From 154f39ee6624bfae297aaed3c26191b2f96ed53e Mon Sep 17 00:00:00 2001 From: Giacomo Pasini Date: Mon, 6 Nov 2023 22:15:52 +0100 Subject: [PATCH] Add option to not collect logs There's currently no way for an app with a logger service to disable log collection. --- nomos-services/log/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nomos-services/log/src/lib.rs b/nomos-services/log/src/lib.rs index 8ccfa7fa..4d01c819 100644 --- a/nomos-services/log/src/lib.rs +++ b/nomos-services/log/src/lib.rs @@ -68,6 +68,8 @@ pub enum LoggerBackend { Stderr, #[serde(skip)] Writer(SharedWriter), + // do not collect logs + None, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -158,6 +160,12 @@ impl ServiceCore for Logger { LoggerBackend::Stdout => tracing_appender::non_blocking(std::io::stdout()), LoggerBackend::Stderr => tracing_appender::non_blocking(std::io::stderr()), LoggerBackend::Writer(writer) => tracing_appender::non_blocking(writer), + LoggerBackend::None => { + return Ok(Self { + service_state, + worker_guard: None, + }) + } }; let layer = tracing_subscriber::fmt::Layer::new()