Skip to content

Commit a29f1d0

Browse files
committed
feat: add caller information to all log messages
- Add caller information to `Infof` log messages - Add caller information to `Errorf` log messages - Add caller information to `Fatalf` log messages - Add caller information to `Debugf` log messages - Add caller information to `Info` log messages - Add caller information to `Error` log messages - Add caller information to `Fatal` log messages - Add caller information to `Debug` log messages Signed-off-by: appleboy <[email protected]>
1 parent f44c6d5 commit a29f1d0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

zerolog/zerolog.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,33 @@ func New() *Manager {
1515
type Manager struct{}
1616

1717
func (l Manager) Infof(format string, args ...interface{}) {
18-
log.Info().Msgf(format, args...)
18+
log.Info().Caller().Msgf(format, args...)
1919
}
2020

2121
func (l Manager) Errorf(format string, args ...interface{}) {
22-
log.Error().Msgf(format, args...)
22+
log.Error().Caller().Msgf(format, args...)
2323
}
2424

2525
func (l Manager) Fatalf(format string, args ...interface{}) {
26-
log.Fatal().Msgf(format, args...)
26+
log.Fatal().Caller().Msgf(format, args...)
2727
}
2828

2929
func (l Manager) Debugf(format string, args ...interface{}) {
30-
log.Debug().Msgf(format, args...)
30+
log.Debug().Caller().Msgf(format, args...)
3131
}
3232

3333
func (l Manager) Info(args ...interface{}) {
34-
log.Info().Msg(fmt.Sprint(args...))
34+
log.Info().Caller().Msg(fmt.Sprint(args...))
3535
}
3636

3737
func (l Manager) Error(args ...interface{}) {
38-
log.Error().Msg(fmt.Sprint(args...))
38+
log.Error().Caller().Msg(fmt.Sprint(args...))
3939
}
4040

4141
func (l Manager) Fatal(args ...interface{}) {
42-
log.Fatal().Msg(fmt.Sprint(args...))
42+
log.Fatal().Caller().Msg(fmt.Sprint(args...))
4343
}
4444

4545
func (l Manager) Debug(args ...interface{}) {
46-
log.Debug().Msg(fmt.Sprint(args...))
46+
log.Debug().Caller().Msg(fmt.Sprint(args...))
4747
}

0 commit comments

Comments
 (0)