Skip to content
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

Automatic error logging #2664

Open
decoursin opened this issue Apr 30, 2024 · 5 comments
Open

Automatic error logging #2664

decoursin opened this issue Apr 30, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@decoursin
Copy link

decoursin commented Apr 30, 2024

What is the problem this feature would solve?

More convenient logging for errors.

What is the feature you are proposing to solve the problem?

ZIO has the below logError function, which will automatically log if the this ZIO element is an error.

  /**
   * Logs the cause of failure of this workflow.
   */
  final def logError(implicit trace: Trace): ZIO[R, E, A] =
    logError("")

Effect also has a logError function which works completely differently. That's fine, but it would also be nice to have a function like the one above which will just automatically log any error for me.

What alternatives have you considered?

      .pipe(Effect.tapError(e => Effect.logError(`name='${e.name}' message='${e.message}'`)))

No response

@decoursin decoursin added the enhancement New feature or request label Apr 30, 2024
@jessekelly881
Copy link
Contributor

I think Loggers should probably just be extended to have better support for Error types so that.pipe(Effect.tapError(Effect.logError)) is sufficient.

@decoursin
Copy link
Author

I would think it not to be best to have the logError function have two purposes. Right now logError means logging at the error level. Or otherwise that should then be done for all of the logging functions like logDebug, logInfo, etc or for none of them. I don't think logError should be special.

@jessekelly881
Copy link
Contributor

jessekelly881 commented Apr 30, 2024

That's what I mean, yeah. I think all loggers, logDebug, etc. should have better support for logging an instance of an Error type if that's what's provided to it. #2667

@decoursin
Copy link
Author

Ah, ok! I think that could be cool, yeah!

@datner
Copy link
Contributor

datner commented May 2, 2024

They already have good support for Cause

effect.pipe(Effect.tapErrorCause(Effect.logError))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants