feat: add feature flag to enable ansi colors and RUST_LOG filtering for terminal output #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 Removing the print!? #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=1
is 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).