-
Notifications
You must be signed in to change notification settings - Fork 3.4k
logging: consistent error attribute when emitted through logr #35397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dacce32
to
729e52e
Compare
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Only two questions regarding the naming of the "replace"-functions. Maybe it's worth to adjust them to something more generic? (replaceFuncWithoutTimestamp
& replaceFunc
?)
Slightly generalize the log attributes mangling logic in preparation for the subsequent extension, changing the function names to be agnostic of the specific operations and making one rely on the other, to ensure consistency and reduce code duplication. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Extend the log attributes mangling logic to ensure consistency in the attribute key used to identify an error. Indeed, the logr.Error method takes an error as first parameter, and the slog adapter converts it into an attribute identified as `err`. Let's replace that into `error` to ensure consistency with all the other occurrences. Related: d91e387 ("cec: Switch to slog for CEC") Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
729e52e
to
4125b1c
Compare
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Extend the log attributes mangling logic to ensure consistency in the attribute key used to identify an error. Indeed, the
logr.Error
method takes an error as first parameter, and the slog adapter converts it into an attribute identified aserr
. Let's replace that intoerror
to ensure consistency with all the other occurrences.