Issue 9556: Specifying the time a TimedRotatingFileHandler rotates (original) (raw)

Created on 2010-08-10 11:57 by ronaldoussoren, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue9556.txt ronaldoussoren,2012-10-23 10:09 review
updated-patch.diff vinay.sajip,2012-10-23 21:43 Added weekly test, docs to Ronald's patch review
post-comments.diff vinay.sajip,2012-10-24 12:55 Taking Ronald's comments into account review

| Repositories containing patches | | | | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | | | | http://hg.python.org/sandbox/vsajip#fix9556 | | | |

Messages (7)
msg113527 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-08-10 11:57
The logging module contains a TimedRotatingFileHandler that automaticly rotates the logfile after a specified interval. This class misses an important feature: it is not possible to specify at what time the file should be rotated, unless that time is midnight. My usecase: one of our customers works night shifts which means that rotating logfiles at midnight means that files get rotated halfway through a shift instead of at the end of one. We'd like to be able to specify that logfiles get rotated at a specific time (such as 7:00AM).
msg113565 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-10 22:21
Adding the logging maintainer to nosy. (BTW Vinay, Misc/maintainers.rst says your roundup name is “vsajip”)
msg114693 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2010-08-22 18:47
One way of implementing this is to use an additional optional "atTime" parameter which is a datetime.time instance, defaulting to None; a specified value would only be used if a 'when' value of 'D' or 'MIDNIGHT' were specified. In that case, computeRollover would be called with the specified time instead of the current time. Would that meet your requirements?
msg173587 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2012-10-23 10:09
An 'atTime' argument would work. I'm currently using a subclass of BaseRotatingHandler that implements just the 'MIDNIGHT' option of TimedRotatingFileHandler with a rotation hour argument. The attached patch is a first attempt at implementing the 'atTime' option, it is currently lacking documentation and tests for the 'WEEKLY' value for 'when'.
msg173639 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2012-10-23 21:42
Thanks for the patch. I've added the weekly test and the documentation update, can you take a look?
msg173678 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2012-10-24 12:59
Thanks for the comments on Rietveld - patch updated.
msg186648 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-04-12 16:04
New changeset eead4be1bdd9 by Vinay Sajip in branch 'default': Closed #9556: Allowed specifying a time-of-day for a TimedRotatingFileHandler to rotate. http://hg.python.org/cpython/rev/eead4be1bdd9
History
Date User Action Args
2022-04-11 14:57:05 admin set github: 53765
2013-04-12 16:04:35 python-dev set status: open -> closednosy: + python-devmessages: + resolution: fixedstage: patch review -> resolved
2013-03-07 10:46:55 tshepang set nosy: + tshepang
2012-10-24 12:59:07 vinay.sajip set messages: +
2012-10-24 12:55:58 vinay.sajip set files: + post-comments.diff
2012-10-23 21:46:05 vinay.sajip set stage: needs patch -> patch review
2012-10-23 21:43:13 vinay.sajip set files: + updated-patch.diffkeywords: + patch
2012-10-23 21:42:51 vinay.sajip set hgrepos: + hgrepo156messages: +
2012-10-23 10:09:44 ronaldoussoren set files: + issue9556.txtstatus: pending -> openmessages: + versions: + Python 3.4, - Python 3.2
2010-08-22 18:47:36 vinay.sajip set status: open -> pendingassignee: vinay.sajipmessages: +
2010-08-10 22:21:45 eric.araujo set nosy: + vinay.sajip, eric.araujomessages: +
2010-08-10 11:58:03 ronaldoussoren set type: behavior -> enhancement
2010-08-10 11:57:35 ronaldoussoren create