[issue1836] 'weekly' rotating logging file rotation incorrect
Christian Heimes added the comment: Please update Misc/NEWS for the bug fix. You forgot to update it for this and another logging fix a week ago. -- nosy: +tiran status: closed - pending __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1836 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1836] 'weekly' rotating logging file rotation incorrect
Changes by Vinay Sajip: -- status: pending - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1836 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1836] 'weekly' rotating logging file rotation incorrect
Changes by Christian Heimes: -- keywords: +easy priority: - normal __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1836 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1836] 'weekly' rotating logging file rotation incorrect
Kathryn M Kowalski added the comment: I did not put suggested code in - walking through it and counting days on my fingers I don't think it works. If the desired rollover day is Tuesday (self.dayOfWeek = 1) and today is Tuesday (day = 1) then self.rolloverAt is the seconds to midnight as if daysToWait =0, and it rolls over at midnight Tuesday. However if the desired rollover day is Tuesday (self.dayOfWeek = 1) and today is Monday (day = 0) then daysToWait = 0 again. It rolls over on Monday at midnight - not Tuesday at midnight. If the desired rollover day is Tuesday (self.dayOfWeek = 1) and today is Wednesday (day = 2) then daysToWait = 5. It also rolls over on Monday at midnight - not Tuesday at midnight. Changing it to: day = t[6] # 0 is Monday if day != self.dayOfWeek: if day self.dayOfWeek: daysToWait = self.dayOfWeek - day else: daysToWait = 6 - day + self.dayOfWeek + 1 would make it equivalent to what I have running and appears to work. (Always rolls (ends) on day specified at midnight.) Alternatively, if you wanted to change it so the log starts on the day specified you could just get rid of if day != self.dayOfWeek: from your code. if when.startswith('W'): day = t[6] # 0 is Monday if day self.dayOfWeek: daysToWait = self.dayOfWeek - day - 1 else: daysToWait = 6 - day + self.dayOfWeek self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24)) __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1836 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1836] 'weekly' rotating logging file rotation incorrect
Kathryn M Kowalski added the comment: downloaded from ActiveState aug 2007 Python 2.5.1.1 # 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 - 1, or 3. # 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, 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). if when.startswith('W'): day = t[6] # 0 is Monday if day self.dayOfWeek: daysToWait = (day - self.dayOfWeek) - 1 self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24)) if day self.dayOfWeek: daysToWait = (6 - self.dayOfWeek) + day __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1836 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1836] 'weekly' rotating logging file rotation incorrect
Vinay Sajip added the comment: There's already been a change to this code, since 2.5.1.1. Here's the code in trunk: if when.startswith('W'): day = t[6] # 0 is Monday if day != self.dayOfWeek: if day self.dayOfWeek: daysToWait = self.dayOfWeek - day - 1 else: daysToWait = 6 - day + self.dayOfWeek self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24)) Does it work for you? __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1836 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1836] 'weekly' rotating logging file rotation incorrect
Vinay Sajip added the comment: Please can you post the data which caused the failure? Is 'the original' the current trunk revision, or a Python release version? There was a patch to this code not long ago, so I'd like to know which code you had originally. Thanks. -- assignee: - vsajip nosy: +vsajip __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1836 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1836] 'weekly' rotating logging file rotation incorrect
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 the # number of days left in the current week (1) plus the number # of days in the next week until the rollover day (4). if when.startswith('W'): day = t[6] # 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) messages: 59983 nosy: kmk severity: normal status: open title: 'weekly' rotating logging file rotation incorrect type: behavior versions: Python 2.5 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1836 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com