From e25ff500d80855d42ca04373e23217888898b04b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 6 Apr 2024 18:53:18 +0100 Subject: [PATCH] feat(server): Add stub for server start command --- src/server.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/server.rs b/src/server.rs index cf2a47f..9bd012b 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,5 +1,7 @@ use std::io::Write; +use tracing::info; + pub(crate) fn init() { let file_name = "git-next-server.toml"; let path = std::path::Path::new(file_name); @@ -20,3 +22,29 @@ pub(crate) fn init() { } } } + +pub(crate) fn start() { + let Ok(_) = init_logging() else { + eprintln!("Failed to initialize logging."); + return; + }; + info!("Starting Server..."); + // todo!() +} + +pub fn init_logging() -> Result<(), tracing::subscriber::SetGlobalDefaultError> { + use tracing_subscriber::prelude::*; + + let console_layer = console_subscriber::ConsoleLayer::builder().spawn(); + + let subscriber = tracing_subscriber::fmt::layer() + // NOTE: set RUSTLOG in ${root}/.cargo/config + .with_target(false) + .with_file(true) + .with_line_number(true); + tracing_subscriber::registry() + .with(console_layer) + .with(subscriber) + .init(); + Ok(()) +}