auto create log directory if it's missing, or continue without logging
This commit is contained in:
parent
98dab06b06
commit
d8404a5030
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user