Skip to content

Commit

Permalink
fix unlikely logger call depth (#849)
Browse files Browse the repository at this point in the history
* fix unlikely logger call depth

* mute test
  • Loading branch information
paulwe committed Oct 13, 2024
1 parent 447f3e7 commit de5ac83
Show file tree
Hide file tree
Showing 2 changed files with 9 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
1 change: 1 addition & 0 deletions utils/rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ func TestSlack(t *testing.T) {
}

func TestSetRateLimitOnTheFly(t *testing.T) {
t.Skip(UnstableTest)
runTest(t, func(r testRunner) {
// Set rate to 1hz
limiter, ok := r.createLimiter(1, WithoutSlack).(*LeakyBucket)
Expand Down

0 comments on commit de5ac83

Please sign in to comment.