iqlusioninc / abscissa

Application microframework with command-line option parsing, configuration, error handling, logging, and shell interactions
Apache License 2.0
570 stars 39 forks source link

Parametrize tracing formatter #434

Open adizere opened 3 years ago

adizere commented 3 years ago

Summary

For our use-case in the relayer-cli crate (https://github.com/informalsystems/ibc-rs/issues/500) we would like to enable JSON-formatted tracing output. At first glance, it's not clear if abscissa permits this kind of configuration. Thanks in advance for any advice!

Description

Abscissa core is setting the global subscriber for tracing as follows:

https://github.com/iqlusioninc/abscissa/blob/cbecf5f471c19972723c74924a14df70fffed289/core/src/trace/component.rs#L40

If I understand correctly, all applications built on abscissa are forced to use this subscriber. It would be great to allow more flexibility here. Note that documentation in tracing seems to provide guidance specifically against libraries using set_global_default.

tony-iqlusion commented 3 years ago

Yes, this would definitely be good.

For reference, how zebrad is managing its tracing config:

https://github.com/ZcashFoundation/zebra/blob/main/zebrad/src/application.rs#L220-L238

adizere commented 3 years ago

Thanks!

Just to note that this issue it not a priority.

We decided to use a custom solution instead of globally enabling JSON output. In the future, we may switch to a more principled approach, similar to the suggested zebrad solution to make all tracing output in JSON (minimal working example here).