diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2006-05-02 08:35:36 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2006-05-02 08:35:36 (GMT) |
commit | 4b4a63e30a8f300e545f2c44b4c456c74718aa79 (patch) | |
tree | a2e12cca998c32c22e8a8dd5da8690d57f060745 /Lib/logging/handlers.py | |
parent | 9652baaf448571ff382fdba868b9402fd3b58751 (diff) | |
download | cpython-4b4a63e30a8f300e545f2c44b4c456c74718aa79.zip cpython-4b4a63e30a8f300e545f2c44b4c456c74718aa79.tar.gz cpython-4b4a63e30a8f300e545f2c44b4c456c74718aa79.tar.bz2 |
Replaced my dumb way of calculating seconds to midnight with Tim Peters' much more sensible suggestion. What was I thinking ?!?
Diffstat (limited to 'Lib/logging/handlers.py')
-rw-r--r-- | Lib/logging/handlers.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 8e569a7..e0da254 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -44,6 +44,8 @@ DEFAULT_HTTP_LOGGING_PORT = 9022 DEFAULT_SOAP_LOGGING_PORT = 9023 SYSLOG_UDP_PORT = 514 +_MIDNIGHT = 24 * 60 * 60 # number of seconds in a day + class BaseRotatingHandler(logging.FileHandler): """ Base class for handlers that rotate log files at a certain point. @@ -217,12 +219,8 @@ class TimedRotatingFileHandler(BaseRotatingHandler): currentMinute = t[4] currentSecond = t[5] # r is the number of seconds left between now and midnight - if (currentMinute == 0) and (currentSecond == 0): - r = (24 - currentHour) * 60 * 60 # number of hours in seconds - else: - r = (23 - currentHour) * 60 * 60 - r = r + (59 - currentMinute) * 60 # plus the number of minutes (in secs) - r = r + (60 - currentSecond) # plus the number of seconds + r = _MIDNIGHT - ((currentHour * 60 + currentMinute) * 60 + + currentSecond) self.rolloverAt = currentTime + r # If we are rolling over on a certain day, add in the number of days until # the next rollover, but offset by 1 since we just calculated the time |