Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext retrieves a previously set logger on the supplied context. If the logger does not exist, an error is returned.
func SetOnContext ¶
SetOnContext retrieves an existing request id from the context, and sets it on the context of a child logger created from the provided parent Logger. The request id is retrieved via the functions provided by the gokit/requestid package.
If the request id is not found, an error message is logged to the parent logger, a new child context logger with the a RequestID of "NOT_FOUND" is set on the context, and the new context and logger is returned.
To retrieve the logger from the new context, use FromContext()
func UpdateLogger ¶
func UpdateLogger(ctx context.Context, updateFunc func(logger zerolog.Context) zerolog.Context) (context.Context, error)
UpdateLogger will run the provided updateFunc on the zerolog.Logger within the context assuming it exists. It will return a new context with the updated logger. This is useful for modifying the loggers zerolog.Context without setting requestID on the logger multiple times. Similar to zerolog.Logger.UpdateContext().
If the logger isn't found this returns the passed in context along with an error.
To retrieve the updated logger from the new context, use FromContext()
Types ¶
This section is empty.