diff options
author | Matthias Beyer <matthias.beyer@ifm.com> | 2022-08-04 20:26:02 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-08-30 13:54:49 +0200 |
commit | 6aa6e2e88b6e1eb0836f212e42003f4c67d30402 (patch) | |
tree | 40f16836431332570689161bb22ab9370f9a2529 | |
parent | 08a32f3294d65b4011e54838fc67c792cf8f3ff0 (diff) |
Add journald backend for tracingpost-merge/tracing-journald
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r-- | Cargo.lock | 12 | ||||
-rw-r--r-- | tedge/Cargo.toml | 1 | ||||
-rw-r--r-- | tedge/src/cli.rs | 6 | ||||
-rw-r--r-- | tedge/src/logging.rs | 7 | ||||
-rw-r--r-- | tedge/src/main.rs | 1 |
5 files changed, 27 insertions, 0 deletions
@@ -3563,6 +3563,7 @@ dependencies = [ "toml", "tracing", "tracing-chrome", + "tracing-journald", "tracing-subscriber", "tracing-tracy", ] @@ -4210,6 +4211,17 @@ dependencies = [ ] [[package]] +name = "tracing-journald" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba316a74e8fc3c3896a850dba2375928a9fa171b085ecddfc7c054d39970f3fd" +dependencies = [ + "libc", + "tracing-core", + "tracing-subscriber", +] + +[[package]] name = "tracing-log" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/tedge/Cargo.toml b/tedge/Cargo.toml index 9e81f7cd..15f9c6b6 100644 --- a/tedge/Cargo.toml +++ b/tedge/Cargo.toml @@ -22,6 +22,7 @@ cfg-if = "1" tracing = "0.1" tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } tracing-chrome = "0.6" +tracing-journald = "0.3.0" tracing-tracy = "0.9" cfg_table = "1.0.0" nu-ansi-term = "0.45.1" diff --git a/tedge/src/cli.rs b/tedge/src/cli.rs index e01bc313..925af22d 100644 --- a/tedge/src/cli.rs +++ b/tedge/src/cli.rs @@ -22,6 +22,12 @@ pub struct Cli { #[clap(long)] pub chrome_logging: Option<PathBuf>, + /// Enable tracing output to journald + /// + /// If set, tracing output will be forwarded to journald + #[clap(long)] + pub journald_logging: bool, + /// Enable tracy compatible tracing output /// /// If set, "tracy" compatible tracing output will be produced diff --git a/tedge/src/logging.rs b/tedge/src/logging.rs index a2d60e76..a8e5b59c 100644 --- a/tedge/src/logging.rs +++ b/tedge/src/logging.rs @@ -1,5 +1,6 @@ use std::path::PathBuf; +use miette::IntoDiagnostic; use tracing_subscriber::filter::EnvFilter; use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::layer::SubscriberExt; @@ -10,6 +11,7 @@ use crate::cli::LoggingSpec; pub fn setup_logging( spec: Option<LoggingSpec>, chrome_logging: Option<&PathBuf>, + journald_logging: bool, tracy_logging: bool, ) -> miette::Result<LogGuard> { let env_filter = match spec { @@ -59,12 +61,17 @@ pub fn setup_logging( .map(|(layer, guard)| (Some(layer), Some(guard))) .unwrap_or_default(); + let opt_journald_layer = journald_logging + .then(tracing_journald::Layer::new) + .transpose() + .into_diagnostic()?; let opt_tracy_layer = tracy_logging.then(tracing_tracy::TracyLayer::new); let stdout_log = env_filter.map(|f| tracing_subscriber::fmt::layer().with_filter(f)); let subscriber = tracing_subscriber::registry::Registry::default() .with(opt_chrome_layer) + .with(opt_journald_layer) .with(opt_tracy_layer) .with(stdout_log); diff --git a/tedge/src/main.rs b/tedge/src/main.rs index 18ffc316..c61e7b62 100644 --- a/tedge/src/main.rs +++ b/tedge/src/main.rs @@ -13,6 +13,7 @@ async fn main() -> miette::Result<()> { let _guard = tedge_cli::logging::setup_logging( args.logging, args.chrome_logging.as_ref(), + args.journald_logging, args.tracy_logging, )?; info!("Tedge booting..."); |