WithContext returns a copy of ctx with the receiver attached. The Logger attached to the provided Context (if any) will not be effected. If the receiver's log level is Disabled it will only be attached to the returned Context if the provided Context has a previously attached Logger. If the provided
(ctx context.Context)
| 31 | // return c.Str("bar", "baz") |
| 32 | // }) |
| 33 | func (l Logger) WithContext(ctx context.Context) context.Context { |
| 34 | if _, ok := ctx.Value(ctxKey{}).(*Logger); !ok && l.level == Disabled { |
| 35 | // Do not store disabled logger. |
| 36 | return ctx |
| 37 | } |
| 38 | return context.WithValue(ctx, ctxKey{}, &l) |
| 39 | } |
| 40 | |
| 41 | // Ctx returns the Logger associated with the ctx. If no logger |
| 42 | // is associated, DefaultContextLogger is returned, unless DefaultContextLogger |
no outgoing calls