MCPcopy
hub / github.com/rs/zerolog / Ctx

Function Ctx

ctx.go:44–51  ·  view source on GitHub ↗

Ctx returns the Logger associated with the ctx. If no logger is associated, DefaultContextLogger is returned, unless DefaultContextLogger is nil, in which case a disabled logger is returned.

(ctx context.Context)

Source from the content-addressed store, hash-verified

42// is associated, DefaultContextLogger is returned, unless DefaultContextLogger
43// is nil, in which case a disabled logger is returned.
44func Ctx(ctx context.Context) *Logger {
45 if l, ok := ctx.Value(ctxKey{}).(*Logger); ok {
46 return l
47 } else if l = DefaultContextLogger; l != nil {
48 return l
49 }
50 return disabledLogger
51}

Callers 15

CtxFunction · 0.92
URLHandlerFunction · 0.92
MethodHandlerFunction · 0.92
RequestHandlerFunction · 0.92
RemoteAddrHandlerFunction · 0.92
RemoteIPHandlerFunction · 0.92
UserAgentHandlerFunction · 0.92
RefererHandlerFunction · 0.92
ProtoHandlerFunction · 0.92
HTTPVersionHandlerFunction · 0.92
RequestIDHandlerFunction · 0.92
CustomHeaderHandlerFunction · 0.92

Calls

no outgoing calls

Tested by 3

TestCtxFunction · 0.56
TestCtxDisabledFunction · 0.56