MCPcopy Index your code
hub / github.com/DoNewsCode/core / WithContext

Function WithContext

logging/log.go:121–127  ·  view source on GitHub ↗

WithContext decorates the log.Logger with information form context. If there is an opentracing span in the context, the span will receive the logger output as well.

(logger log.Logger, ctx context.Context)

Source from the content-addressed store, hash-verified

119// WithContext decorates the log.Logger with information form context. If there is an opentracing span
120// in the context, the span will receive the logger output as well.
121func WithContext(logger log.Logger, ctx context.Context) log.Logger {
122 span := opentracing.SpanFromContext(ctx)
123 if span == nil {
124 return WithBaggage(logger, ctx)
125 }
126 return WithBaggage(spanLogger{span: span, base: logger}, ctx)
127}
128
129// WithBaggage decorates the log.Logger with information form context.
130func WithBaggage(logger log.Logger, ctx context.Context) log.Logger {

Callers 4

ExampleWithContextFunction · 0.92
WithLoggingFunction · 0.92
RecoverFunction · 0.92
TestWithContextFunction · 0.85

Calls 1

WithBaggageFunction · 0.85

Tested by 2

ExampleWithContextFunction · 0.74
TestWithContextFunction · 0.68