classification
Title: Specifying the time a TimedRotatingFileHandler rotates
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.2
process
Status: pending Resolution:
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: eric.araujo, ronaldoussoren, vinay.sajip
Priority: normal Keywords:

Created on 2010-08-10 11:57 by ronaldoussoren, last changed 2010-08-22 18:47 by vinay.sajip.

Messages (3)
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?
History
Date User Action Args
2010-08-22 18:47:36vinay.sajipsetstatus: open -> pending
assignee: vinay.sajip
messages: + msg114693
2010-08-10 22:21:45eric.araujosetnosy: + vinay.sajip, eric.araujo
messages: + msg113565
2010-08-10 11:58:03ronaldoussorensettype: behavior -> enhancement
2010-08-10 11:57:35ronaldoussorencreate