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

feat: add feature flag to enable ansi colors and RUST_LOG filtering for terminal output #51

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Frando
Copy link

@Frando Frando commented Feb 5, 2025

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!? #38
  • pretty-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 via RUST_LOG (while defaulting to the current filter of "trace for main crate"), and enables ansi colors unless NO_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).

@Frando Frando force-pushed the feat/color-and-filter-on-cli branch from 2060540 to c1f19d7 Compare February 5, 2025 11:17
@Frando Frando changed the title feat: enable ansi colors and RUST_LOG filtering on stderr output feat: add feature flag to enable ansi colors and RUST_LOG filtering on stderr output Feb 5, 2025
@Frando Frando changed the title feat: add feature flag to enable ansi colors and RUST_LOG filtering on stderr output feat: add feature flag to enable ansi colors and RUST_LOG filtering for terminal output Feb 5, 2025
@Frando
Copy link
Author

Frando commented Feb 20, 2025

Friendly ping @dbrgn - did you have a chance to look at this?

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

Successfully merging this pull request may close these issues.

Removing the print!?
1 participant