summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-05-26 13:48:34 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-05-26 13:48:34 (GMT)
commita37cfc649a0a6ed3ec963748886e85428eb7edd9 (patch)
tree055d611fbe978494f750aa17106215631bb5e51a /Lib/logging
parent2c9c7a5f33d502fa468e38537d57834c7e33aa4d (diff)
downloadcpython-a37cfc649a0a6ed3ec963748886e85428eb7edd9.zip
cpython-a37cfc649a0a6ed3ec963748886e85428eb7edd9.tar.gz
cpython-a37cfc649a0a6ed3ec963748886e85428eb7edd9.tar.bz2
Merged revisions 63402,63405,63411,63457,63467-63468,63480,63507-63508,63516,63534,63541 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r63402 | raymond.hettinger | 2008-05-16 23:13:36 -0500 (Fri, 16 May 2008) | 1 line Fix-up docstring ........ r63405 | gregory.p.smith | 2008-05-17 02:17:34 -0500 (Sat, 17 May 2008) | 3 lines fix issue2381: test_subprocess fails if your sys.executable is on a path with a space in it. ........ r63411 | lars.gustaebel | 2008-05-17 11:50:22 -0500 (Sat, 17 May 2008) | 8 lines Replace signatures with optional arguments in square brackets with keyword arguments and the actual default values. Fix references that point nowhere or to the wrong place. Add description of the ENCODING module-level variable. Fix the URL pointing to the GNU tar manual. Remove two obsolete examples. Add an example on how to use a generator with TarFile.extractall(). ........ r63457 | ronald.oussoren | 2008-05-18 15:09:54 -0500 (Sun, 18 May 2008) | 9 lines MacOSX: ctypes annotation in implementation of getproxies_macosx_sysconf getproxies_macosx_sysconf uses ctypes to call SystemConfiguration APIs. This checkin adds ctypes annotation to specify the right argument types for the API's that are used. This is needed to be able to use urllib on a 64-bit system, without annotations you'd get a hard crash. ........ r63467 | andrew.kuchling | 2008-05-18 22:03:46 -0500 (Sun, 18 May 2008) | 1 line Re-organize the increasingly long list of deprecated modules ........ r63468 | benjamin.peterson | 2008-05-19 06:55:54 -0500 (Mon, 19 May 2008) | 2 lines just MacOS (instead of MacOS 9) ........ r63480 | neal.norwitz | 2008-05-20 00:21:57 -0500 (Tue, 20 May 2008) | 1 line Add html package so it gets installed and more tests work (from installed copy) ........ r63507 | vinay.sajip | 2008-05-20 10:34:36 -0500 (Tue, 20 May 2008) | 1 line Fixed: #2914 (RFE for UTC support in TimedRotatingFileHandler) and #2929 (wrong filename used to delete old log files). ........ r63508 | vinay.sajip | 2008-05-20 10:37:22 -0500 (Tue, 20 May 2008) | 1 line Updated with fixes for #2914 and #2929. ........ r63516 | martin.v.loewis | 2008-05-21 02:31:31 -0500 (Wed, 21 May 2008) | 2 lines Add Robert Schuppenies. ........ r63534 | brett.cannon | 2008-05-21 22:18:35 -0500 (Wed, 21 May 2008) | 1 line Add Quentin Gallet-Gilles for (at least) a fixer for markupbase. ........ r63541 | raymond.hettinger | 2008-05-22 19:49:27 -0500 (Thu, 22 May 2008) | 1 line Docs for Issue 2819. ........
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/handlers.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 9cb0e09..c871ed0 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -153,10 +153,11 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
If backupCount is > 0, when rollover is done, no more than backupCount
files are kept - the oldest ones are deleted.
"""
- def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=0):
+ def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=0, utc=0):
BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay)
self.when = when.upper()
self.backupCount = backupCount
+ self.utc = utc
# Calculate the real rollover interval, which is just the number of
# seconds between rollovers. Also set the filename suffix used when
# a rollover occurs. Current 'when' events supported:
@@ -211,7 +212,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
# the rest. Note that this code doesn't care about leap seconds. :)
if self.when == 'MIDNIGHT' or self.when.startswith('W'):
# This could be done with less code, but I wanted it to be clear
- t = time.localtime(currentTime)
+ if utc:
+ t = time.gmtime(currentTime)
+ else:
+ t = time.localtime(currentTime)
currentHour = t[3]
currentMinute = t[4]
currentSecond = t[5]
@@ -242,13 +246,14 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
else:
daysToWait = 6 - day + self.dayOfWeek + 1
newRolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
- dstNow = t[-1]
- dstAtRollover = time.localtime(newRolloverAt)[-1]
- if dstNow != dstAtRollover:
- if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour
- newRolloverAt = newRolloverAt - 3600
- else: # DST bows out before next rollover, so we need to add an hour
- newRolloverAt = newRolloverAt + 3600
+ if not utc:
+ dstNow = t[-1]
+ dstAtRollover = time.localtime(newRolloverAt)[-1]
+ if dstNow != dstAtRollover:
+ if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour
+ newRolloverAt = newRolloverAt - 3600
+ else: # DST bows out before next rollover, so we need to add an hour
+ newRolloverAt = newRolloverAt + 3600
self.rolloverAt = newRolloverAt
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)
@@ -281,7 +286,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
if fileName[:plen] == prefix:
suffix = fileName[plen:]
if self.extMatch.match(suffix):
- result.append(fileName)
+ result.append(os.path.join(dirName, fileName))
result.sort()
if len(result) < self.backupCount:
result = []
@@ -300,7 +305,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
self.stream.close()
# get the time that this sequence started at and make it a TimeTuple
t = self.rolloverAt - self.interval
- timeTuple = time.localtime(t)
+ if self.utc:
+ timeTuple = time.gmtime(t)
+ else:
+ timeTuple = time.localtime(t)
dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple)
if os.path.exists(dfn):
os.remove(dfn)
@@ -321,7 +329,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
while newRolloverAt <= currentTime:
newRolloverAt = newRolloverAt + self.interval
#If DST changes and midnight or weekly rollover, adjust for this.
- if self.when == 'MIDNIGHT' or self.when.startswith('W'):
+ if (self.when == 'MIDNIGHT' or self.when.startswith('W')) and not self.utc:
dstNow = time.localtime(currentTime)[-1]
dstAtRollover = time.localtime(newRolloverAt)[-1]
if dstNow != dstAtRollover: