Skip to content

Commit

Permalink
wip: pretty and compact loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed May 14, 2024
1 parent f42180f commit 2326db8
Show file tree
Hide file tree
Showing 12 changed files with 755 additions and 435 deletions.
4 changes: 3 additions & 1 deletion core/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rust-version = "1.75"
all-features = true

[lints.rust]
unexpected_cfgs = "allow"
rust_2018_idioms = "warn"
# missing_docs = "warn"
async_fn_in_trait = "allow"
Expand All @@ -42,7 +43,7 @@ uuid = ["uuid_", "rocket_http/uuid"]
tls = ["rustls", "tokio-rustls", "rustls-pemfile"]
mtls = ["tls", "x509-parser"]
tokio-macros = ["tokio/macros"]
trace = ["tracing-subscriber", "tinyvec", "rustls?/logging", "tokio-rustls?/logging", "multer/log"]
trace = ["tracing-subscriber", "tinyvec", "thread_local", "rustls?/logging", "tokio-rustls?/logging", "multer/log"]

[dependencies]
# Optional serialization dependencies.
Expand Down Expand Up @@ -87,6 +88,7 @@ state = "0.6"
# tracing
tracing = { version = "0.1.40", default-features = false, features = ["std", "attributes"] }
tinyvec = { version = "1.6", optional = true, features = ["std", "rustc_1_57"] }
thread_local = { version = "1.1", optional = true }

[dependencies.tracing-subscriber]
version = "0.3.18"
Expand Down
11 changes: 6 additions & 5 deletions core/lib/src/trace/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use rocket::Config;

#[macro_use]
pub mod macros;
#[cfg(feature = "trace")]
pub mod subscriber;
pub mod level;
pub mod traceable;

pub fn init<'a, T: Into<Option<&'a Config>>>(_config: T) {
#[cfg(feature = "trace")]
subscriber::init(_config.into());
pub fn init<'a, T: Into<Option<&'a crate::Config>>>(_config: T) {
#[cfg(all(feature = "trace", debug_assertions))]
subscriber::RocketFmt::<subscriber::Pretty>::init(_config.into());

#[cfg(all(feature = "trace", not(debug_assertions)))]
subscriber::RocketFmt::<subscriber::Compact>::init(_config.into());
}
Loading

0 comments on commit 2326db8

Please sign in to comment.