Skip to content

Commit

Permalink
Filter by log level before anything else
Browse files Browse the repository at this point in the history
This saves a lot of work walking the stack to find the caller, and a bit
more to format the timestamp.

Recommended at go-kit/log#14 (comment)

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
  • Loading branch information
bboreham committed Oct 17, 2021
1 parent 98fdea3 commit 5ac183a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion logging/gokit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func NewGoKitFormat(l Level, f Format) Interface {

// stand-alone for test purposes
func addStandardFields(logger log.Logger, l Level) Interface {
logger = log.With(logger, "ts", log.DefaultTimestampUTC, "caller", log.Caller(5))
logger = level.NewFilter(logger, l.Gokit)
logger = log.With(logger, "ts", log.DefaultTimestampUTC, "caller", log.DefaultCaller)
return gokit{logger}
}

Expand Down

0 comments on commit 5ac183a

Please sign in to comment.