Skip to content

Commit

Permalink
feat(log): capture logs from the log crate to tracing subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Oct 18, 2023
1 parent 8592d35 commit 6b4a74c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/rundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ tokio-rustls = "0.24.1"
tokio-util = "0.7.8"
tracing.workspace = true
tracing-appender = "0.2.2"
tracing-log = "0.1.3"
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "fmt", "json"] }
4 changes: 4 additions & 0 deletions bin/rundler/src/cli/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::io;
pub use tracing::*;
use tracing::{subscriber, subscriber::Interest, Metadata, Subscriber};
use tracing_appender::non_blocking::WorkerGuard;
use tracing_log::LogTracer;
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, FmtSubscriber, Layer};

use super::LogsArgs;
Expand Down Expand Up @@ -46,6 +47,9 @@ pub fn configure_logging(config: &LogsArgs) -> anyhow::Result<WorkerGuard> {
)?;
}

// Redirect logs from external crates using `log` to the tracing subscriber
LogTracer::init()?;

Ok(guard)
}

Expand Down

0 comments on commit 6b4a74c

Please sign in to comment.