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

Add env-filter-explorer example #3233

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

joshka
Copy link
Contributor

@joshka joshka commented Mar 12, 2025

Motivation

On discord, Conrad suggested a website to experiment with env-filter syntax. I think a TUI in tree makes a pretty decent replacement, especially as the output can exactly match the output that a real user might see if they're configuring tracing_subscriber with the default values.

Solution

This example demonstrates how to use the tracing-subscriber crate's
EnvFilter type to filter log messages based on their metadata. The
example provides a text area where users can input an environment filter
string, and displays the log messages that would be captured by that
filter.

There are preset filters that can be selected that show off the syntax.

image

joshka added 2 commits March 12, 2025 12:16
The transitive dependency on itoa 0.4 does not compiles with stable
rust. Bump inferno to 0.12.1 to fix this.

```
❯ cargo check --examples
    Checking serde v1.0.157
    Checking tokio v1.43.0
    Checking itoa v0.4.0
    Checking tracing-macros v0.1.0 (/Users/joshka/local/tracing/tracing-macros)
error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /Users/joshka/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/itoa-0.4.0/src/lib.rs:13:31
   |
13 | #![cfg_attr(feature = "i128", feature(i128_type, i128))]
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: the feature `i128_type` has been stable since `1.26.0` and no longer requires an attribute to enable

```

```
❯ cargo tree -i itoa@0.4.0
itoa v0.4.0
└── num-format v0.4.0
    └── inferno v0.11.6
        [dev-dependencies]
        └── tracing-examples v0.0.0 (/Users/joshka/local/tracing/examples)
```
This example demonstrates how to use the `tracing-subscriber` crate's
`EnvFilter` type to filter log messages based on their metadata. The
example provides a text area where users can input an environment filter
string, and displays the log messages that would be captured by that
filter.
@joshka joshka requested review from hawkw, davidbarsky and a team as code owners March 12, 2025 20:59
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.

2 participants