Commit 0f2eb140 authored by Vinay Sajip's avatar Vinay Sajip

Issue #18941: Respected delay when doing rollover.

parent 117cf1c3
# Copyright 2001-2012 by Vinay Sajip. All Rights Reserved. # Copyright 2001-2013 by Vinay Sajip. All Rights Reserved.
# #
# Permission to use, copy, modify, and distribute this software and its # Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, # documentation for any purpose and without fee is hereby granted,
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
Logging package for Python. Based on PEP 282 and comments thereto in Logging package for Python. Based on PEP 282 and comments thereto in
comp.lang.python. comp.lang.python.
Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved. Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away! To use, simply 'import logging' and log away!
""" """
...@@ -957,6 +957,7 @@ class FileHandler(StreamHandler): ...@@ -957,6 +957,7 @@ class FileHandler(StreamHandler):
self.baseFilename = os.path.abspath(filename) self.baseFilename = os.path.abspath(filename)
self.mode = mode self.mode = mode
self.encoding = encoding self.encoding = encoding
self.delay = delay
if delay: if delay:
#We don't open the stream, but we still need to call the #We don't open the stream, but we still need to call the
#Handler constructor to set level, formatter, lock etc. #Handler constructor to set level, formatter, lock etc.
......
...@@ -174,6 +174,7 @@ class RotatingFileHandler(BaseRotatingHandler): ...@@ -174,6 +174,7 @@ class RotatingFileHandler(BaseRotatingHandler):
if os.path.exists(dfn): if os.path.exists(dfn):
os.remove(dfn) os.remove(dfn)
self.rotate(self.baseFilename, dfn) self.rotate(self.baseFilename, dfn)
if not self.delay:
self.stream = self._open() self.stream = self._open()
def shouldRollover(self, record): def shouldRollover(self, record):
...@@ -382,6 +383,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler): ...@@ -382,6 +383,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
if self.backupCount > 0: if self.backupCount > 0:
for s in self.getFilesToDelete(): for s in self.getFilesToDelete():
os.remove(s) os.remove(s)
if not self.delay:
self.stream = self._open() self.stream = self._open()
newRolloverAt = self.computeRollover(currentTime) newRolloverAt = self.computeRollover(currentTime)
while newRolloverAt <= currentTime: while newRolloverAt <= currentTime:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment