Make journald an optional feature.

This commit is contained in:
Jani Monoses 2021-09-07 20:56:37 +03:00
parent d5b0d76435
commit 39e39cd277
2 changed files with 9 additions and 7 deletions

View File

@ -15,6 +15,7 @@ default = [ "tokio" ]
async-std = [ "tor-client/async-std", "tor-rtcompat/async-std", "async-ctrlc", "once_cell" ]
tokio = [ "tokio-crate", "tor-client/tokio", "tor-rtcompat/tokio" ]
static = [ "tor-rtcompat/static", "tor-dirmgr/static" ]
journald = [ "tracing-journald" ]
[dependencies]
tor-client = { package="arti-tor-client", path = "../tor-client", version="0.0.0" }
@ -34,4 +35,4 @@ serde = { version = "1.0.124", features = ["derive"] }
tracing-subscriber = "0.2.19"
tokio-crate = { package="tokio", version = "1.7.0", optional = true, features = ["signal"] }
argh = "0.1.4"
tracing-journald = "0.1.0"
tracing-journald = { version = "0.1.0", optional = true }

View File

@ -237,14 +237,15 @@ fn setup_logging(config: &ArtiConfig) {
let registry = registry().with(fmt::Layer::default()).with(env_filter);
#[cfg(feature = "journald")]
if config.journald {
match tracing_journald::layer() {
Ok(journald) => registry.with(journald).init(),
Err(_err) => registry.init(),
};
} else {
registry.init()
if let Ok(journald) = tracing_journald::layer() {
registry.with(journald).init();
return;
}
}
registry.init();
}
fn main() -> Result<()> {