Skip to content

Commit

Permalink
Add comment about ctxzap.AddFields not being concurrent-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
hexdigest committed Nov 25, 2024
1 parent 43a1474 commit 1ef678e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion logging/zap/ctxzap/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ctxzap
import (
"context"

"github.com/grpc-ecosystem/go-grpc-middleware/tags"
grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
Expand All @@ -21,6 +21,8 @@ var (
)

// AddFields adds zap fields to the logger.
//
// This function is not safe to call concurrently.
func AddFields(ctx context.Context, fields ...zapcore.Field) {
l, ok := ctx.Value(ctxMarkerKey).(*ctxLogger)
if !ok || l == nil {
Expand Down

0 comments on commit 1ef678e

Please sign in to comment.