-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Two questions: Swallowing exceptions? Accepting nullable Throwables? #38
Comments
Regarding the first issue see the discussion here: #22 Regarding the second issue, a pull request is welcome! |
Thanks for the response! I understand this is a question of preference (or context), some people prefer to be fail-safe, while I'd rather fail-fast. The behavior is also different from Slf4j, compare:
with
The former throws the exception, the latter doesn't. So I think this should at least be mentioned somewhere in the readme or documentation, otherwise it could lead to some real head scratchers. I created a pull request for the nullable throwables. |
usually, I also prefer fail-fast than fail-safe. However, I think in this case it is better to be consistent with other logging frameworks. the exception you described above in |
version 1.5.4 was released with nullable throwables (#39) |
Ah, yes, you're right, the logging framework doesn't even even see the exception in the first example. Thank you for the quick release! |
Hello,
Thank you for this library! I love how it provides true lazy-evaluation. Prettier and, afaict, even faster than the idiomatic way of Slf4j
log.info("foo: {}", bar)
.However, I noticed the
toStringSafe
method inMessageInvoker.kt
:This means that exceptions from a logging lambda will be caught and swallowed. Just the exception message will be logged, on the same log level as the base statement. E.g.
prints, on level INFO
I'm wondering if this is desirable? It should be rare to actually get any exception from a log statement, but when it happens, I would rather see the exception fall through so that it can be handled by whatever root exception handling is in place. In our current project, we would log on level ERROR and send a mail, to make sure that no exception goes unnoticed.
What do you think? Is there a way to skip or replace the
toStringSafe
?--
Another thing, not very important at all, but is there a reason that the methods of
Klogger.kt
don't accept nullable Throwables?I would like to do, for example, the following, in an exception handler implementation
That's not possible though, since
ex
is nullable, andKLogger.error
expects anThrowable
. The underlying Slf4j logger would accept null and simply handle it as if no exception was passed to it. so I don't see a reason whyKlogger
could not accept aThrowable?
as well.The text was updated successfully, but these errors were encountered: