feat: app log level add silent

This commit is contained in:
GyDi 2023-07-22 09:25:54 +08:00
parent aadfaf7150
commit 6b0ca2966e
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A
3 changed files with 11 additions and 7 deletions

View File

@ -10,7 +10,7 @@ pub struct IVerge {
pub app_singleton_port: Option<u16>,
/// app log level
/// `trace` `debug` `info` `warn` `error`
/// silent | error | warn | info | debug | trace
pub app_log_level: Option<String>,
// i18n
@ -193,11 +193,12 @@ impl IVerge {
pub fn get_log_level(&self) -> LevelFilter {
if let Some(level) = self.app_log_level.as_ref() {
match level.to_lowercase().as_str() {
"trace" => LevelFilter::Trace,
"debug" => LevelFilter::Debug,
"info" => LevelFilter::Info,
"warn" => LevelFilter::Warn,
"silent" => LevelFilter::Off,
"error" => LevelFilter::Error,
"warn" => LevelFilter::Warn,
"info" => LevelFilter::Info,
"debug" => LevelFilter::Debug,
"trace" => LevelFilter::Trace,
_ => LevelFilter::Info,
}
} else {

View File

@ -18,6 +18,9 @@ fn init_log() -> Result<()> {
}
let log_level = Config::verge().data().get_log_level();
if log_level == LevelFilter::Off {
return Ok(());
}
let local_time = Local::now().format("%Y-%m-%d-%H%M").to_string();
let log_file = format!("{}.log", local_time);

View File

@ -83,9 +83,9 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
}));
}}
>
{["trace", "debug", "info", "warn", "error"].map((i) => (
{["trace", "debug", "info", "warn", "error", "silent"].map((i) => (
<MenuItem value={i} key={i}>
{i}
{i[0].toUpperCase() + i.slice(1).toLowerCase()}
</MenuItem>
))}
</Select>