Skip to content

Commit

Permalink
fix logger value passing
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwe committed Oct 4, 2024
1 parent 2406243 commit 587ee64
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,24 @@ type UnlikelyLogger struct {
keysAndValues []any
}

func makeUnlikelyLogger(logger Logger, keysAndValues ...any) UnlikelyLogger {
return UnlikelyLogger{logger, keysAndValues}
}

func (l UnlikelyLogger) Debugw(msg string, keysAndValues ...any) {
l.logger.Debugw(msg, slices.Concat(l.keysAndValues, keysAndValues))
l.logger.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.logger.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.logger.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.logger.Errorw(msg, err, slices.Concat(l.keysAndValues, keysAndValues)...)
}

func (l UnlikelyLogger) WithValues(keysAndValues ...any) UnlikelyLogger {
return makeUnlikelyLogger(l.logger, slices.Concat(l.keysAndValues, keysAndValues))
return UnlikelyLogger{l.logger, slices.Concat(l.keysAndValues, keysAndValues)}
}

type sharedConfig struct {
Expand Down Expand Up @@ -363,7 +359,7 @@ func (l *zapLogger[T]) WithValues(keysAndValues ...any) Logger {
}

func (l *zapLogger[T]) WithUnlikelyValues(keysAndValues ...any) UnlikelyLogger {
return makeUnlikelyLogger(l, keysAndValues)
return UnlikelyLogger{l, keysAndValues}
}

func (l *zapLogger[T]) WithName(name string) Logger {
Expand Down Expand Up @@ -452,7 +448,7 @@ func (l LogRLogger) WithValues(keysAndValues ...any) Logger {
}

func (l LogRLogger) WithUnlikelyValues(keysAndValues ...any) UnlikelyLogger {
return makeUnlikelyLogger(l, keysAndValues)
return UnlikelyLogger{l, keysAndValues}
}

func (l LogRLogger) WithName(name string) Logger {
Expand Down

0 comments on commit 587ee64

Please sign in to comment.