def shouldRollover(self, record): # if doRollover doesn't work, then we don't want to find # ourselves in a situation where we're trying to do things on # a closed stream. if self.stream.closed: self.stream = open(self.baseFilename, "a") return RotatingFileHandler.shouldRollover(self, record)
def shouldRollover(self, record): """ Check the need to rotate. """ timed_rollover = TimedRotatingFileHandler.shouldRollover(self, record) sized_rollover = RotatingFileHandler.shouldRollover(self, record) return timed_rollover or sized_rollover
def shouldRollover(self, record): if RotatingFileHandler.shouldRollover(self , record): RotatingFileHandler.doRollover(self) t = time.strftime("%Y%m%d" , time.localtime(time.time())) if (cmp(self.current , t) < 0) : return 1 return 0
def shouldRollover(self, record): current_date = str(datetime.date.today()) if current_date != self.today: self.today = current_date self.baseFilename = "{}{}.log".format( self.filename_prefix, datetime.datetime.now().strftime('%Y-%m-%d_%H_%M_%S.%f')) return 1 return RotatingFileHandler.shouldRollover(self, record)
def shouldRollover(self, record): # dont rotate already rotated by other process file real_file = self._open() if os.fstat(self.stream.fileno()) != os.fstat(real_file.fileno()): self.stream.flush() self.stream.close() self.stream = real_file else: real_file.close() return RotatingFileHandler.shouldRollover(self, record)
def shouldRollover(self, record): """ Return if the log files should rollover. If a rollover operation failed in the past this method will always return False. :param logging.Record record: record that is about to be written to the logs. :returns: True if rollover should happen, False otherwise. :rtype: bool """ return not self._disable_rollover and RotatingFileHandler.shouldRollover(self, record)
def shouldRollover(self, record): return TimedRotatingFileHandler.shouldRollover( self, record) or RotatingFileHandler.shouldRollover(self, record)
def shouldRollover(self, record): return bool(TimedRotatingFileHandler.shouldRollover(self, record)) or \ bool(RotatingFileHandler.shouldRollover(self, record))
def shouldRollover(self, record): """ Determine if rollover should occur. """ return (TimedRotatingFileHandler.shouldRollover(self, record) or RotatingFileHandler.shouldRollover(self, record))
''' Created on Jan 4, 2018 @author: ZhuqinZ ''' import logging import time from logging.handlers import RotatingFileHandler if __name__ == '__main__': logger = logging.getLogger('Rotating Log') handler = RotatingFileHandler( "C:\\Users\\zhuqinz\\Desktop\\log\\172.24.201.122\\test.log", maxBytes=100, backupCount=20) logger.addHandler(handler) while (True): if handler.shouldRollover(''): handler.doRollover() time.sleep(600)
def shouldRollover(self, record): """ description : determines when to roll over (overloading) """ return TimedRotatingFileHandler.shouldRollover(self, record) \ or RotatingFileHandler.shouldRollover(self, record)