rfc5424-logging-handler icon indicating copy to clipboard operation
rfc5424-logging-handler copied to clipboard

Don't import tzlocal at top level

Open regebro opened this issue 1 year ago • 1 comments

tzlocal 5 now uses logging, which means that rfc5424 gets a recursive import error with tzlocal 5.0.1 and later. This PR solves that, and also does not call tzlocal every time a message is formatted. tzlocals get_localzone() does cache the result, so it's not a big burden, but it's still not necessary.

An alternative solution is to store the get_localzone method on the logger, if you want to be able refreshing the local zone at runtime, but the feature was implemented to support testing, I really don't think anyone uses it.

regebro avatar May 18 '23 14:05 regebro

Or maybe even better, don't use tzlocal at all? It seems to be used to convert local time to UTC, you don't need to know the timezone name to do that.

regebro avatar May 31 '23 09:05 regebro