Skip to content

Commit

Permalink
feat: add caller information to all log messages
Browse files Browse the repository at this point in the history
- 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]>
  • Loading branch information
appleboy committed Jan 19, 2025
1 parent f44c6d5 commit a29f1d0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions zerolog/zerolog.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ func New() *Manager {
type Manager struct{}

func (l Manager) Infof(format string, args ...interface{}) {
log.Info().Msgf(format, args...)
log.Info().Caller().Msgf(format, args...)
}

func (l Manager) Errorf(format string, args ...interface{}) {
log.Error().Msgf(format, args...)
log.Error().Caller().Msgf(format, args...)
}

func (l Manager) Fatalf(format string, args ...interface{}) {
log.Fatal().Msgf(format, args...)
log.Fatal().Caller().Msgf(format, args...)
}

func (l Manager) Debugf(format string, args ...interface{}) {
log.Debug().Msgf(format, args...)
log.Debug().Caller().Msgf(format, args...)
}

func (l Manager) Info(args ...interface{}) {
log.Info().Msg(fmt.Sprint(args...))
log.Info().Caller().Msg(fmt.Sprint(args...))
}

func (l Manager) Error(args ...interface{}) {
log.Error().Msg(fmt.Sprint(args...))
log.Error().Caller().Msg(fmt.Sprint(args...))
}

func (l Manager) Fatal(args ...interface{}) {
log.Fatal().Msg(fmt.Sprint(args...))
log.Fatal().Caller().Msg(fmt.Sprint(args...))
}

func (l Manager) Debug(args ...interface{}) {
log.Debug().Msg(fmt.Sprint(args...))
log.Debug().Caller().Msg(fmt.Sprint(args...))
}

0 comments on commit a29f1d0

Please sign in to comment.