You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Encode log attributes with values of type any as pretty-formatted JSON
This makes devlog's attribute encoding more consistent with the JSON log handler that you'll typically use for production, to avoid discrepancies between local and production log output
devlog/log:
Add log.AddContextAttrs function for attaching log attributes to a context.Context
Breaking: Add context.Context parameter to all logging functions, to ensure that attributes from AddContextAttrs are propagated
To migrate, replace:
log.Info("Message", ...attributes)
...with:
log.Info(ctx, "Message", ...attributes)
If you're in a function without a context parameter, you may pass a nil context:
log.Info(nil, "Message", ...attributes)
Breaking: Remove log.Error, log.WarnError and log.DebugError functions that don't take a log message, and replace them with the error-logging functions that previously had a Cause suffix
Renamed functions:
log.ErrorCause -> log.Error
log.ErrorCausef -> log.Errorf
log.WarnErrorCause -> log.WarnError
log.WarnErrorCausef -> log.WarnErrorf
log.DebugErrorCause -> log.DebugError
log.DebugErrorCausef -> log.DebugErrorf
To migrate uses of Error, WarnError and DebugError without a log message, you can add a blank log message, which behaves the same (error string is used as the message). Replace: