diff --git a/log_level_test.go b/log_level_test.go index c038148..25a8e55 100644 --- a/log_level_test.go +++ b/log_level_test.go @@ -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 { @@ -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") diff --git a/setup.go b/setup.go index 65f23f7..79ff0ad 100644 --- a/setup.go +++ b/setup.go @@ -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()