diff --git a/pkg/log/zap/field.go b/pkg/log/zap/field.go index 4cf6ad44acf9f141e9fc5863790467fd9a4cdeb4..53006a021d4e77af10609bb32b1d03a30bcd429b 100644 --- a/pkg/log/zap/field.go +++ b/pkg/log/zap/field.go @@ -1,7 +1,6 @@ package zap import ( - "context" "fmt" "go.uber.org/zap" @@ -41,12 +40,7 @@ func Object(v any) zapcore.Field { return zap.String("object", object) } -type callerKey struct{} - -// ContextWithCaller добавляет в контекст передаваемый аргумент в качестве "вызывающего" в формате GlobalID. -// Поддерживает один из типов: string, fmt.Stringer. Если передан аргумент другого типа, в качестве вызывающего -// будет установлен "unknown". -func ContextWithCaller(parent context.Context, v any) context.Context { +func Caller(v any) zapcore.Field { var caller string switch value := v.(type) { case string: @@ -56,14 +50,6 @@ func ContextWithCaller(parent context.Context, v any) context.Context { default: caller = unknownCaller } - return context.WithValue(parent, callerKey{}, caller) -} - -func CallerFromContext(ctx context.Context) zapcore.Field { - caller, ok := ctx.Value(callerKey{}).(string) - if !ok { - caller = unknownCaller - } return zap.String("caller", caller) }