MCPcopy Index your code
hub / github.com/python/cpython / doRollover

Method doRollover

Lib/logging/handlers.py:424–462  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
464class WatchedFileHandler(logging.FileHandler):
465 """

Callers

nothing calls this directly

Calls 10

getFilesToDeleteMethod · 0.95
computeRolloverMethod · 0.95
rotation_filenameMethod · 0.80
timeMethod · 0.45
strftimeMethod · 0.45
existsMethod · 0.45
closeMethod · 0.45
rotateMethod · 0.45
removeMethod · 0.45
_openMethod · 0.45

Tested by

no test coverage detected