refactor: enhance logging system with NoExternModule for better log filtering

This commit is contained in:
Tunglies
2025-09-21 01:31:08 +08:00
parent 94ec25c193
commit b8c82320d3
2 changed files with 26 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
use flexi_logger::filter::LogLineFilter;
cfg_if::cfg_if! {
if #[cfg(feature = "tauri-dev")] {
use std::fmt;
@@ -171,6 +173,27 @@ macro_rules! logging_error {
};
}
#[cfg(not(feature = "tauri-dev"))]
static IGNORE_MODULES: &[&str] = &["tauri", "wry"];
#[cfg(not(feature = "tauri-dev"))]
pub struct NoExternModule;
#[cfg(not(feature = "tauri-dev"))]
impl LogLineFilter for NoExternModule {
fn write(
&self,
now: &mut DeferredNow,
record: &Record,
log_line_writer: &dyn flexi_logger::filter::LogLineWriter,
) -> std::io::Result<()> {
let module_path = record.module_path().unwrap_or_default();
if IGNORE_MODULES.iter().any(|m| module_path.starts_with(m)) {
Ok(())
} else {
log_line_writer.write(now, record)
}
}
}
#[cfg(not(feature = "tauri-dev"))]
pub fn get_log_level(log_level: &LevelFilter) -> String {
#[cfg(feature = "verge-dev")]