fix(#487): set CallerSkipFrameCount (#488)

This commit is contained in:
egyel 2020-07-06 14:59:57 +02:00 committed by Vasiliy Tolstov
parent 7ce08034e0
commit 2c0726449a

View File

@ -56,6 +56,7 @@ func (l *zeroLogger) Init(opts ...logger.Option) error {
// RESET // RESET
zerolog.TimeFieldFormat = time.RFC3339 zerolog.TimeFieldFormat = time.RFC3339
zerolog.ErrorStackMarshaler = nil zerolog.ErrorStackMarshaler = nil
zerolog.CallerSkipFrameCount = 4
switch l.opts.Mode { switch l.opts.Mode {
case Development: case Development:
@ -89,10 +90,12 @@ func (l *zeroLogger) Init(opts ...logger.Option) error {
l.zLog = l.zLog.Level(loggerToZerologLevel(l.opts.Level)) l.zLog = l.zLog.Level(loggerToZerologLevel(l.opts.Level))
} }
// Adding hooks if exist // Reporting caller
if l.opts.ReportCaller { if l.opts.ReportCaller {
l.zLog = l.zLog.With().Caller().Logger() l.zLog = l.zLog.With().Caller().Logger()
} }
// Adding hooks if exist
for _, hook := range l.opts.Hooks { for _, hook := range l.opts.Hooks {
l.zLog = l.zLog.Hook(hook) l.zLog = l.zLog.Hook(hook)
} }