Address PR feedback

pull/269/head
pqnga 2 years ago
parent 1c937cdbc6
commit e787610afe

@ -95,10 +95,9 @@ impl TimezoneStrategy {
pub fn get_now(&self) -> OffsetDateTime { pub fn get_now(&self) -> OffsetDateTime {
match self { match self {
TimezoneStrategy::UseUtc => OffsetDateTime::now_utc(), TimezoneStrategy::UseUtc => OffsetDateTime::now_utc(),
TimezoneStrategy::UseLocal => match OffsetDateTime::now_local() { TimezoneStrategy::UseLocal => {
Ok(v) => v, OffsetDateTime::now_local().unwrap_or_else(|_| OffsetDateTime::now_utc())
Err(_) => OffsetDateTime::now_utc() // Fallback to UTC since Rust cannot determine local timezone } // 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!( let to = dir.as_ref().join(format!(
"{}_{}.log", "{}_{}.log",
app_name, app_name,
timezone_strategy.get_now() timezone_strategy
.get_now()
.format( .format(
&time::format_description::parse( &time::format_description::parse(
"[year]-[month]-[day]_[hour]-[minute]-[second]" "[year]-[month]-[day]_[hour]-[minute]-[second]"

Loading…
Cancel
Save