feat: add feature flag to enable ansi colors and RUST_LOG filtering for terminal output
While the crate description states that this crate is not intended for debugging tests but on testing the logging (which is great), we frequently still need to debug tests. We recently moved from a home-baked solution to this crate and really like the ability to assert log lines. At the same time, we quite miss the colored output and a way to set a custom filter directive when debugging tests.
This PR adds two feature flags. Without the feature flags, the behavior is fully unchanged.
no-log-printing: Disable log printing fully. Fixes #38pretty-log-printing: Uses a different fmt layer for outputting the logs to the terminal, while keeping the layer used for assertions as it is now. The new layer for outputting allows to set a filter viaRUST_LOG(while defaulting to the current filter of "trace for main crate"), and enables ansi colors unlessNO_COLOR=1is present.
The layer that is used for the assertions is kept unchanged in any case (no ansi, no way to change the filter apart from the no-env-filter feature flag).
Friendly ping @dbrgn - did you have a chance to look at this?
This is a great approach! I had a similar idea for log filtering in https://github.com/paritytech/polkadot-sdk/blob/master/substrate/primitives/tracing/src/lib.rs#L270
Any news on this one? @dbrgn