Skip to content

Commit

Permalink
Add tokio-console feature to main odilia binary
Browse files Browse the repository at this point in the history
  • Loading branch information
TTWNO committed Jun 17, 2024
1 parent 581a3f0 commit beb33e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion odilia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ futures-lite = "2.3.0"
pin-project = "1.1.5"
static_assertions = "1.1.0"
futures-concurrency = "7.6.1"
console-subscriber = "0.3.0"
console-subscriber = { version = "0.3.0", optional = true }

[dev-dependencies]
lazy_static = "1.4.0"
tokio-test = "0.4.2"

[features]
tokio-console = ["dep:console-subscriber"]
15 changes: 10 additions & 5 deletions odilia/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ pub fn init(config: &ApplicationConfig) -> eyre::Result<()> {
.with_syslog_identifier("odilia".to_owned())
.boxed(),
};
let console_env = EnvFilter::from("tokio=trace,runtime=trace");
let console_layer = console_subscriber::spawn();
tracing_subscriber::Registry::default()
.with(console_env)
.with(console_layer)
#[cfg(feature = "tokio-console")]
let trace_sub = {
let console_layer = console_subscriber::spawn();
tracing_subscriber::Registry::default()
.with(EnvFilter::from("tokio=trace,runtime=trace"))
.with(console_layer)
};
#[cfg(not(feature = "tokio-console"))]
let trace_sub = { tracing_subscriber::Registry::default() };
trace_sub
.with(env_filter)
.with(ErrorLayer::default())
.with(final_layer)
Expand Down
2 changes: 1 addition & 1 deletion scripts/tokio_console_run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
RUSTFLAGS="--cfg tokio_unstable" RUST_LOG="trace" cargo run
RUSTFLAGS="--cfg tokio_unstable" RUST_LOG="trace" cargo run --features tokio-console

0 comments on commit beb33e6

Please sign in to comment.