-
Notifications
You must be signed in to change notification settings - Fork 120
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
Failure when logging non-string objects #23
Comments
This certainly sounds like reasonable behavior. I checked the default stdlib logger, and it does accept any object and formats it as a string. I checked the source code for the default formatter, and found that it calls a private method #msg2str. This method does special formatting on exceptions, and defaults to calling I'll push a fix to call |
Released 0.7.0 to Rubygems. |
Still crashes when it receives an int for example (which can be quite useful for taking averages in kibana) |
@rogierslag I cannot reproduce this. Are you using LogStashLogger >= 0.7? logger = LogStashLogger.new(type: :stdout)
logger.info(1)
{"message":"1","@timestamp":"2015-04-22T07:48:51.934-07:00","@version":"1","severity":"INFO","host":"Davids-MacBook-Pro-2.local"} |
When passing an object to any log method that is not a String, a Hash or a Logstash object, the logger errors with
The culprit is https://github.com/dwbutler/logstash-logger/blob/master/lib/logstash-logger/formatter.rb#L24 where a default case for anything that is not a String, but can be converted is missing. It would be more robust to test if
data.responds_to :to_s
, so that exception objects or similar can be passed directly.The text was updated successfully, but these errors were encountered: