Drakulix / simplelog.rs

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

Local timezone when logging #19

Closed manio closed 5 years ago

manio commented 6 years ago

Hi Victor, I think it is sometimes desirable to log times using a local timezone instead of UTC: https://github.com/Drakulix/simplelog.rs/blob/9cc5b7e87d964658d08a17a075f0801bd98ba629/src/loggers/logging.rs#L43

Can you make it configurable somehow?

Drakulix commented 5 years ago

4d9de6c9b699356a8e7236c8d3b24fad94618858 instead allows you to specify a FixedOffset to be used for logging (default is still UTC). You can now use any timezone (including one derived from chrono::offset::Local) for logging.

r-darwish commented 5 years ago

Maybe I misunderstand something but I don't see how is it possible to use Local. Config expects a FixedOffset. Local doesn't have fix() method so I think the only possible solution is to construct the current date with Local and then find some way to get the FixedOffset from the date. Even if I do that then I'll get a FixedOffset which is relevant to the time the current date was crated. If an application using simplelog.rs stays running during the night the timezone shifts to daylight saving time then the time in the logs would be wrong. Perhaps Config should get a &Timezone or Box<Timezone>?

Drakulix commented 5 years ago

Of course, I forget about DST... I will check this...

Drakulix commented 5 years ago

Perhaps Config should get a &Timezone or Box<Timezone>?

I am afraid this is not possible. Timezone is not object-safe, so I am sure, how I could store it in the config.

Drakulix commented 5 years ago

Fixed via a6fd9a240c36e26fc9ca0ceb07cec1b52359c382.

Will be in v0.7