[Python-checkins] r47122 - python/branches/release24-maint/Lib/logging/handlers.py
vinay.sajip
python-checkins at python.org
Tue Jun 27 09:37:46 CEST 2006
Author: vinay.sajip
Date: Tue Jun 27 09:37:45 2006
New Revision: 47122
Modified:
python/branches/release24-maint/Lib/logging/handlers.py
Log:
Removed buggy exception handling in doRollover of rotating file handlers. Exceptions now propagate to caller.
Modified: python/branches/release24-maint/Lib/logging/handlers.py
==============================================================================
--- python/branches/release24-maint/Lib/logging/handlers.py (original)
+++ python/branches/release24-maint/Lib/logging/handlers.py Tue Jun 27 09:37:45 2006
@@ -44,6 +44,8 @@
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.
@@ -126,12 +128,7 @@
dfn = self.baseFilename + ".1"
if os.path.exists(dfn):
os.remove(dfn)
- try:
- os.rename(self.baseFilename, dfn)
- except (KeyboardInterrupt, SystemExit):
- raise
- except:
- self.handleError(record)
+ os.rename(self.baseFilename, dfn)
#print "%s -> %s" % (self.baseFilename, dfn)
if self.encoding:
self.stream = codecs.open(self.baseFilename, 'w', self.encoding)
@@ -217,12 +214,8 @@
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
@@ -275,12 +268,7 @@
dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple)
if os.path.exists(dfn):
os.remove(dfn)
- try:
- os.rename(self.baseFilename, dfn)
- except (KeyboardInterrupt, SystemExit):
- raise
- except:
- self.handleError(record)
+ os.rename(self.baseFilename, dfn)
if self.backupCount > 0:
# find the oldest log file and delete it
s = glob.glob(self.baseFilename + ".20*")
More information about the Python-checkins
mailing list