From 8217ecade7690c82e41b1db5aa8a7ffd89dc278d Mon Sep 17 00:00:00 2001
From: Semyon Krestyaninov <ensiouel@gmail.com>
Date: Wed, 7 Feb 2024 09:09:53 +0300
Subject: [PATCH] refactor caller field

---
 pkg/log/zap/field.go | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/pkg/log/zap/field.go b/pkg/log/zap/field.go
index 4cf6ad44..53006a02 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)
 }
 
-- 
GitLab