Skip to content

Commit 2326db8

Browse files
committed
wip: pretty and compact loggers
1 parent f42180f commit 2326db8

File tree

12 files changed

+755
-435
lines changed

12 files changed

+755
-435
lines changed

core/lib/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ rust-version = "1.75"
2020
all-features = true
2121

2222
[lints.rust]
23+
unexpected_cfgs = "allow"
2324
rust_2018_idioms = "warn"
2425
# missing_docs = "warn"
2526
async_fn_in_trait = "allow"
@@ -42,7 +43,7 @@ uuid = ["uuid_", "rocket_http/uuid"]
4243
tls = ["rustls", "tokio-rustls", "rustls-pemfile"]
4344
mtls = ["tls", "x509-parser"]
4445
tokio-macros = ["tokio/macros"]
45-
trace = ["tracing-subscriber", "tinyvec", "rustls?/logging", "tokio-rustls?/logging", "multer/log"]
46+
trace = ["tracing-subscriber", "tinyvec", "thread_local", "rustls?/logging", "tokio-rustls?/logging", "multer/log"]
4647

4748
[dependencies]
4849
# Optional serialization dependencies.
@@ -87,6 +88,7 @@ state = "0.6"
8788
# tracing
8889
tracing = { version = "0.1.40", default-features = false, features = ["std", "attributes"] }
8990
tinyvec = { version = "1.6", optional = true, features = ["std", "rustc_1_57"] }
91+
thread_local = { version = "1.1", optional = true }
9092

9193
[dependencies.tracing-subscriber]
9294
version = "0.3.18"

core/lib/src/trace/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
use rocket::Config;
2-
31
#[macro_use]
42
pub mod macros;
53
#[cfg(feature = "trace")]
64
pub mod subscriber;
75
pub mod level;
86
pub mod traceable;
97

10-
pub fn init<'a, T: Into<Option<&'a Config>>>(_config: T) {
11-
#[cfg(feature = "trace")]
12-
subscriber::init(_config.into());
8+
pub fn init<'a, T: Into<Option<&'a crate::Config>>>(_config: T) {
9+
#[cfg(all(feature = "trace", debug_assertions))]
10+
subscriber::RocketFmt::<subscriber::Pretty>::init(_config.into());
11+
12+
#[cfg(all(feature = "trace", not(debug_assertions)))]
13+
subscriber::RocketFmt::<subscriber::Compact>::init(_config.into());
1314
}

0 commit comments

Comments
 (0)