rfc5424-logging-handler
rfc5424-logging-handler copied to clipboard
Don't import tzlocal at top level
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.
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.