Merge pull request #837 from JackDandy/feature/ChangeLogger

Fix logger.
This commit is contained in:
JackDandy 2016-12-10 04:57:21 +00:00 committed by GitHub
commit 79d18ff485

View file

@ -203,21 +203,11 @@ class TimedCompressedRotatingFileHandler(TimedRotatingFileHandler):
backup_count, encoding, delay, utc) backup_count, encoding, delay, utc)
self.logger_instance = logger self.logger_instance = logger
def doRollover(self):
"""
example:
logger.TimedCompressedRotatingFileHandler(sickbeard.logger.sb_log_instance.log_file_path, when='M', interval=2,
logger=sickbeard.logger.sb_log_instance).doRollover()
"""
if self.logger_instance:
with self.logger_instance.log_lock:
self._do_rollover()
""" """
Extended version of TimedRotatingFileHandler that compress logs on rollover. Extended version of TimedRotatingFileHandler that compress logs on rollover.
by Angel Freire <cuerty at gmail dot com> by Angel Freire <cuerty at gmail dot com>
""" """
def _do_rollover(self): def doRollover(self):
""" """
do a rollover; in this case, a date/time stamp is appended to the filename 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 when the rollover happens. However, you want the file to be named for the
@ -227,8 +217,12 @@ class TimedCompressedRotatingFileHandler(TimedRotatingFileHandler):
This method is modified from the one in TimedRotatingFileHandler. This method is modified from the one in TimedRotatingFileHandler.
example:
logger.TimedCompressedRotatingFileHandler(sickbeard.logger.sb_log_instance.log_file_path, when='M', interval=2,
logger=sickbeard.logger.sb_log_instance).doRollover()
""" """
self.stream.close() if not self.logger_instance:
return
# get the time that this sequence started at # get the time that this sequence started at
t = self.rolloverAt - self.interval t = self.rolloverAt - self.interval
@ -240,6 +234,11 @@ class TimedCompressedRotatingFileHandler(TimedRotatingFileHandler):
self.logger_instance.close_log() self.logger_instance.close_log()
self.logger_instance.h_file = self.logger_instance.h_console = None self.logger_instance.h_file = self.logger_instance.h_console = None
try:
self.stream.close()
except AttributeError:
pass
from sickbeard import encodingKludge from sickbeard import encodingKludge
try: try:
encodingKludge.ek(os.rename, self.baseFilename, dfn) encodingKludge.ek(os.rename, self.baseFilename, dfn)