[issue40469] TimedRotatingFileHandler rotating on use not time

Ivan Marton report at bugs.python.org
Fri Aug 13 03:09:43 EDT 2021


Ivan Marton <github at martonivan.hu> added the comment:

Well, there is nothing in the documentation that would say the logrotation can be only performed by continously running scripts, thats why. :)

There are scripts or even daemons written in Python that need to be restarted from time to time. If the logrotate period is greater than restart period the log files will never be rotated, however they could be.

We were looking for something that works like the logrotate do, but without involving any external logic, but the one written in python. And TimedLogrotateHandler appears to be one of those, unless it checks the MTIME of the files instead of the CTIME.

What is the logic behind checking the MTIME instead of CTIME when one is calculating the age of a file when tries to calculate whether it has to be rotated or not? If the only purpose of this initial rollover calculation would be to start a predefined long period (as you suggest), now() (time of execution) should used instead and no file attribute should be involved. From the code I have to assume that the original author also tried to prepare for the cases where the execution is interrupted and/or restarted and (s)he wanted the TimedLogrotateHandler to be resumed where it was during the previous execution. Dnn't you agree?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40469>
_______________________________________


More information about the Python-bugs-list mailing list