Skip to content

Commit

Permalink
Merge pull request #96 from ipfs/fix/caller
Browse files Browse the repository at this point in the history
Fix caller not being added
  • Loading branch information
Kubuxu authored Jun 9, 2020
2 parents 9a85138 + 54eefc7 commit f8d20c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions log_level_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestLogLevel(t *testing.T) {
for {
var entry struct {
Message string `json:"msg"`
Caller string `json:"caller"`
}
err := decoder.Decode(&entry)
switch err {
Expand All @@ -30,6 +31,9 @@ func TestLogLevel(t *testing.T) {
if entry.Message != "bar" {
t.Errorf("unexpected message: %s", entry.Message)
}
if entry.Caller == "" {
t.Errorf("no caller in log entry")
}
}
}()
logger.Debugw("foo")
Expand Down
5 changes: 4 additions & 1 deletion setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ func getLogger(name string) *zap.SugaredLogger {
if !ok {
levels[name] = zap.NewAtomicLevelAt(zapcore.Level(defaultLevel))
log = zap.New(loggerCore).
WithOptions(zap.IncreaseLevel(levels[name])).
WithOptions(
zap.IncreaseLevel(levels[name]),
zap.AddCaller(),
).
Named(name).
Sugar()

Expand Down

0 comments on commit f8d20c3

Please sign in to comment.