diff --git a/src/bin/main.rs b/src/bin/main.rs index ec67554..a78329c 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -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)