-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support for slf4j's Throwable param? #4
Comments
Would be nice, lets see how we could twist the ruby standard logger API to make this work. Basically I think implementations should behave like: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html#method-i-add In some implementations (e.g. Rails' BufferedLogger) though progname is ignored, in the slf4j logger it uses the progname as marker if given. Maybe we can enhance the slf4j logger to accept a hash of options as progname logger.error("some failure bla bla: #{err}", exception: err, marker: "FOO") Problem is change is basically incompatible with the MRI Logger, question how bad is that - considering it's only used in jruby/slf4j projects. An alternative would be to provide a new method like: def raised(exception, msg = nil, level = :error)
msg = yield if block_given?
msg ||= "#{msg.class}: #{msg}"
java_logger.send(level, java_marker, msg, exception) # <- maybe need to cast the exception to Throwable...
end What do you think? Personally, I'm in favor of a new method, then it's clear it's a new different, non-standard behavior. |
Another issue is that Ruby Exception != Java Throwable, when looking at the ancestors of a Ruby
while a java.lang.RuntimeException looks like:
Sadly I did not find any useful method to convert a ruby exception to a java.lang.Throwable... |
e.g. http://www.slf4j.org/apidocs/org/slf4j/Logger.html#debug(java.lang.String, java.lang.Throwable)
Would it be possible to add support for passing a caught Exception into the log method, for the stacktrace to be logged through slf4j's mechanism?
The text was updated successfully, but these errors were encountered: