Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/logger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ dioxus-cli-config = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["registry", "std"] }

[features]
default = []
env-filter = ["tracing-subscriber/env-filter"]

[target.'cfg(target_arch = "wasm32")'.dependencies]
tracing-wasm = { workspace = true }
console_error_panic_hook = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions packages/logger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ fn App() -> Element {
p { "hi" }
}
}


```
For non-wasm targets, the `env-filter` feature enables runtime filtering based on the `RUST_LOG` environment variable. e.g. `RUST_LOG=none,myAppName=trace`, see [here](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives) for syntax.

## Platform Support
Dioxus logger will eventually support every target that Dioxus does. Currently mobile and TUI are not supported.
Expand Down
2 changes: 2 additions & 0 deletions packages/logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ pub fn init(level: Level) -> Result<(), SetGlobalDefaultError> {
#[cfg(not(target_arch = "wasm32"))]
{
let sub = tracing_subscriber::FmtSubscriber::builder().with_max_level(level);
#[cfg(feature = "env-filter")]
let sub = sub.with_env_filter(tracing_subscriber::EnvFilter::from_default_env());

if !dioxus_cli_config::is_cli_enabled() {
return set_global_default(sub.finish());
Expand Down