mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-10-25 19:33:46 +08:00
fix g.Log()的使用
This commit is contained in:
@@ -20,7 +20,7 @@ var (
|
|||||||
Description: ``,
|
Description: ``,
|
||||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||||
flags := parser.GetOptAll()
|
flags := parser.GetOptAll()
|
||||||
g.Log().Debug(ctx, "flags:%+v", flags)
|
g.Log().Debugf(ctx, "flags:%+v", flags)
|
||||||
if len(flags) == 0 {
|
if len(flags) == 0 {
|
||||||
g.Log().Fatal(ctx, "工具参数不能为空")
|
g.Log().Fatal(ctx, "工具参数不能为空")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func ScanInstall(m Module) (record *InstallRecord, err error) {
|
|||||||
func IsInstall(m Module) bool {
|
func IsInstall(m Module) bool {
|
||||||
record, err := ScanInstall(m)
|
record, err := ScanInstall(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Log().Debugf(m.Ctx(), err.Error())
|
g.Log().Debug(m.Ctx(), err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if record == nil {
|
if record == nil {
|
||||||
|
|||||||
4
server/internal/library/cache/cache.go
vendored
4
server/internal/library/cache/cache.go
vendored
@@ -37,7 +37,7 @@ func SetAdapter(ctx context.Context) {
|
|||||||
|
|
||||||
if conf == nil {
|
if conf == nil {
|
||||||
conf = new(model.CacheConfig)
|
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 {
|
switch conf.Adapter {
|
||||||
@@ -45,7 +45,7 @@ func SetAdapter(ctx context.Context) {
|
|||||||
adapter = gcache.NewAdapterRedis(g.Redis())
|
adapter = gcache.NewAdapterRedis(g.Redis())
|
||||||
case "file":
|
case "file":
|
||||||
if conf.FileDir == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func Get(ctx context.Context) *model.Context {
|
|||||||
func SetUser(ctx context.Context, user *model.Identity) {
|
func SetUser(ctx context.Context, user *model.Identity) {
|
||||||
c := Get(ctx)
|
c := Get(ctx)
|
||||||
if c == nil {
|
if c == nil {
|
||||||
g.Log().Warningf(ctx, "contexts.SetUser, c == nil ")
|
g.Log().Warning(ctx, "contexts.SetUser, c == nil ")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.User = user
|
c.User = user
|
||||||
@@ -44,7 +44,7 @@ func SetUser(ctx context.Context, user *model.Identity) {
|
|||||||
func SetResponse(ctx context.Context, response *model.Response) {
|
func SetResponse(ctx context.Context, response *model.Response) {
|
||||||
c := Get(ctx)
|
c := Get(ctx)
|
||||||
if c == nil {
|
if c == nil {
|
||||||
g.Log().Warningf(ctx, "contexts.SetResponse, c == nil ")
|
g.Log().Warning(ctx, "contexts.SetResponse, c == nil ")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Response = response
|
c.Response = response
|
||||||
@@ -54,7 +54,7 @@ func SetResponse(ctx context.Context, response *model.Response) {
|
|||||||
func SetModule(ctx context.Context, module string) {
|
func SetModule(ctx context.Context, module string) {
|
||||||
c := Get(ctx)
|
c := Get(ctx)
|
||||||
if c == nil {
|
if c == nil {
|
||||||
g.Log().Warningf(ctx, "contexts.SetModule, c == nil ")
|
g.Log().Warning(ctx, "contexts.SetModule, c == nil ")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Module = module
|
c.Module = module
|
||||||
@@ -64,7 +64,7 @@ func SetModule(ctx context.Context, module string) {
|
|||||||
func SetTakeUpTime(ctx context.Context, takeUpTime int64) {
|
func SetTakeUpTime(ctx context.Context, takeUpTime int64) {
|
||||||
c := Get(ctx)
|
c := Get(ctx)
|
||||||
if c == nil {
|
if c == nil {
|
||||||
g.Log().Warningf(ctx, "contexts.SetTakeUpTime, c == nil ")
|
g.Log().Warning(ctx, "contexts.SetTakeUpTime, c == nil ")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.TakeUpTime = takeUpTime
|
c.TakeUpTime = takeUpTime
|
||||||
@@ -120,7 +120,7 @@ func GetModule(ctx context.Context) string {
|
|||||||
func SetAddonName(ctx context.Context, name string) {
|
func SetAddonName(ctx context.Context, name string) {
|
||||||
c := Get(ctx)
|
c := Get(ctx)
|
||||||
if c == nil {
|
if c == nil {
|
||||||
g.Log().Warningf(ctx, "contexts.SetAddonName, c == nil ")
|
g.Log().Warning(ctx, "contexts.SetAddonName, c == nil ")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Get(ctx).AddonName = name
|
Get(ctx).AddonName = name
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func FilterAuthWithField(filterField string) func(m *gdb.Model) *gdb.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if role == nil {
|
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")
|
sq := g.Model("admin_member").Fields("id")
|
||||||
@@ -77,7 +77,7 @@ func FilterAuthWithField(filterField string) func(m *gdb.Model) *gdb.Model {
|
|||||||
case consts.RoleDataSelfAndAllSub: // 自己和全部下级
|
case consts.RoleDataSelfAndAllSub: // 自己和全部下级
|
||||||
m = m.WhereIn(filterField, GetSelfAndAllSub(co.User.Id))
|
m = m.WhereIn(filterField, GetSelfAndAllSub(co.User.Id))
|
||||||
default:
|
default:
|
||||||
g.Log().Panicf(ctx, "dataScope is not registered")
|
g.Log().Panic(ctx, "dataScope is not registered")
|
||||||
}
|
}
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ func GetPublicIP(ctx context.Context) (ip string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if data == nil {
|
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 "0.0.0.0", nil
|
||||||
}
|
}
|
||||||
return data.Ip, nil
|
return data.Ip, nil
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func init() {
|
|||||||
mqProducerInstanceMap = make(map[string]MqProducer)
|
mqProducerInstanceMap = make(map[string]MqProducer)
|
||||||
mqConsumerInstanceMap = make(map[string]MqConsumer)
|
mqConsumerInstanceMap = make(map[string]MqConsumer)
|
||||||
if err := g.Cfg().MustGet(ctx, "queue").Scan(&config); err != nil {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func (s *sMiddleware) Blacklist(r *ghttp.Request) {
|
|||||||
response.JsonExit(r, gcode.CodeServerBusy.Code(), "请求异常,已被封禁,如有疑问请联系管理员!")
|
response.JsonExit(r, gcode.CodeServerBusy.Code(), "请求异常,已被封禁,如有疑问请联系管理员!")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g.Log().Infof(r.Context(), "blacklists uninitialized")
|
g.Log().Info(r.Context(), "blacklists uninitialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Middleware.Next()
|
r.Middleware.Next()
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ func (manager *ClientManager) start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case <-manager.closeSignal:
|
case <-manager.closeSignal:
|
||||||
g.Log().Infof(ctxManager, "websocket closeSignal quit..")
|
g.Log().Info(ctxManager, "websocket closeSignal quit..")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func IsDNSName(s string) bool {
|
|||||||
func IsHTTPS(ctx context.Context) bool {
|
func IsHTTPS(ctx context.Context) bool {
|
||||||
r := ghttp.RequestFromCtx(ctx)
|
r := ghttp.RequestFromCtx(ctx)
|
||||||
if r == nil {
|
if r == nil {
|
||||||
g.Log().Infof(ctx, "IsHTTPS ctx not request")
|
g.Log().Info(ctx, "IsHTTPS ctx not request")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
|||||||
Reference in New Issue
Block a user