Skip to content

Commit 570433b

Browse files
committed
fix: use "tag" as the key to identify logs
1 parent 05633f0 commit 570433b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

otredis/dependency.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func provideRedisFactory(option *providersOption) func(p factoryIn) (factoryOut,
139139
MasterName: base.MasterName,
140140
}
141141
option.interceptor(name, &full)
142-
redis.SetLogger(&RedisLogAdapter{level.Debug(p.Logger)})
142+
redis.SetLogger(&RedisLogAdapter{level.Debug(log.With(p.Logger, "tag", "redis"))})
143143

144144
client := redis.NewUniversalClient(&full)
145145
if p.Tracer != nil {

serve.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (s serveIn) httpServe(ctx context.Context, logger logging.LevelLogger) (fun
6767

6868
router.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
6969
tpl, _ := route.GetPathTemplate()
70-
level.Debug(logger).Log("service", "http", "path", tpl)
70+
level.Debug(logger).Log("tag", "http", "path", tpl)
7171
return nil
7272
})
7373

@@ -108,7 +108,7 @@ func (s serveIn) grpcServe(ctx context.Context, logger logging.LevelLogger) (fun
108108

109109
for module, info := range s.GRPCServer.GetServiceInfo() {
110110
for _, method := range info.Methods {
111-
level.Debug(logger).Log("service", "grpc", "path", fmt.Sprintf("%s/%s", module, method.Name))
111+
level.Debug(logger).Log("tag", "grpc", "path", fmt.Sprintf("%s/%s", module, method.Name))
112112
}
113113
}
114114

@@ -141,7 +141,8 @@ func (s serveIn) cronServe(ctx context.Context, logger logging.LevelLogger) (fun
141141
return nil, nil, nil
142142
}
143143
if s.Cron == nil {
144-
s.Cron = cron.New(cron.WithLogger(cronopts.CronLogAdapter{Logging: s.Logger}))
144+
logger := log.With(s.Logger, "tag", "cron")
145+
s.Cron = cron.New(cron.WithLogger(cronopts.CronLogAdapter{Logging: logger}))
145146
}
146147
s.Container.ApplyCron(s.Cron)
147148

0 commit comments

Comments
 (0)