gh-90535: Fix support of interval>1 in logging.TimedRotatingFileHandler (GH-116220)

Fix support of interval values > 1 in logging.TimedRotatingFileHandler
for when='MIDNIGHT' and when='Wx'.
This commit is contained in:
Serhiy Storchaka 2024-03-16 12:29:42 +02:00 • committed by GitHub
parent 20578a1f68
commit 269051d20e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 173 additions and 35 deletions

View file

@ -340,7 +340,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
daysToWait = self.dayOfWeek - day
else:
daysToWait = 6 - day + self.dayOfWeek + 1
result += daysToWait * (60 * 60 * 24)
result += daysToWait * _MIDNIGHT
result += self.interval - _MIDNIGHT * 7
else:
result += self.interval - _MIDNIGHT
if not self.utc:
dstNow = t[-1]
dstAtRollover = time.localtime(result)[-1]