From 77d1b849745098ef24d1d0df1af8dd7d1f70f673 Mon Sep 17 00:00:00 2001 From: rickiey <34705031+rickiey@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:46:53 +0800 Subject: [PATCH] fix:log config : invalid filter directive (#146) --- node/src/log.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/node/src/log.rs b/node/src/log.rs index 5f1b526..db8c1ce 100644 --- a/node/src/log.rs +++ b/node/src/log.rs @@ -20,10 +20,13 @@ pub fn configure(log_level_file: &str, log_directory: &str, executor: TaskExecut let handle = builder.reload_handle(); builder.init(); - let level_file = log_level_file.to_string(); + let level_file = log_level_file.trim_end().to_string(); // load config synchronously - let mut config = std::fs::read_to_string(&level_file).unwrap_or_default(); + let mut config = std::fs::read_to_string(&level_file) + .unwrap_or_default() + .trim_end() + .to_string(); let _ = handle.reload(&config); // periodically check for config changes @@ -38,8 +41,14 @@ pub fn configure(log_level_file: &str, log_directory: &str, executor: TaskExecut interval.tick().await; let new_config = match tokio::fs::read_to_string(&level_file).await { - Ok(c) if c == config => continue, - Ok(c) => c, + Ok(c) => { + let nc = c.trim_end().to_string(); + if nc == config { + continue; + } else { + nc + } + } Err(e) => { println!("Unable to read log file {}: {:?}", level_file, e); continue;