u
This commit is contained in:
1 parent
4725ee75ca
commit
3420976bd6
1 file changed
+3
-3
@@ -126,7 +126,7 @@ func parseLevel(lvl string) zapcore.Level {
|
||||
// trace 支持(核心)
|
||||
// ======================
|
||||
|
||||
// Fiber 中使用
|
||||
// Ctx Fiber 中使用
|
||||
func Ctx(c fiber.Ctx) *zap.Logger {
|
||||
if c == nil {
|
||||
return Log
|
||||
@@ -140,7 +140,7 @@ func Ctx(c fiber.Ctx) *zap.Logger {
|
||||
return Log.With(zap.String("trace_id", traceID))
|
||||
}
|
||||
|
||||
// Service / Repo 使用
|
||||
// FromCtx Service / Repo 使用
|
||||
func FromCtx(ctx context.Context) *zap.Logger {
|
||||
if ctx == nil {
|
||||
return Log
|
||||
@@ -154,7 +154,7 @@ func FromCtx(ctx context.Context) *zap.Logger {
|
||||
return Log.With(zap.String("trace_id", traceID))
|
||||
}
|
||||
|
||||
// 注入 trace
|
||||
// WithTrace 注入 trace
|
||||
func WithTrace(ctx context.Context, traceID string) context.Context {
|
||||
return context.WithValue(ctx, TraceIDKey, traceID)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user