log: avoid double span wrapping
Avoid wrapping a span logger inside of another span logger.
When calling `log.FromCtx`, the logger inside the context is wrapped
with a span logger. If the logger is already a span logger, it is not
wrapped.
@@ -42,6 +42,9 @@ func FromCtx(ctx context.Context) Logger {
return Root()
}
if logger := ctx.Value(loggerKey); logger != nil {
+ if _, ok := logger.(Span); ok {
+ return logger.(Logger)
+ }
return attachSpan(ctx, logger.(Logger))
}
// Logger not found in ctx, make sure we never return a nil root
