all: prevent data race when accessing zerolog.Logger

This commit is contained in:
Cuong Manh Le
2023-07-26 16:48:17 +00:00
committed by Cuong Manh Le
parent 59dc74ffbb
commit 19bc44a7f3
24 changed files with 242 additions and 222 deletions
+10
View File
@@ -4,14 +4,24 @@ import (
"context"
"fmt"
"io"
"sync/atomic"
"github.com/rs/zerolog"
)
func init() {
l := zerolog.New(io.Discard)
ProxyLogger.Store(&l)
}
// ProxyLog emits the log record for proxy operations.
// The caller should set it only once.
// DEPRECATED: use ProxyLogger instead.
var ProxyLog = zerolog.New(io.Discard)
// ProxyLogger emits the log record for proxy operations.
var ProxyLogger atomic.Pointer[zerolog.Logger]
// ReqIdCtxKey is the context.Context key for a request id.
type ReqIdCtxKey struct{}