add option to enable/disable timestamps in logging
This commit is contained in:
parent
89ba67cbbe
commit
c1644899da
@ -28,6 +28,7 @@ logging:
|
|||||||
log_to_file: false
|
log_to_file: false
|
||||||
backup_count: 7
|
backup_count: 7
|
||||||
local_time: true
|
local_time: true
|
||||||
|
timestamp: true
|
||||||
log_path: "/var/log/ffplayout/"
|
log_path: "/var/log/ffplayout/"
|
||||||
log_level: "DEBUG"
|
log_level: "DEBUG"
|
||||||
ffmpeg_level: "error"
|
ffmpeg_level: "error"
|
||||||
|
@ -44,6 +44,7 @@ pub struct Logging {
|
|||||||
pub log_to_file: bool,
|
pub log_to_file: bool,
|
||||||
pub backup_count: usize,
|
pub backup_count: usize,
|
||||||
pub local_time: bool,
|
pub local_time: bool,
|
||||||
|
pub timestamp: bool,
|
||||||
pub log_path: String,
|
pub log_path: String,
|
||||||
pub log_level: String,
|
pub log_level: String,
|
||||||
pub ffmpeg_level: String,
|
pub ffmpeg_level: String,
|
||||||
|
@ -103,13 +103,19 @@ async fn send_mail(msg: String) {
|
|||||||
pub fn init_logging(rt_handle: Handle) -> Vec<Box<dyn SharedLogger>> {
|
pub fn init_logging(rt_handle: Handle) -> Vec<Box<dyn SharedLogger>> {
|
||||||
let config = GlobalConfig::global();
|
let config = GlobalConfig::global();
|
||||||
let app_config = config.logging.clone();
|
let app_config = config.logging.clone();
|
||||||
|
let mut time_level = LevelFilter::Off;
|
||||||
let mut app_logger: Vec<Box<dyn SharedLogger>> = vec![];
|
let mut app_logger: Vec<Box<dyn SharedLogger>> = vec![];
|
||||||
|
|
||||||
|
if app_config.timestamp {
|
||||||
|
time_level = LevelFilter::Error;
|
||||||
|
}
|
||||||
|
|
||||||
let log_config = simplelog::ConfigBuilder::new()
|
let log_config = simplelog::ConfigBuilder::new()
|
||||||
.set_thread_level(LevelFilter::Off)
|
.set_thread_level(LevelFilter::Off)
|
||||||
.set_target_level(LevelFilter::Off)
|
.set_target_level(LevelFilter::Off)
|
||||||
.set_level_padding(LevelPadding::Left)
|
.set_level_padding(LevelPadding::Left)
|
||||||
.set_time_to_local(app_config.local_time)
|
.set_time_to_local(app_config.local_time)
|
||||||
|
.set_time_level(time_level)
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
if app_config.log_to_file {
|
if app_config.log_to_file {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user