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

Method Ctx

event.go:499–504  ·  view source on GitHub ↗

Ctx adds the Go Context to the *Event context. The context is not rendered in the output message, but is available to hooks and to Func() calls via the GetCtx() accessor. A typical use case is to extract tracing information from the Go Ctx.

(ctx context.Context)

Source from the content-addressed store, hash-verified

497// GetCtx() accessor. A typical use case is to extract tracing information from
498// the Go Ctx.
499func (e *Event) Ctx(ctx context.Context) *Event {
500 if e != nil {
501 e.ctx = ctx
502 }
503 return e
504}
505
506// GetCtx retrieves the Go context.Context which is optionally stored in the
507// Event. This allows Hooks and functions passed to Func() to retrieve values

Callers 10

TestEvent_WithNilEventFunction · 0.95
TestWithFunction · 0.45
TestWithResetFunction · 0.45
TestFieldsFunction · 0.45
TestFieldsDisabledFunction · 0.45
TestHookFunction · 0.45
BenchmarkLogFieldTypeFunction · 0.45
HandleMethod · 0.45
ExampleCtxFunction · 0.45

Calls

no outgoing calls

Tested by 9

TestEvent_WithNilEventFunction · 0.76
TestWithFunction · 0.36
TestWithResetFunction · 0.36
TestFieldsFunction · 0.36
TestFieldsDisabledFunction · 0.36
TestHookFunction · 0.36
BenchmarkLogFieldTypeFunction · 0.36
ExampleCtxFunction · 0.36