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

Skip to content

Commit f7b436c

Browse files
committed
Closes #18941: Merged fix from 3.3.
2 parents a92a356 + 43c6ef1 commit f7b436c

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
"""
@@ -971,6 +971,7 @@ def __init__(self, filename, mode='a', encoding=None, delay=False):
971971
self.baseFilename = os.path.abspath(filename)
972972
self.mode = mode
973973
self.encoding = encoding
974+
self.delay = delay
974975
if delay:
975976
#We don't open the stream, but we still need to call the
976977
#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
@@ -172,7 +172,8 @@ def doRollover(self):
172172
if os.path.exists(dfn):
173173
os.remove(dfn)
174174
self.rotate(self.baseFilename, dfn)
175-
self.stream = self._open()
175+
if not self.delay:
176+
self.stream = self._open()
176177

177178
def shouldRollover(self, record):
178179
"""
@@ -394,7 +395,8 @@ def doRollover(self):
394395
if self.backupCount > 0:
395396
for s in self.getFilesToDelete():
396397
os.remove(s)
397-
self.stream = self._open()
398+
if not self.delay:
399+
self.stream = self._open()
398400
newRolloverAt = self.computeRollover(currentTime)
399401
while newRolloverAt <= currentTime:
400402
newRolloverAt = newRolloverAt + self.interval

0 commit comments

Comments
 (0)