got basic action stuff running, now to make error handling better
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use ops_sat_rs::config::LOG_FOLDER;
|
||||
|
||||
@ -6,6 +6,9 @@ pub fn setup_logger() -> Result<(), fern::InitError> {
|
||||
if !Path::new(LOG_FOLDER).exists() && std::fs::create_dir_all(LOG_FOLDER).is_err() {
|
||||
eprintln!("Failed to create log folder '{}'", LOG_FOLDER);
|
||||
}
|
||||
let mut path_buf = PathBuf::from(LOG_FOLDER);
|
||||
path_buf.push(format!("output.log"));
|
||||
println!("{:?}", path_buf);
|
||||
fern::Dispatch::new()
|
||||
.format(move |out, message, record| {
|
||||
out.finish(format_args!(
|
||||
@ -18,11 +21,7 @@ pub fn setup_logger() -> Result<(), fern::InitError> {
|
||||
})
|
||||
.level(log::LevelFilter::Debug)
|
||||
.chain(std::io::stdout())
|
||||
.chain(fern::log_file(format!(
|
||||
"{}/output_{}.log",
|
||||
LOG_FOLDER,
|
||||
humantime::format_rfc3339_seconds(std::time::SystemTime::now())
|
||||
))?)
|
||||
.chain(fern::log_file(path_buf.as_os_str())?)
|
||||
.apply()?;
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user