socketry / async

An awesome asynchronous event-driven reactor for Ruby.
MIT License
2.09k stars 86 forks source link

Allow to customise the kind of logging/reporting when an exception is thrown in a task #171

Closed Maaarcocr closed 2 years ago

Maaarcocr commented 2 years ago

Currently we log when an error is thrown in a task https://github.com/socketry/async/blob/809025c576a14317e40dd9e7e9584aabe2feb01c/lib/async/task.rb#L236 but there is no way to allow people to customise the kind of reporting that they want to do whenever an error is thrown.

For example, in my use case I'd like to use report these errors to something like Sentry and log them with a custom logger we have internally.

We could default to the current behaviour but also allow to pass a custom reporter somehow.

ioquatix commented 2 years ago

You can configure the console with a different output, this is unrelated to async.

ioquatix commented 2 years ago

See https://github.com/socketry/console-output-datadog/blob/main/lib/console/output/datadog/wrapper.rb for an example of how to amend logs. The output can either be a wrapper or a final destination, but for that I'd suggest you use the structured JSON formatter which is enabled automatically if the output is not a TTY.