Skip to content

Commit

Permalink
fix unlikely logger call depth
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwe committed Oct 11, 2024
1 parent 19b686d commit 98a421c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,24 @@ type UnlikelyLogger struct {
keysAndValues []any
}

func (l UnlikelyLogger) makeLogger() Logger {
return l.logger.WithCallDepth(2)
}

func (l UnlikelyLogger) Debugw(msg string, keysAndValues ...any) {
l.logger.Debugw(msg, slices.Concat(l.keysAndValues, keysAndValues)...)
l.makeLogger().Debugw(msg, slices.Concat(l.keysAndValues, keysAndValues)...)
}

func (l UnlikelyLogger) Infow(msg string, keysAndValues ...any) {
l.logger.Infow(msg, slices.Concat(l.keysAndValues, keysAndValues)...)
l.makeLogger().Infow(msg, slices.Concat(l.keysAndValues, keysAndValues)...)
}

func (l UnlikelyLogger) Warnw(msg string, err error, keysAndValues ...any) {
l.logger.Warnw(msg, err, slices.Concat(l.keysAndValues, keysAndValues)...)
l.makeLogger().Warnw(msg, err, slices.Concat(l.keysAndValues, keysAndValues)...)
}

func (l UnlikelyLogger) Errorw(msg string, err error, keysAndValues ...any) {
l.logger.Errorw(msg, err, slices.Concat(l.keysAndValues, keysAndValues)...)
l.makeLogger().Errorw(msg, err, slices.Concat(l.keysAndValues, keysAndValues)...)
}

func (l UnlikelyLogger) WithValues(keysAndValues ...any) UnlikelyLogger {
Expand Down

0 comments on commit 98a421c

Please sign in to comment.