There is a very confusing problem for me when using zerolog:
log.Ctx(ctx) doesn't insert the provided context in the Event, resulting in logs without telemetry data
The solution is quite ugly:
import "github.com/rs/zerolog/log"
...
log.
Ctx(ctx). // Retrieves the logger from context, without setting the context for Event.
Info(). // Creates an event
Ctx(ctx). // Sets the ctx for the Event so we can retrieve telemetry data.
...
I think it would be highly convenient that we do not have to set the event context if the log is already created from a context.
Am I doing something wrong here?
There is a very confusing problem for me when using zerolog:
log.Ctx(ctx)doesn't insert the provided context in the Event, resulting in logs without telemetry dataThe solution is quite ugly:
I think it would be highly convenient that we do not have to set the event context if the log is already created from a context.
Am I doing something wrong here?