-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specifying the time a TimedRotatingFileHandler rotates #53765
Comments
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). |
Adding the logging maintainer to nosy. (BTW Vinay, Misc/maintainers.rst says your roundup name is “vsajip”) |
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? |
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'. |
Thanks for the patch. I've added the weekly test and the documentation update, can you take a look? |
Thanks for the comments on Rietveld - patch updated. |
New changeset eead4be1bdd9 by Vinay Sajip in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: