create logs in subfolder
This commit is contained in:
@ -9,6 +9,7 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
pub const STOP_FILE_NAME: &str = "stop-experiment";
|
||||
pub const HOME_FOLER_EXPERIMENT: &str = "/home/exp278";
|
||||
pub const LOG_FOLDER: &str = "logs";
|
||||
|
||||
pub const OBSW_SERVER_ADDR: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
|
||||
pub const SERVER_PORT: u16 = 7301;
|
||||
|
@ -1,4 +1,11 @@
|
||||
use std::path::Path;
|
||||
|
||||
use ops_sat_rs::config::LOG_FOLDER;
|
||||
|
||||
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);
|
||||
}
|
||||
fern::Dispatch::new()
|
||||
.format(move |out, message, record| {
|
||||
out.finish(format_args!(
|
||||
@ -12,7 +19,8 @@ pub fn setup_logger() -> Result<(), fern::InitError> {
|
||||
.level(log::LevelFilter::Debug)
|
||||
.chain(std::io::stdout())
|
||||
.chain(fern::log_file(format!(
|
||||
"output_{}.log",
|
||||
"{}/output_{}.log",
|
||||
LOG_FOLDER,
|
||||
humantime::format_rfc3339_seconds(std::time::SystemTime::now())
|
||||
))?)
|
||||
.apply()?;
|
||||
|
Reference in New Issue
Block a user