mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
all: prevent data race when accessing zerolog.Logger
This commit is contained in:
committed by
Cuong Manh Le
parent
59dc74ffbb
commit
19bc44a7f3
@@ -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{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user