From 2c0726449aa396b75cfa039790a969458d67c520 Mon Sep 17 00:00:00 2001 From: egyel Date: Mon, 6 Jul 2020 14:59:57 +0200 Subject: [PATCH] fix(#487): set CallerSkipFrameCount (#488) --- zerolog.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zerolog.go b/zerolog.go index 0c66f50..1857a24 100644 --- a/zerolog.go +++ b/zerolog.go @@ -56,6 +56,7 @@ func (l *zeroLogger) Init(opts ...logger.Option) error { // RESET zerolog.TimeFieldFormat = time.RFC3339 zerolog.ErrorStackMarshaler = nil + zerolog.CallerSkipFrameCount = 4 switch l.opts.Mode { case Development: @@ -89,10 +90,12 @@ func (l *zeroLogger) Init(opts ...logger.Option) error { l.zLog = l.zLog.Level(loggerToZerologLevel(l.opts.Level)) } - // Adding hooks if exist + // Reporting caller if l.opts.ReportCaller { l.zLog = l.zLog.With().Caller().Logger() } + + // Adding hooks if exist for _, hook := range l.opts.Hooks { l.zLog = l.zLog.Hook(hook) }