Skip to content

Commit

Permalink
feat(logging): Add EnvFilter for dynamic log level control
Browse files Browse the repository at this point in the history
Add `EnvFilter` to the logging setup to allow runtime configuration of log levels via environment variables.
  • Loading branch information
andrewgazelka committed Nov 17, 2024
1 parent a5e2ae1 commit f1fb7ac
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions events/proof-of-concept/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use proof_of_concept::init_game;
use tracing_subscriber::{Registry, layer::SubscriberExt};
use tracing_subscriber::{Registry, layer::SubscriberExt, EnvFilter};
use tracing_tracy::TracyLayer;

#[cfg(not(target_env = "msvc"))]
Expand All @@ -20,13 +20,16 @@ struct Args {

fn setup_logging() {
tracing::subscriber::set_global_default(
Registry::default().with(TracyLayer::default()).with(
tracing_subscriber::fmt::layer()
.with_target(false)
.with_thread_ids(false)
.with_file(true)
.with_line_number(true),
),
Registry::default()
.with(EnvFilter::from_default_env())
.with(TracyLayer::default())
.with(
tracing_subscriber::fmt::layer()
.with_target(false)
.with_thread_ids(false)
.with_file(true)
.with_line_number(true),
),
)
.expect("setup tracing subscribers");
}
Expand All @@ -36,13 +39,9 @@ fn main() {

setup_logging();

// console_subscriber::init();

let Args { ip, port } = Args::parse();

let address = format!("{ip}:{port}");

// Denormals (numbers very close to 0) are flushed to zero because doing computations on them
// is slow.
init_game(address).unwrap();
}

0 comments on commit f1fb7ac

Please sign in to comment.