log to file/mail

This commit is contained in:
jb-alvarado 2024-09-03 16:41:33 +02:00
parent d3d737a3fa
commit d54745a860
4 changed files with 20 additions and 18 deletions

4
Cargo.lock generated
View File

@ -1221,7 +1221,7 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
[[package]]
name = "ffplayout"
version = "0.24.0-beta3"
version = "0.24.0-beta4"
dependencies = [
"actix-files",
"actix-multipart",
@ -3696,7 +3696,7 @@ dependencies = [
[[package]]
name = "tests"
version = "0.24.0-beta3"
version = "0.24.0-beta4"
dependencies = [
"actix-rt",
"actix-test",

View File

@ -4,7 +4,7 @@ default-members = ["ffplayout", "tests"]
resolver = "2"
[workspace.package]
version = "0.24.0-beta3"
version = "0.24.0-beta4"
license = "GPL-3.0"
repository = "https://github.com/ffplayout/ffplayout"
authors = ["Jonathan Baecker <jonbae77@gmail.com>"]

View File

@ -32,7 +32,7 @@ pub fn watchman(
let path = Path::new(&config.channel.storage_path);
if !path.exists() {
error!("Folder path not exists: '{path:?}'");
error!(target: Target::file_mail(), channel = id; "Folder path not exists: '{path:?}'");
panic!("Folder path not exists: '{path:?}'");
}
@ -95,7 +95,7 @@ pub fn watchman(
}
_ => debug!(target: Target::file_mail(), channel = id; "Not tracked file event: {event:?}")
}),
Err(errors) => errors.iter().for_each(|error| error!("{error:?}")),
Err(errors) => errors.iter().for_each(|error| error!(target: Target::file_mail(), channel = id; "{error:?}")),
}
}

View File

@ -11,7 +11,7 @@ use crate::player::{
controller::{ChannelManager, ProcessUnit::*},
utils::{get_delta, get_media_map},
};
use crate::utils::{config::OutputMode::*, errors::ServiceError, TextFilter};
use crate::utils::{config::OutputMode::*, errors::ServiceError, logging::Target, TextFilter};
#[derive(Debug, Deserialize, Serialize, Clone)]
struct TextParams {
@ -85,6 +85,7 @@ pub async fn send_message(
let filter = message.to_string();
let mut data_map = Map::new();
let config = manager.config.lock().unwrap().clone();
let id = config.general.channel_id;
if config.text.zmq_stream_socket.is_some() {
if let Some(clips_filter) = manager.filter_chain.clone() {
@ -105,7 +106,7 @@ pub async fn send_message(
return Ok(data_map);
};
} else if let Err(e) = manager.stop(Ingest) {
error!("Ingest {e:?}")
error!(target: Target::file_mail(), channel = id; "Ingest {e:?}")
}
}
@ -135,6 +136,7 @@ pub async fn control_state(
command: &str,
) -> Result<Map<String, Value>, ServiceError> {
let config = manager.config.lock().unwrap().clone();
let id = config.general.channel_id;
let current_date = manager.current_date.lock().unwrap().clone();
let current_list = manager.current_list.lock().unwrap().clone();
let mut date = manager.current_date.lock().unwrap().clone();
@ -145,23 +147,23 @@ pub async fn control_state(
if index > 1 && current_list.len() > 1 {
if let Some(proc) = manager.decoder.lock().unwrap().as_mut() {
if let Err(e) = proc.kill() {
error!("Decoder {e:?}")
error!(target: Target::file_mail(), channel = id; "Decoder {e:?}")
};
if let Err(e) = proc.wait() {
error!("Decoder {e:?}")
error!(target: Target::file_mail(), channel = id; "Decoder {e:?}")
};
} else {
return Err(ServiceError::InternalServerError);
}
info!("Move to last clip");
info!(target: Target::file_mail(), channel = id; "Move to last clip");
let mut data_map = Map::new();
let mut media = current_list[index - 2].clone();
manager.current_index.fetch_sub(2, Ordering::SeqCst);
if let Err(e) = media.add_probe(false) {
error!("{e:?}");
error!(target: Target::file_mail(), channel = id; "{e:?}");
};
let (delta, _) = get_delta(&config, &media.begin.unwrap_or(0.0));
@ -181,23 +183,23 @@ pub async fn control_state(
if index < current_list.len() {
if let Some(proc) = manager.decoder.lock().unwrap().as_mut() {
if let Err(e) = proc.kill() {
error!("Decoder {e:?}")
error!(target: Target::file_mail(), channel = id; "Decoder {e:?}")
};
if let Err(e) = proc.wait() {
error!("Decoder {e:?}")
error!(target: Target::file_mail(), channel = id; "Decoder {e:?}")
};
} else {
return Err(ServiceError::InternalServerError);
}
info!("Move to next clip");
info!(target: Target::file_mail(), channel = id; "Move to next clip");
let mut data_map = Map::new();
let mut media = current_list[index].clone();
if let Err(e) = media.add_probe(false) {
error!("{e:?}");
error!(target: Target::file_mail(), channel = id; "{e:?}");
};
let (delta, _) = get_delta(&config, &media.begin.unwrap_or(0.0));
@ -216,17 +218,17 @@ pub async fn control_state(
"reset" => {
if let Some(proc) = manager.decoder.lock().unwrap().as_mut() {
if let Err(e) = proc.kill() {
error!("Decoder {e:?}")
error!(target: Target::file_mail(), channel = id; "Decoder {e:?}")
};
if let Err(e) = proc.wait() {
error!("Decoder {e:?}")
error!(target: Target::file_mail(), channel = id; "Decoder {e:?}")
};
} else {
return Err(ServiceError::InternalServerError);
}
info!("Reset playout to original state");
info!(target: Target::file_mail(), channel = id; "Reset playout to original state");
let mut data_map = Map::new();
manager.channel.lock().unwrap().time_shift = 0.0;
date.clone_from(&current_date);