-
Notifications
You must be signed in to change notification settings - Fork 63
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
add: log all errors wrapper for Logger component #143
base: main
Are you sure you want to change the base?
Conversation
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 with a few comments
internal/log/strict.go
Outdated
continue | ||
} | ||
|
||
switch arg.(type) { |
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.
I think you probably want something like this:
_, isErr := arg.(error)
instead to see if it implements the error interface, not if its literally an error no?
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.
Wont the switch case also check if the value arg
implements the error
interface?
Or are you suggesting we remove the check for *error
as well since that's technically not an error
type.
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.
I guess if your tests pass its fine
internal/log/config.go
Outdated
@@ -14,13 +14,15 @@ const ( | |||
fieldFilePath = "path" | |||
fieldFileRotate = "rotate" | |||
fieldFileRotateMaxAge = "rotate_max_age_days" | |||
fieldStrictLogging = "strict" |
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.
log_all_errors
IMO instead of "strict" since thats way more clear
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.
Update all the variables / go code to match the name as well
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.
Done!
I acknowledge the request for review - will give it a good look soon 👍 |
Adds an optional wrapped logger that will promote any log with an
error
type to theERROR
level.This does not include ading an error in a logger's
With
orWithField
.For example, if you set:
Then any subsequent
logger
callingWarn
,Info
,Debug
,Trace
, or with anerror
type in the params will promote the log to anError
type.In addition, a field
@log_all_errors=true
is added to all logs generated from the strict logger: