-
Notifications
You must be signed in to change notification settings - Fork 1.4k
adds support for logging failures with traces #9738
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
base: series/2.x
Are you sure you want to change the base?
Conversation
* Logs the specified failure at the current log level. | ||
*/ | ||
def logFailure(e: => Any)(implicit trace: Trace): UIO[Unit] = | ||
ZIO.logCause(Cause.fail(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.
I am fine with this change overall, but I wonder if users would expect this to capture a trace given it's not an explicit parameter. @kyri-petrou what do you think?
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 want to have trace with default Empty
, however scala only allow one overload with default params. So I had to split it into two overloads, one with error only and one with error and trace.
In total there are 3 overloads, one with error only, one with error and trace and one with message, error and trace with default parameter.
I'm fine with removing the first one with error only if it make it clearer.
@kyri-petrou can you please take a look? |
An alternative to #9488, fixes #9485.
ZIO 2.0 removed
zio-logging
'slogThrowable
; in ZIO 2.0, onlyCause
s can be logged. This PR restores the ability to log failures that are not wrapped in causes.catchAllCause
does not give access to the original error, and it is also dangerous because it catches defects as well.Now users can use
catchAll
orcatchAllTrace
to log the error safely:tapError
andtapErrorTrace
can also be used:cc @quelgar