From 611103b2115fa359a9d6331852bb13b62c02e773 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 27 Dec 2022 13:47:20 +0100 Subject: [PATCH] Add more logging to `rust-dataflow` example --- Cargo.lock | 2 ++ Cargo.toml | 2 ++ binaries/daemon/src/lib.rs | 3 +++ examples/rust-dataflow/run.rs | 11 +++++++++++ 4 files changed, 18 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index d6285549..c11a74de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1009,6 +1009,8 @@ dependencies = [ "eyre", "serde_yaml 0.8.23", "tokio", + "tracing", + "tracing-subscriber", "uuid 1.2.1", ] diff --git a/Cargo.toml b/Cargo.toml index 38873e2a..e91c3d8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,8 @@ dora-core = { path = "libraries/core" } dunce = "1.0.2" serde_yaml = "0.8.23" uuid = { version = "1.2.1", features = ["v4", "serde"] } +tracing = "0.1.36" +tracing-subscriber = "0.3.15" [[example]] name = "c-dataflow" diff --git a/binaries/daemon/src/lib.rs b/binaries/daemon/src/lib.rs index b663dbd6..7a88b58f 100644 --- a/binaries/daemon/src/lib.rs +++ b/binaries/daemon/src/lib.rs @@ -414,6 +414,9 @@ impl Daemon { if let Some(exit_when_done) = &mut self.exit_when_done { exit_when_done.remove(&dataflow_id); if exit_when_done.is_empty() { + tracing::info!( + "exiting daemon because all required dataflows are finished" + ); return Ok(RunStatus::Exit); } } diff --git a/examples/rust-dataflow/run.rs b/examples/rust-dataflow/run.rs index 54fd131f..1b9bb095 100644 --- a/examples/rust-dataflow/run.rs +++ b/examples/rust-dataflow/run.rs @@ -9,6 +9,8 @@ use uuid::Uuid; #[tokio::main] async fn main() -> eyre::Result<()> { + set_up_tracing().wrap_err("failed to set up tracing subscriber")?; + let root = Path::new(env!("CARGO_MANIFEST_DIR")); std::env::set_current_dir(root.join(file!()).parent().unwrap()) .wrap_err("failed to set working dir")?; @@ -69,3 +71,12 @@ pub async fn read_descriptor(file: &Path) -> eyre::Result { serde_yaml::from_slice(&descriptor_file).context("failed to parse given descriptor")?; Ok(descriptor) } + +fn set_up_tracing() -> eyre::Result<()> { + use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; + + let stdout_log = tracing_subscriber::fmt::layer().pretty(); + let subscriber = tracing_subscriber::Registry::default().with(stdout_log); + tracing::subscriber::set_global_default(subscriber) + .context("failed to set tracing global subscriber") +}