From e787610afeadb21f370ede28c6c2724af753a3c7 Mon Sep 17 00:00:00 2001 From: pqnga Date: Mon, 6 Mar 2023 18:37:37 +0700 Subject: [PATCH] Address PR feedback --- plugins/log/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/log/src/lib.rs b/plugins/log/src/lib.rs index 42ad0843..b081cd41 100644 --- a/plugins/log/src/lib.rs +++ b/plugins/log/src/lib.rs @@ -95,10 +95,9 @@ impl TimezoneStrategy { pub fn get_now(&self) -> OffsetDateTime { match self { TimezoneStrategy::UseUtc => OffsetDateTime::now_utc(), - TimezoneStrategy::UseLocal => match OffsetDateTime::now_local() { - Ok(v) => v, - Err(_) => OffsetDateTime::now_utc() // Fallback to UTC since Rust cannot determine local timezone - } + TimezoneStrategy::UseLocal => { + OffsetDateTime::now_local().unwrap_or_else(|_| OffsetDateTime::now_utc()) + } // Fallback to UTC since Rust cannot determine local timezone } } } @@ -361,7 +360,8 @@ fn get_log_file_path( let to = dir.as_ref().join(format!( "{}_{}.log", app_name, - timezone_strategy.get_now() + timezone_strategy + .get_now() .format( &time::format_description::parse( "[year]-[month]-[day]_[hour]-[minute]-[second]"