gh-90535: Fix support of interval>1 in logging.TimedRotatingFileHandler#116220
Conversation
…eHandler Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
ba423df to
c1feb41
Compare
|
@vsajip, please take a look. It is a surprisingly tiny change. |
vsajip
left a comment
There was a problem hiding this comment.
Just one minor suggestion. Otherwise looks fine. Thank you very much for all your work on TimedRotatingFileHandler, Serhiy!
Lib/logging/handlers.py
Outdated
| else: | ||
| daysToWait = 6 - day + self.dayOfWeek + 1 | ||
| result += daysToWait * (60 * 60 * 24) | ||
| if self.when == 'MIDNIGHT': |
There was a problem hiding this comment.
No, because the else branch should be executed when self.when.startswith('W').
I see now that two ifs can be merged:
if self.when.startswith('W'):
day = currentDay # 0 is Monday
if day != self.dayOfWeek:
if day < self.dayOfWeek:
daysToWait = self.dayOfWeek - day
else:
daysToWait = 6 - day + self.dayOfWeek + 1
result += daysToWait * _MIDNIGHT
result += self.interval - _MIDNIGHT * 7
else:
result += self.interval - _MIDNIGHT|
When you're done making the requested changes, leave the comment: |
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @vsajip: please review the changes made to this pull request. |
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'. (cherry picked from commit 269051d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-116892 is a backport of this pull request to the 3.12 branch. |
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'. (cherry picked from commit 269051d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-116893 is a backport of this pull request to the 3.11 branch. |
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
…eHandler (pythonGH-116220) Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.
Fix support of interval values > 1 in logging.TimedRotatingFileHandler for when='MIDNIGHT' and when='Wx'.