Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43c6ef1

Browse files
committed
Issue #18941: Respected delay when doing rollover.
1 parent d859926 commit 43c6ef1

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

Lib/logging/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2001-2012 by Vinay Sajip. All Rights Reserved.
1+
# Copyright 2001-2013 by Vinay Sajip. All Rights Reserved.
22
#
33
# Permission to use, copy, modify, and distribute this software and its
44
# documentation for any purpose and without fee is hereby granted,
@@ -18,7 +18,7 @@
1818
Logging package for Python. Based on PEP 282 and comments thereto in
1919
comp.lang.python.
2020
21-
Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved.
21+
Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
2222
2323
To use, simply 'import logging' and log away!
2424
"""
@@ -957,6 +957,7 @@ def __init__(self, filename, mode='a', encoding=None, delay=False):
957957
self.baseFilename = os.path.abspath(filename)
958958
self.mode = mode
959959
self.encoding = encoding
960+
self.delay = delay
960961
if delay:
961962
#We don't open the stream, but we still need to call the
962963
#Handler constructor to set level, formatter, lock etc.

Lib/logging/handlers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ def doRollover(self):
174174
if os.path.exists(dfn):
175175
os.remove(dfn)
176176
self.rotate(self.baseFilename, dfn)
177-
self.stream = self._open()
177+
if not self.delay:
178+
self.stream = self._open()
178179

179180
def shouldRollover(self, record):
180181
"""
@@ -382,7 +383,8 @@ def doRollover(self):
382383
if self.backupCount > 0:
383384
for s in self.getFilesToDelete():
384385
os.remove(s)
385-
self.stream = self._open()
386+
if not self.delay:
387+
self.stream = self._open()
386388
newRolloverAt = self.computeRollover(currentTime)
387389
while newRolloverAt <= currentTime:
388390
newRolloverAt = newRolloverAt + self.interval

0 commit comments

Comments
 (0)