diff --git a/src/server.rs b/src/server.rs index cf2a47f9..9bd012b7 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(()) +}