From 8df1a0401585a8c62e34d16490b0e07903669218 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Wed, 13 Dec 2023 07:45:06 -0600 Subject: [PATCH] pkg/logger: add SugaredLogger methods (#290) --- pkg/logger/sugared.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/logger/sugared.go b/pkg/logger/sugared.go index a5eb029b9..753c292a9 100644 --- a/pkg/logger/sugared.go +++ b/pkg/logger/sugared.go @@ -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. @@ -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)) +}