diff --git a/sickbeard/config.py b/sickbeard/config.py index 540241d7..a1927bbf 100644 --- a/sickbeard/config.py +++ b/sickbeard/config.py @@ -89,7 +89,7 @@ def change_LOG_DIR(log_dir, web_log): sickbeard.ACTUAL_LOG_DIR = os.path.normpath(log_dir) sickbeard.LOG_DIR = abs_log_dir - logger.sb_log_instance.initLogging() + logger.initLogging() logger.log(u"Initialized new log file in " + sickbeard.LOG_DIR) log_dir_changed = True diff --git a/sickbeard/logger.py b/sickbeard/logger.py index 969c3444..ef43f661 100644 --- a/sickbeard/logger.py +++ b/sickbeard/logger.py @@ -27,6 +27,8 @@ import threading import sickbeard from sickbeard import classes +censoredItems = {} + # log levels ERROR = logging.ERROR WARNING = logging.WARNING @@ -40,8 +42,6 @@ reverseNames = {u'ERROR': ERROR, u'DEBUG': DEBUG, u'DB': DB} -censoredItems = {} - # send logging to null class NullFilter(logging.Filter): def filter(self, record): @@ -54,9 +54,7 @@ class CensorFilter(logging.Filter): record.msg = record.msg.replace(v, len(v) * '*') return True -def initLogging(consoleLogging=False, fileLogging=False, debug=False): - logFile = os.path.join(sickbeard.LOG_DIR, 'sickrage.log') - +def initLogging(logFile=os.path.join(sickbeard.LOG_DIR, 'sickrage.log'), consoleLogging=False, fileLogging=False, debug=False): # Add a new logging level DB logging.addLevelName(DB, 'DB') diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index ad616534..30bae45d 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -1278,8 +1278,8 @@ class CMD_Logs(ApiCall): minLevel = logger.reverseNames[str(self.min_level).upper()] data = [] - if os.path.isfile(logger.sb_log_instance.log_file_path): - with ek.ek(open, logger.sb_log_instance.log_file_path) as f: + if os.path.isfile(logger.logFile): + with ek.ek(open, logger.logFile) as f: data = f.readlines() regex = "^(\d\d\d\d)\-(\d\d)\-(\d\d)\s*(\d\d)\:(\d\d):(\d\d)\s*([A-Z]+)\s*(.+?)\s*\:\:\s*(.*)$" diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 041be1d9..2f991009 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -4663,8 +4663,8 @@ class ErrorLogs(WebRoot): minLevel = int(minLevel) data = [] - if os.path.isfile(logger.sb_log_instance.log_file_path): - with ek.ek(open, logger.sb_log_instance.log_file_path) as f: + if os.path.isfile(logger.logFile): + with ek.ek(open, logger.logFile) as f: data = f.readlines() regex = "^(\d\d\d\d)\-(\d\d)\-(\d\d)\s*(\d\d)\:(\d\d):(\d\d)\s*([A-Z]+)\s*(.+?)\s*\:\:\s*(.*)$" diff --git a/tests/test_lib.py b/tests/test_lib.py index bfeb4314..ccb958f1 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -54,8 +54,7 @@ FILEDIR = os.path.join(TESTDIR, SHOWNAME) FILEPATH = os.path.join(FILEDIR, FILENAME) SHOWDIR = os.path.join(TESTDIR, SHOWNAME + " final") -#sickbeard.logger.sb_log_instance = sickbeard.logger.SBRotatingLogHandler(os.path.join(TESTDIR, 'sickbeard.log'), sickbeard.logger.NUM_LOGS, sickbeard.logger.LOG_SIZE) -sickbeard.logger.SBRotatingLogHandler.log_file = os.path.join(os.path.join(TESTDIR, 'Logs'), 'test_sickbeard.log') +sickbeard.logger.initLogging(os.path.join(os.path.join(TESTDIR, 'Logs'), 'test_sickbeard.log')) #================= # prepare env functions @@ -92,7 +91,7 @@ sickbeard.PROG_DIR = os.path.abspath('..') sickbeard.DATA_DIR = sickbeard.PROG_DIR sickbeard.LOG_DIR = os.path.join(TESTDIR, 'Logs') createTestLogFolder() -sickbeard.logger.sb_log_instance.initLogging(False) +sickbeard.logger.initLogging(False) sickbeard.CACHE_DIR = os.path.join(TESTDIR, 'cache') createTestCacheFolder()