Skip to content

Commit

Permalink
Remove redundant copying
Browse files Browse the repository at this point in the history
  • Loading branch information
elgopher committed Jan 22, 2022
1 parent a629075 commit bed9cc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions adapter/contextadapter/contextadapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func (p adapter) Log(ctx context.Context, entry logger.Entry) {
contextLogger := ctx.Value(p.contextKey)
loggerAdapter := p.adapterFromContextLogger(contextLogger)

newEntry := entry
newEntry.SkippedCallerFrames++
entry.SkippedCallerFrames++

loggerAdapter.Log(ctx, newEntry)
loggerAdapter.Log(ctx, entry)
}
10 changes: 4 additions & 6 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ func (l Logger) With(key string, value interface{}) Logger {

// WithError creates a new Logger with error.
func (l Logger) WithError(err error) Logger {
c := l
c.entry.Error = err
l.entry.Error = err

return c
return l
}

func (l Logger) WithSkippedCallerFrame() Logger {
c := l
c.entry.SkippedCallerFrames++
l.entry.SkippedCallerFrames++

return c
return l
}

func (l Logger) Debug(msg string) {
Expand Down

0 comments on commit bed9cc7

Please sign in to comment.