This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: TimedRotatingFileHandler and RotatingFileHandler fail to doRollover if a logger has delay=True and no logs in that time.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, solarmist, vinay.sajip
Priority: normal Keywords: patch

Created on 2013-09-05 23:49 by solarmist, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
doRollover.patch solarmist, 2013-09-06 01:51 Patch for doRollover review
logging_test.py solarmist, 2013-09-06 01:53 Demonstrate the bug
Messages (4)
msg197035 - (view) Author: Joshua Olson (solarmist) * Date: 2013-09-05 23:49
In TimedRotatingFileHandler if you have a low volume logger than hasn't written to the log within the interval time doRollover will fail because there is no file to rotate.

os.rename(self.baseFilename, dfn) 

should be something like

if os.path.exists(self.base_fileName):
    os.rename(self.baseFilename, dfn

I have included a unit test file.  This test fails on 2.7.1 and 2.7.3. I have not tried 2.7.5.
msg197039 - (view) Author: Joshua Olson (solarmist) * Date: 2013-09-06 00:46
Here is a patch for the logging file from the cpython hg repo.
msg197041 - (view) Author: Joshua Olson (solarmist) * Date: 2013-09-06 01:51
This fixes the issue in both RotatingFilerHandler classes.
msg197059 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-09-06 09:11
New changeset 6a591870017c by Vinay Sajip in branch '2.7':
Issue #18940: Handled low-volume logging when delay is True.
http://hg.python.org/cpython/rev/6a591870017c

New changeset 324774a59256 by Vinay Sajip in branch '3.3':
Issue #18940: Handled low-volume logging when delay is True.
http://hg.python.org/cpython/rev/324774a59256

New changeset 8002aee72837 by Vinay Sajip in branch 'default':
Closes #18940: Merged fix from 3.3.
http://hg.python.org/cpython/rev/8002aee72837
History
Date User Action Args
2022-04-11 14:57:50adminsetgithub: 63140
2013-09-06 09:11:50python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg197059

resolution: fixed
stage: resolved
2013-09-06 02:42:09r.david.murraysetnosy: + vinay.sajip
2013-09-06 01:53:00solarmistsetfiles: + logging_test.py
2013-09-06 01:51:21solarmistsetfiles: + doRollover.patch

messages: + msg197041
title: TimedRotatingFileHandler fails to doRollover if a logger has delay=True and no logs in that time. -> TimedRotatingFileHandler and RotatingFileHandler fail to doRollover if a logger has delay=True and no logs in that time.
2013-09-06 01:50:18solarmistsetfiles: - logging_test.py
2013-09-06 01:50:11solarmistsetfiles: - doRollover.patch
2013-09-06 00:47:48solarmistsettype: behavior
2013-09-06 00:46:02solarmistsetfiles: + doRollover.patch
keywords: + patch
messages: + msg197039
2013-09-05 23:49:27solarmistcreate