Drakulix / simplelog.rs

Simple Logging Facility for Rust
https://docs.rs/simplelog/
Apache License 2.0
423 stars 71 forks source link

set_time_to_local #102

Closed jb-alvarado closed 2 years ago

jb-alvarado commented 2 years ago

Hi, I saw that in the process of replacing chrono you replace also the function set_time_to_local. Is there a equivalent for that? When I set set_time_offset I'm worry that this will result in wrong time, when in Europe it changes from summer to winter and vis versa.

Drakulix commented 2 years ago

Sadly not.

Because getting the current time was the reason for the unsoundness, that led to the decision to replace chrono with time, there is no equivalent in the time-crate. To figure this out we would need to parse timezone files on unix and I have no idea, how this could work on other operating systems. In any way this is out-of-scope for a logging library.

jb-alvarado commented 2 years ago

Thank you, for you quick response! I saw to, that now you have set_time_offset_to_local, but the doc sound not so optimistic :-). You think is save enough, to use this with a fallback when it failed? Like:

let mut config = ConfigBuilder::new();

let config = match config.set_time_offset_to_local() {
    Ok(local) => local.build(),
    Err(_) => config.build(),
};
Drakulix commented 2 years ago

Yes, that fallback should work. :+1: