From 67a0a38fd4a8fb548eccdd8fe2da7c48dedde77d Mon Sep 17 00:00:00 2001 From: maxbad <26058031@qq.com> Date: Sun, 7 May 2023 22:35:29 +0800 Subject: [PATCH] =?UTF-8?q?fix=20g.Log()=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/internal/cmd/tools.go | 2 +- server/internal/library/addons/install.go | 2 +- server/internal/library/cache/cache.go | 4 ++-- server/internal/library/contexts/context.go | 10 +++++----- server/internal/library/hgorm/handler/filter_auth.go | 4 ++-- server/internal/library/location/location.go | 2 +- server/internal/library/queue/init.go | 2 +- server/internal/logic/middleware/limit_blacklist.go | 2 +- server/internal/websocket/client_manager.go | 2 +- server/utility/validate/validate.go | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/server/internal/cmd/tools.go b/server/internal/cmd/tools.go index 07a8b06..99e5e0e 100644 --- a/server/internal/cmd/tools.go +++ b/server/internal/cmd/tools.go @@ -20,7 +20,7 @@ var ( Description: ``, Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { flags := parser.GetOptAll() - g.Log().Debug(ctx, "flags:%+v", flags) + g.Log().Debugf(ctx, "flags:%+v", flags) if len(flags) == 0 { g.Log().Fatal(ctx, "工具参数不能为空") return diff --git a/server/internal/library/addons/install.go b/server/internal/library/addons/install.go index e24d81d..85ba87b 100644 --- a/server/internal/library/addons/install.go +++ b/server/internal/library/addons/install.go @@ -35,7 +35,7 @@ func ScanInstall(m Module) (record *InstallRecord, err error) { func IsInstall(m Module) bool { record, err := ScanInstall(m) if err != nil { - g.Log().Debugf(m.Ctx(), err.Error()) + g.Log().Debug(m.Ctx(), err.Error()) return false } if record == nil { diff --git a/server/internal/library/cache/cache.go b/server/internal/library/cache/cache.go index ce6e512..668c933 100644 --- a/server/internal/library/cache/cache.go +++ b/server/internal/library/cache/cache.go @@ -37,7 +37,7 @@ func SetAdapter(ctx context.Context) { if conf == nil { conf = new(model.CacheConfig) - g.Log().Infof(ctx, "no cache driver is configured. default memory cache is used.") + g.Log().Info(ctx, "no cache driver is configured. default memory cache is used.") } switch conf.Adapter { @@ -45,7 +45,7 @@ func SetAdapter(ctx context.Context) { adapter = gcache.NewAdapterRedis(g.Redis()) case "file": if conf.FileDir == "" { - g.Log().Fatalf(ctx, "file path must be configured for file caching.") + g.Log().Fatal(ctx, "file path must be configured for file caching.") return } diff --git a/server/internal/library/contexts/context.go b/server/internal/library/contexts/context.go index b2f86f7..c01d02a 100644 --- a/server/internal/library/contexts/context.go +++ b/server/internal/library/contexts/context.go @@ -34,7 +34,7 @@ func Get(ctx context.Context) *model.Context { func SetUser(ctx context.Context, user *model.Identity) { c := Get(ctx) if c == nil { - g.Log().Warningf(ctx, "contexts.SetUser, c == nil ") + g.Log().Warning(ctx, "contexts.SetUser, c == nil ") return } c.User = user @@ -44,7 +44,7 @@ func SetUser(ctx context.Context, user *model.Identity) { func SetResponse(ctx context.Context, response *model.Response) { c := Get(ctx) if c == nil { - g.Log().Warningf(ctx, "contexts.SetResponse, c == nil ") + g.Log().Warning(ctx, "contexts.SetResponse, c == nil ") return } c.Response = response @@ -54,7 +54,7 @@ func SetResponse(ctx context.Context, response *model.Response) { func SetModule(ctx context.Context, module string) { c := Get(ctx) if c == nil { - g.Log().Warningf(ctx, "contexts.SetModule, c == nil ") + g.Log().Warning(ctx, "contexts.SetModule, c == nil ") return } c.Module = module @@ -64,7 +64,7 @@ func SetModule(ctx context.Context, module string) { func SetTakeUpTime(ctx context.Context, takeUpTime int64) { c := Get(ctx) if c == nil { - g.Log().Warningf(ctx, "contexts.SetTakeUpTime, c == nil ") + g.Log().Warning(ctx, "contexts.SetTakeUpTime, c == nil ") return } c.TakeUpTime = takeUpTime @@ -120,7 +120,7 @@ func GetModule(ctx context.Context) string { func SetAddonName(ctx context.Context, name string) { c := Get(ctx) if c == nil { - g.Log().Warningf(ctx, "contexts.SetAddonName, c == nil ") + g.Log().Warning(ctx, "contexts.SetAddonName, c == nil ") return } Get(ctx).AddonName = name diff --git a/server/internal/library/hgorm/handler/filter_auth.go b/server/internal/library/hgorm/handler/filter_auth.go index ecee5a8..843520f 100644 --- a/server/internal/library/hgorm/handler/filter_auth.go +++ b/server/internal/library/hgorm/handler/filter_auth.go @@ -56,7 +56,7 @@ func FilterAuthWithField(filterField string) func(m *gdb.Model) *gdb.Model { } if role == nil { - g.Log().Panicf(ctx, "failed to role information roleModel == nil") + g.Log().Panic(ctx, "failed to role information roleModel == nil") } sq := g.Model("admin_member").Fields("id") @@ -77,7 +77,7 @@ func FilterAuthWithField(filterField string) func(m *gdb.Model) *gdb.Model { case consts.RoleDataSelfAndAllSub: // 自己和全部下级 m = m.WhereIn(filterField, GetSelfAndAllSub(co.User.Id)) default: - g.Log().Panicf(ctx, "dataScope is not registered") + g.Log().Panic(ctx, "dataScope is not registered") } return m diff --git a/server/internal/library/location/location.go b/server/internal/library/location/location.go index 7a22ba2..00e0262 100644 --- a/server/internal/library/location/location.go +++ b/server/internal/library/location/location.go @@ -174,7 +174,7 @@ func GetPublicIP(ctx context.Context) (ip string, err error) { } if data == nil { - g.Log().Infof(ctx, "publicIP address Parsing failure, check the network and firewall blocking.") + g.Log().Info(ctx, "publicIP address Parsing failure, check the network and firewall blocking.") return "0.0.0.0", nil } return data.Ip, nil diff --git a/server/internal/library/queue/init.go b/server/internal/library/queue/init.go index 159157b..0d83f92 100644 --- a/server/internal/library/queue/init.go +++ b/server/internal/library/queue/init.go @@ -81,7 +81,7 @@ func init() { mqProducerInstanceMap = make(map[string]MqProducer) mqConsumerInstanceMap = make(map[string]MqConsumer) if err := g.Cfg().MustGet(ctx, "queue").Scan(&config); err != nil { - g.Log().Warning(ctx, "queue init err:%+v", err) + g.Log().Warningf(ctx, "queue init err:%+v", err) } } diff --git a/server/internal/logic/middleware/limit_blacklist.go b/server/internal/logic/middleware/limit_blacklist.go index 725ef02..b07cf1d 100644 --- a/server/internal/logic/middleware/limit_blacklist.go +++ b/server/internal/logic/middleware/limit_blacklist.go @@ -16,7 +16,7 @@ func (s *sMiddleware) Blacklist(r *ghttp.Request) { response.JsonExit(r, gcode.CodeServerBusy.Code(), "请求异常,已被封禁,如有疑问请联系管理员!") } } else { - g.Log().Infof(r.Context(), "blacklists uninitialized") + g.Log().Info(r.Context(), "blacklists uninitialized") } r.Middleware.Next() diff --git a/server/internal/websocket/client_manager.go b/server/internal/websocket/client_manager.go index 1e089ef..f6e045d 100644 --- a/server/internal/websocket/client_manager.go +++ b/server/internal/websocket/client_manager.go @@ -291,7 +291,7 @@ func (manager *ClientManager) start() { } } case <-manager.closeSignal: - g.Log().Infof(ctxManager, "websocket closeSignal quit..") + g.Log().Info(ctxManager, "websocket closeSignal quit..") return } diff --git a/server/utility/validate/validate.go b/server/utility/validate/validate.go index cc698d3..1fd1ac4 100644 --- a/server/utility/validate/validate.go +++ b/server/utility/validate/validate.go @@ -30,7 +30,7 @@ func IsDNSName(s string) bool { func IsHTTPS(ctx context.Context) bool { r := ghttp.RequestFromCtx(ctx) if r == nil { - g.Log().Infof(ctx, "IsHTTPS ctx not request") + g.Log().Info(ctx, "IsHTTPS ctx not request") return false } var (