loguru icon indicating copy to clipboard operation
loguru copied to clipboard

Add timezone to default logging time

Open tim-x-y-z opened this issue 1 year ago • 19 comments

Hi thanks for the great library! 🤙

Started using it recently, and having resources in various locations I thought it would be great to have the timezone information in the default format. I realised that i could define a custom format for my need - but everything else just works out of the box, it felt that just this could be a nice default to have too.

Let me know your thoughts.

tim-x-y-z avatar Apr 27 '23 08:04 tim-x-y-z

Hi @tim-habitat. Thanks for the improvement proposal. :+1:

I do like the idea of displaying the timezone by default since it eliminates any potential ambiguities. It feels good, indeed.

On the other hand, I also appreciate the simplicity of the current format. Repeatedly displaying the timezone is not necessarily useful for the default user, especially when Loguru is used as a replacement of print().

Basically, I see two cases where the timezone is very valuable:

  • reviewing logs from a system running on a different location
  • parsing logs from a file and converting them into a structured format

However, these are not necessarily common use cases and are intended for the more advanced user. So it would make sense to leave the format without timezone by default, since it is a bit less cumbersome to read.

Considering that many libraries and tools do not display the timezone by default, and that this may be what the end user prefers, I would rather leave the format as is. But in the end, I have mixed feelings.

On a side note, there is also the question of the default format used for file names. Currently, the naive local time is used. It is difficult to consider displaying the timezone, since "+" in the file name raises concerns about portability and usability. Maybe it could be left as is or converted to UTC with "Z" suffix.

Delgan avatar May 05 '23 14:05 Delgan

Hey,

Thanks for the reply!

I take the point that not everyone would want that timezone info in their logs - particularly as it may be redundant during local development. Though, personally, i feel it's good to always attach timezones to times and introduce this way of thinking may guide people towards the right direction before shooting themself in the foot. Of course, i understand loguru achieved the level of popularity because of its ease of use and all. This was more of a selfish suggestion as i felt all the other default were perfect (even at "scale").

On the filename, i think converting to UTC would make the most sense - but this needs to be easily understood by the users for the same reasons. I don't really see any other way either to include an iso 8601 name.

tim-x-y-z avatar May 08 '23 13:05 tim-x-y-z

Though, personally, i feel it's good to always attach timezones to times and introduce this way of thinking may guide people towards the right direction before shooting themself in the foot.

Yes, that's totally how I feel as well. The user may have unpleasant surprises the day he needs to manipulate the logged "naive" dates. Whereas with "aware" date by default, a whole lot of possible problems are avoided.

I agree with you about enforcing good practices, even if it can be a bit annoying visually, it shouldn't be a big deal.

I'm leaving this open for now, I could probably make it the default for the next version, thanks. :+1:

Delgan avatar May 08 '23 16:05 Delgan

hey @Delgan - did you have anymore thoughts about this ? :)

tim-x-y-z avatar Sep 07 '23 12:09 tim-x-y-z

I'm waiting for the next minor release, namely v0.8.0, to merge this, as this is kind of a breaking change. I need first to publish v0.7.2 due to a bug introduced in v0.7.1.

Delgan avatar Sep 07 '23 16:09 Delgan

amazing thanks - looking forward to it!

tim-x-y-z avatar Sep 08 '23 07:09 tim-x-y-z

any progress :P ?

rickythink avatar Mar 06 '24 06:03 rickythink

Persistent review updated to latest commit https://github.com/Delgan/loguru/commit/c9e240b1c3454d9a57b6009072a768a4b450d9a6

startime-h avatar May 30 '24 13:05 startime-h

Persistent review updated to latest commit https://github.com/Delgan/loguru/commit/c9e240b1c3454d9a57b6009072a768a4b450d9a6

startime-h avatar May 30 '24 13:05 startime-h

Persistent review updated to latest commit https://github.com/Delgan/loguru/commit/c9e240b1c3454d9a57b6009072a768a4b450d9a6

startime-h avatar May 30 '24 13:05 startime-h

Persistent review updated to latest commit https://github.com/Delgan/loguru/commit/c9e240b1c3454d9a57b6009072a768a4b450d9a6

startime-h avatar May 30 '24 13:05 startime-h

Persistent review updated to latest commit https://github.com/Delgan/loguru/commit/c9e240b1c3454d9a57b6009072a768a4b450d9a6

startime-h avatar May 30 '24 13:05 startime-h

Persistent review updated to latest commit https://github.com/Delgan/loguru/commit/c9e240b1c3454d9a57b6009072a768a4b450d9a6

startime-h avatar May 30 '24 13:05 startime-h

Persistent review updated to latest commit https://github.com/Delgan/loguru/commit/c9e240b1c3454d9a57b6009072a768a4b450d9a6

startime-h avatar May 30 '24 13:05 startime-h

Preparing review...

startime-h avatar May 30 '24 13:05 startime-h

Persistent review updated to latest commit https://github.com/Delgan/loguru/commit/c9e240b1c3454d9a57b6009072a768a4b450d9a6

startime-h avatar May 30 '24 13:05 startime-h