do a rollover; in this case, a date/time stamp is appended to the filename when the rollover happens. However, you want the file to be named for the start of the interval, not the current time. If there is a backup count, then we have to get a list of matching file
(self)
| 422 | return result |
| 423 | |
| 424 | def doRollover(self): |
| 425 | """ |
| 426 | do a rollover; in this case, a date/time stamp is appended to the filename |
| 427 | when the rollover happens. However, you want the file to be named for the |
| 428 | start of the interval, not the current time. If there is a backup count, |
| 429 | then we have to get a list of matching filenames, sort them and remove |
| 430 | the one with the oldest suffix. |
| 431 | """ |
| 432 | # get the time that this sequence started at and make it a TimeTuple |
| 433 | currentTime = int(time.time()) |
| 434 | t = self.rolloverAt - self.interval |
| 435 | if self.utc: |
| 436 | timeTuple = time.gmtime(t) |
| 437 | else: |
| 438 | timeTuple = time.localtime(t) |
| 439 | dstNow = time.localtime(currentTime)[-1] |
| 440 | dstThen = timeTuple[-1] |
| 441 | if dstNow != dstThen: |
| 442 | if dstNow: |
| 443 | addend = 3600 |
| 444 | else: |
| 445 | addend = -3600 |
| 446 | timeTuple = time.localtime(t + addend) |
| 447 | dfn = self.rotation_filename(self.baseFilename + "." + |
| 448 | time.strftime(self.suffix, timeTuple)) |
| 449 | if os.path.exists(dfn): |
| 450 | # Already rolled over. |
| 451 | return |
| 452 | |
| 453 | if self.stream: |
| 454 | self.stream.close() |
| 455 | self.stream = None |
| 456 | self.rotate(self.baseFilename, dfn) |
| 457 | if self.backupCount > 0: |
| 458 | for s in self.getFilesToDelete(): |
| 459 | os.remove(s) |
| 460 | if not self.delay: |
| 461 | self.stream = self._open() |
| 462 | self.rolloverAt = self.computeRollover(currentTime) |
| 463 | |
| 464 | class WatchedFileHandler(logging.FileHandler): |
| 465 | """ |
nothing calls this directly
no test coverage detected