Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log::Log4perl::DateFormat caches time zone offset #109

Open
provtemp opened this issue Apr 16, 2021 · 1 comment
Open

Log::Log4perl::DateFormat caches time zone offset #109

provtemp opened this issue Apr 16, 2021 · 1 comment

Comments

@provtemp
Copy link

Log::Log4perl::DateFormat computes the time zone offset only once, so Lo4perl ends up logging incorrect datetimes when the object survives during time zone changes.

% faketime '2021-03-28 01:59:58' perl -MLog::Log4perl -E 'sub g {Log::Log4perl::DateFormat->new("yyyy-MM-ddTHH:mm:ss.SSSZ")}; my $outer = g(); for (1..5) { say join " ", $outer->format(time), g->format(time); sleep 1 }'
2021-03-28T01:59:58.000+0100 2021-03-28T01:59:58.000+0100
2021-03-28T01:59:59.000+0100 2021-03-28T01:59:59.000+0100
2021-03-28T03:00:00.000+0100 2021-03-28T03:00:00.000+0200
2021-03-28T03:00:01.000+0100 2021-03-28T03:00:01.000+0200
2021-03-28T03:00:02.000+0100 2021-03-28T03:00:02.000+0200
@mohawk2
Copy link
Collaborator

mohawk2 commented Jun 1, 2022

How expensive is it to look up the timezone offset? If it's cheap, it should be just not cached. If it's expensive, then this should be documented in e.g. an FAQ (so that a rolling restart of logging could be scheduled at TZ switch time). How do other logging daemons/libraries deal with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants