[New-bugs-announce] [issue1836] 'weekly' rotating logging file rotation incorrect
Kathryn M Kowalski
report at bugs.python.org
Tue Jan 15 22:30:09 CET 2008
New submission from Kathryn M Kowalski:
Log file did not 'rotate' on day requested.
Fixed code in Lib/logging/handlers.py class TimedRotatingFileHandler
Compare excerpt of my fix below to the original
# Case 2) The day to rollover is further in the interval (i.e., today is
# day 2 (Wednesday) and rollover is on day 6 (Sunday). Days to
# next rollover is simply 6 - 2, or 4.
# Case 3) The day to rollover is behind us in the interval (i.e., today
# is day 5 (Saturday) and rollover is on day 3 (Thursday).
# Days to rollover is 6 - 5 + 3 + 1, or 5. In this case, it's
# number of days left in the current week (1) plus the number
# of days in the next week until the rollover day (4).
day = t # 0 is Monday
if self.dayOfWeek > day:
daysToWait = (self.dayOfWeek - day)
self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
if self.dayOfWeek < day:
daysToWait = (6 - day) + self.dayOfWeek + 1
components: Library (Lib)
title: 'weekly' rotating logging file rotation incorrect
versions: Python 2.5
Tracker <report at bugs.python.org>
More information about the New-bugs-announce