MCPcopy Index your code
hub / github.com/RustPython/RustPython / doRollover

Method doRollover

Lib/logging/handlers.py:420–458  ·  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

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

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