This commit is contained in:
2025-10-26 09:24:49 -07:00
parent 5455935f3a
commit eefc3293b4
36 changed files with 886 additions and 516 deletions

View File

@@ -5,6 +5,10 @@ use std::fs::create_dir_all;
use std::str::FromStr;
use std::{env, thread};
/// Set up the logger with a given package name
///
/// # Errors
/// If an error occurred while trying to set up the logger
pub fn setup_logger(package_name: &'static str) -> Result<()> {
let log_file = env::var("LOG_FILE").or_else(|_| {
create_dir_all("logs/")?;
@@ -37,7 +41,7 @@ pub fn setup_logger(package_name: &'static str) -> Result<()> {
level = colors.color(record.level()),
time = chrono::Local::now().format("%Y-%m-%dT%H:%M:%S%.9f"),
target = record.target(),
))
));
})
.chain(
fern::Dispatch::new()
@@ -47,6 +51,6 @@ pub fn setup_logger(package_name: &'static str) -> Result<()> {
.chain(fern::log_file(log_file.clone())?)
.apply()?;
debug!("Logging to {} at level {}", log_file, log_level);
debug!("Logging to {log_file} at level {log_level}");
Ok(())
}