[Python-checkins] r60160 - python/branches/release25-maint/Lib/logging/handlers.py
vinay.sajip
python-checkins at python.org
Mon Jan 21 18:03:47 CET 2008
Author: vinay.sajip
Date: Mon Jan 21 18:03:46 2008
New Revision: 60160
Modified:
python/branches/release25-maint/Lib/logging/handlers.py
Log:
Fix: #1836: Off-by-one bug in TimedRotatingFileHandler rollover calculation. Patch thanks to Kathryn M. Kowalski.
Modified: python/branches/release25-maint/Lib/logging/handlers.py
==============================================================================
--- python/branches/release25-maint/Lib/logging/handlers.py (original)
+++ python/branches/release25-maint/Lib/logging/handlers.py Mon Jan 21 18:03:46 2008
@@ -229,13 +229,16 @@
# Days to rollover is 6 - 5 + 3, or 4. In this case, it's the
# number of days left in the current week (1) plus the number
# of days in the next week until the rollover day (3).
+ # The calculations described in 2) and 3) above need to have a day added.
+ # This is because the above time calculation takes us to midnight on this
+ # day, i.e. the start of the next day.
if when.startswith('W'):
day = t[6] # 0 is Monday
if day != self.dayOfWeek:
if day < self.dayOfWeek:
- daysToWait = self.dayOfWeek - day - 1
+ daysToWait = self.dayOfWeek - day
else:
- daysToWait = 6 - day + self.dayOfWeek
+ daysToWait = 6 - day + self.dayOfWeek + 1
self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)
More information about the Python-checkins
mailing list