rucksack/src/logging.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
752 B
Rust
Raw Normal View History

2022-08-15 01:20:45 +05:30
use tracing::dispatcher::SetGlobalDefaultError;
use tracing::subscriber::set_global_default;
#[cfg(not(feature = "journald"))]
fn configure_tracing() -> Result<(), SetGlobalDefaultError> {
use tracing_subscriber::{fmt::layer, layer::SubscriberExt, registry};
let stdout_log = layer().pretty();
let subscriber = registry().with(stdout_log);
set_global_default(subscriber)
}
#[cfg(feature = "journald")]
fn configure_tracing() -> Result<(), SetGlobalDefaultError> {
use tracing_journald::layer;
2022-08-15 01:20:45 +05:30
use tracing_subscriber::{layer::SubscriberExt, registry};
let subscriber = registry().with(layer().unwrap());
2022-08-15 01:20:45 +05:30
set_global_default(subscriber)
}
pub fn init() -> Result<(), SetGlobalDefaultError> {
configure_tracing()
}