-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Logger dumps error with classname #899
Conversation
0d02974
to
a720cde
Compare
@repeatedly @sonots How do you think about this change? |
I am positive for specifying only an error object, but somebody might be watching logs of fluentd by a log monitoring system for alerting. Changing log format would break compatibilities for their system, so I think we should keep compatibilities of log format. |
@sonots Do you mean that we should print errors in format below?
|
@tagomoris yes! |
@sonots Hmm, it looks a bit verbose for me, and v0.14 may be a good time to do that kind of change. |
Keeping compatibility is good for existing users. Maybe, asking it on mailing list is better.
This change affects v0.12 because we will backport several changes to v0.12 and skipping this patch is hard... |
Okay, I'll change format of errors. |
Done. |
@@ -292,7 +292,11 @@ def event(level, args) | |||
} | |||
|
|||
map.each_pair {|k,v| | |||
message << " #{k}=#{v.inspect}" | |||
if k == "error".freeze | |||
message << " error_class=#{v.class.to_s} error=#{v.to_s.inspect}" |
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.
v
would be a string like
Line 127 in 88054a0
$log.error "error on output thread", error: $!.to_s |
and v.is_a?(Exception)
.
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.
Need to add another condition !map.has_key?('error_class')
, otherwirse, error_class=
appears twice for old codes such as:
log.error 'message', error_class: e.class, error: e
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.
That's right. I fixed so.
LGTM! |
Merged. |
In these days, many plugin authors (and core developers) writes logging code like below many times.
Fairly speaking, this is waste of time and key typing.
Fluentd will log errors like below with this change by just specifying
error: e
: