Skip to content

Commit

Permalink
pkg/logger: add SugaredLogger methods (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Dec 13, 2023
1 parent fc53b0a commit b6c433e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/logger/sugared.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type SugaredLogger interface {
Trace(args ...interface{})
Tracef(format string, vals ...interface{})
Tracew(msg string, keysAndVals ...interface{})

Named(string) SugaredLogger
With(keyvals ...any) SugaredLogger
Helper(skip int) SugaredLogger
}

// Sugared returns a new SugaredLogger wrapping the given Logger.
Expand Down Expand Up @@ -119,3 +123,15 @@ func (s *sugared) Criticalw(msg string, keysAndValues ...interface{}) {
}
s.h.Errorw(critPrefix+msg, keysAndValues...)
}

func (s *sugared) Named(n string) SugaredLogger {
return Sugared(Named(s.Logger, n))
}

func (s *sugared) With(keyvals ...interface{}) SugaredLogger {
return Sugared(With(s.Logger, keyvals...))
}

func (s *sugared) Helper(skip int) SugaredLogger {
return Sugared(Helper(s.Logger, skip))
}

0 comments on commit b6c433e

Please sign in to comment.