feat: make logging non-blocking

This commit is contained in:
2026-05-06 21:52:34 -04:00
parent 2dbc0a2e87
commit 9441204f9f
3 changed files with 24 additions and 0 deletions

20
Cargo.lock generated
View File

@@ -1769,6 +1769,7 @@ dependencies = [
"tokio-websockets 0.11.4",
"tokio-websockets 0.13.2",
"tracing",
"tracing-appender",
"tracing-subscriber",
"twilight-gateway",
"twilight-http",
@@ -6613,6 +6614,12 @@ dependencies = [
"thiserror 2.0.17",
]
[[package]]
name = "symlink"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a"
[[package]]
name = "symphonia"
version = "0.5.5"
@@ -7147,6 +7154,19 @@ dependencies = [
"tracing-core",
]
[[package]]
name = "tracing-appender"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c"
dependencies = [
"crossbeam-channel",
"symlink",
"thiserror 2.0.17",
"time",
"tracing-subscriber",
]
[[package]]
name = "tracing-attributes"
version = "0.1.31"

View File

@@ -95,6 +95,7 @@ twilight-model = "0.17"
twilight-util = { version = "0.17", features = ["builder"] }
typed-builder = "0.23.2"
yoke = "0.8.2"
tracing-appender = "0.2.5"
[build-dependencies]
capnpc = "0.25.3"

View File

@@ -173,10 +173,13 @@ async fn main() -> Result<(), MainError> {
let LoggingArgs { env_filter } = logging_args;
let (non_blocking_writer, _guard) = tracing_appender::non_blocking(std::io::stdout());
tracing_subscriber::fmt()
.pretty()
.with_env_filter(env_filter)
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
.with_writer(non_blocking_writer)
.init();
tracing::debug!(?app_args, "using");