From ea4a6727e59094b2344c4ef8d713c7b6eadf3629 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 24 Apr 2022 12:26:57 +0100 Subject: [PATCH] Move logging::setup out of main.rs Signed-off-by: Ian Jackson --- daemon/logging.rs | 9 +++++++++ daemon/main.rs | 7 +------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/daemon/logging.rs b/daemon/logging.rs index 80596ee0..42e5a63a 100644 --- a/daemon/logging.rs +++ b/daemon/logging.rs @@ -37,3 +37,12 @@ pub const BASIC_FORMAT: FormatFunction = basic_format; pub const ADAPTIVE_FORMAT: AdaptiveFormat = AdaptiveFormat::Custom( basic_format, coloured_format ); + +#[throws(StartupError)] +pub fn setup() { + flexi_logger::Logger::with(log_config()) + .format(BASIC_FORMAT) + .adaptive_format_for_stderr(ADAPTIVE_FORMAT) + .adaptive_format_for_stdout(ADAPTIVE_FORMAT) + .start()?; +} diff --git a/daemon/main.rs b/daemon/main.rs index 5c8b605c..8540b1f7 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -487,12 +487,7 @@ async fn main() -> Result<(),StartupError> { PathResolveMethod::Chdir)?; let c = config(); - - flexi_logger::Logger::with(log_config()) - .format(logging::BASIC_FORMAT) - .adaptive_format_for_stderr(logging::ADAPTIVE_FORMAT) - .adaptive_format_for_stdout(logging::ADAPTIVE_FORMAT) - .start()?; + logging::setup().context("initialise logging")?; debug!("resolved config: {:#?}", c); -- 2.30.2