github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/logger/context_with_logging.go (about) 1 package logger 2 3 import ( 4 "golang.org/x/net/context" 5 ) 6 7 type Context struct { 8 ctx context.Context 9 Logger 10 } 11 12 var _ ContextInterface = Context{} 13 14 func (c Context) Ctx() context.Context { 15 return c.ctx 16 } 17 18 func NewContext(c context.Context, l Logger) Context { 19 return Context{ctx: c, Logger: l} 20 } 21 22 func (c Context) UpdateContextToLoggerContext(ctx context.Context) ContextInterface { 23 return NewContext(ctx, c.Logger) 24 } 25 26 func (c Context) Debug(format string, arg ...interface{}) { 27 c.Logger.CloneWithAddedDepth(1).CDebugf(c.ctx, format, arg...) 28 } 29 30 func (c Context) Info(format string, arg ...interface{}) { 31 c.Logger.CloneWithAddedDepth(1).CInfof(c.ctx, format, arg...) 32 } 33 34 func (c Context) Notice(format string, arg ...interface{}) { 35 c.Logger.CloneWithAddedDepth(1).CNoticef(c.ctx, format, arg...) 36 } 37 38 func (c Context) Warning(format string, arg ...interface{}) { 39 c.Logger.CloneWithAddedDepth(1).CWarningf(c.ctx, format, arg...) 40 } 41 42 func (c Context) Error(format string, arg ...interface{}) { 43 c.Logger.CloneWithAddedDepth(1).CErrorf(c.ctx, format, arg...) 44 } 45 46 func (c Context) Critical(format string, arg ...interface{}) { 47 c.Logger.CloneWithAddedDepth(1).CCriticalf(c.ctx, format, arg...) 48 } 49 50 func (c Context) Fatal(format string, arg ...interface{}) { 51 c.Logger.CloneWithAddedDepth(1).CFatalf(c.ctx, format, arg...) 52 }