From: Ian Jackson Date: Sun, 24 Apr 2022 11:26:57 +0000 (+0100) Subject: Move logging::setup out of main.rs X-Git-Tag: otter-1.1.0~466 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ea4a6727e59094b2344c4ef8d713c7b6eadf3629;p=otter.git Move logging::setup out of main.rs Signed-off-by: Ian Jackson --- 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);