change to eprint, fix log path create in main
This commit is contained in:
parent
7aeb9dad0b
commit
82c02e293c
@ -103,9 +103,12 @@ fn main() -> Result<(), ProcError> {
|
||||
let messages = Arc::new(Mutex::new(Vec::new()));
|
||||
|
||||
// try to create logging folder, if not exist
|
||||
if config.logging.log_to_file && config.logging.path.is_dir() {
|
||||
if config.logging.log_to_file
|
||||
&& !config.logging.path.is_dir()
|
||||
&& !config.logging.path.ends_with(".log")
|
||||
{
|
||||
if let Err(e) = fs::create_dir_all(&config.logging.path) {
|
||||
println!("Logging path not exists! {e}");
|
||||
eprintln!("Logging path not exists! {e}");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ pub fn get_config(args: Args) -> Result<PlayoutConfig, ProcError> {
|
||||
}
|
||||
|
||||
if let Some(log_path) = args.log {
|
||||
if log_path != Path::new("none") && log_path.is_dir() {
|
||||
if log_path != Path::new("none") {
|
||||
config.logging.log_to_file = true;
|
||||
config.logging.path = log_path;
|
||||
} else {
|
||||
|
@ -377,7 +377,7 @@ impl PlayoutConfig {
|
||||
let f = match File::open(&config_path) {
|
||||
Ok(file) => file,
|
||||
Err(_) => {
|
||||
println!(
|
||||
eprintln!(
|
||||
"{config_path:?} doesn't exists!\nPut \"ffplayout.yml\" in \"/etc/playout/\" or beside the executable!"
|
||||
);
|
||||
process::exit(1);
|
||||
|
@ -2,7 +2,6 @@ extern crate log;
|
||||
extern crate simplelog;
|
||||
|
||||
use std::{
|
||||
fs,
|
||||
path::PathBuf,
|
||||
sync::{atomic::Ordering, Arc, Mutex},
|
||||
thread::{self, sleep},
|
||||
@ -205,12 +204,6 @@ pub fn init_logging(
|
||||
};
|
||||
};
|
||||
|
||||
if app_config.log_to_file && !app_config.path.exists() && !app_config.path.ends_with(".log") {
|
||||
if let Err(e) = fs::create_dir_all(&app_config.path) {
|
||||
eprintln!("Log folder creating failed: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
if app_config.log_to_file && app_config.path.exists() {
|
||||
let file_config = log_config
|
||||
.clone()
|
||||
@ -225,7 +218,7 @@ pub fn init_logging(
|
||||
} else if app_config.path.is_file() {
|
||||
log_path = app_config.path
|
||||
} else {
|
||||
println!("Logging path not exists!")
|
||||
eprintln!("Logging path not exists!")
|
||||
}
|
||||
|
||||
let log_file = FileRotate::new(
|
||||
|
Loading…
Reference in New Issue
Block a user