diff --git a/context.go b/context.go index 718ba94..dad0684 100644 --- a/context.go +++ b/context.go @@ -488,3 +488,28 @@ func (c *Context) GetHTTPC() *httpc.Client { func (c *Context) GetLogger() *reco.Logger { return c.engine.LogReco } + +// === 日志记录 === +func (c *Context) Debugf(format string, args ...any) { + c.engine.LogReco.Debugf(format, args...) +} + +func (c *Context) Infof(format string, args ...any) { + c.engine.LogReco.Infof(format, args...) +} + +func (c *Context) Warnf(format string, args ...any) { + c.engine.LogReco.Warnf(format, args...) +} + +func (c *Context) Errorf(format string, args ...any) { + c.engine.LogReco.Errorf(format, args...) +} + +func (c *Context) Fatalf(format string, args ...any) { + c.engine.LogReco.Fatalf(format, args...) +} + +func (c *Context) Panicf(format string, args ...any) { + c.engine.LogReco.Panicf(format, args...) +} diff --git a/logreco.go b/logreco.go index 290778f..7182c51 100644 --- a/logreco.go +++ b/logreco.go @@ -3,6 +3,7 @@ package touka import ( "log" "os" + "time" "github.com/fenthope/reco" ) @@ -11,6 +12,7 @@ import ( var defaultLogRecoConfig = reco.Config{ Level: reco.LevelInfo, Mode: reco.ModeText, + TimeFormat: time.RFC3339, Output: os.Stdout, Async: true, DefaultFields: nil,