auto create log directory if it's missing, or continue without logging

This commit is contained in:
andy 2025-04-10 18:03:01 -03:00
parent 98dab06b06
commit d8404a5030

View File

@ -15,6 +15,17 @@ use entity::item::{NewItemEntity, ItemDetail, InventoryItemEntity};
use entity::item;
fn setup_logger() {
match std::fs::create_dir(std::path::Path::new("log")) {
Ok(_) => {},
Err(e) => match e.kind() {
std::io::ErrorKind::AlreadyExists => {},
_ => {
println!("Error creating log directory. Error: {}", e); // Probably a permission issue
return; // Continue without logging into a file
},
},
};
let colors = fern::colors::ColoredLevelConfig::new()
.error(fern::colors::Color::Red)
.warn(fern::colors::Color::Yellow)