Changed nzbtomedia_configure_logging to accept a logfile paramater so that in the future if wanted we could log to seperate files

This commit is contained in:
echel0n 2014-04-01 21:57:22 -07:00
commit 4c35248561
8 changed files with 10 additions and 10 deletions

View file

@ -436,7 +436,7 @@ if __name__ == "__main__":
migratecfg.migrate() migratecfg.migrate()
# Logging # Logging
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) nzbtomedia_configure_logging(LOG_FILE)
Logger = logging.getLogger(__name__) Logger = logging.getLogger(__name__)
Logger.info("====================") # Seperate old from new log Logger.info("====================") # Seperate old from new log

View file

@ -28,9 +28,9 @@ def safeName(name):
return safename return safename
def nzbtomedia_configure_logging(dirname): def nzbtomedia_configure_logging(logfile):
logging.config.fileConfig(CONFIG_FILE) logging.config.fileConfig(CONFIG_FILE)
fileHandler = logging.handlers.RotatingFileHandler(LOG_FILE, mode='a', maxBytes=1048576, backupCount=1, encoding='utf-8', delay=True) fileHandler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=1048576, backupCount=1, encoding='utf-8', delay=True)
fileHandler.formatter = logging.Formatter('%(asctime)s|%(levelname)-7.7s %(message)s', '%H:%M:%S') fileHandler.formatter = logging.Formatter('%(asctime)s|%(levelname)-7.7s %(message)s', '%H:%M:%S')
fileHandler.level = logging.DEBUG fileHandler.level = logging.DEBUG
logging.getLogger().addHandler(fileHandler) logging.getLogger().addHandler(fileHandler)

View file

@ -135,7 +135,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
if os.environ.has_key('NZBOP_SCRIPTDIR'): if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg.addnzbget() migratecfg.addnzbget()
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) nzbtomedia_configure_logging(LOG_FILE)
Logger = logging.getLogger(__name__) Logger = logging.getLogger(__name__)
Logger.info("====================") # Seperate old from new log Logger.info("====================") # Seperate old from new log

View file

@ -71,7 +71,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
if os.environ.has_key('NZBOP_SCRIPTDIR'): if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg.addnzbget() migratecfg.addnzbget()
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) nzbtomedia_configure_logging(LOG_FILE)
Logger = logging.getLogger(__name__) Logger = logging.getLogger(__name__)
Logger.info("====================") # Seperate old from new log Logger.info("====================") # Seperate old from new log

View file

@ -81,7 +81,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
if os.environ.has_key('NZBOP_SCRIPTDIR'): if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg.addnzbget() migratecfg.addnzbget()
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) nzbtomedia_configure_logging(LOG_FILE)
Logger = logging.getLogger(__name__) Logger = logging.getLogger(__name__)
Logger.info("====================") # Seperate old from new log Logger.info("====================") # Seperate old from new log

View file

@ -297,10 +297,10 @@ elif config():
migratecfg.migrate() migratecfg.migrate()
# check to write settings from nzbGet UI to autoProcessMedia.cfg. # check to write settings from nzbGet UI to autoProcessMedia.cfg.
if os.environ.has_key('NZBOP_SCRIPTDIR'): if config() and os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg.addnzbget() migratecfg.addnzbget()
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) nzbtomedia_configure_logging(LOG_FILE)
Logger = logging.getLogger(__name__) Logger = logging.getLogger(__name__)
Logger.info("====================") # Seperate old from new log Logger.info("====================") # Seperate old from new log

View file

@ -74,7 +74,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
if os.environ.has_key('NZBOP_SCRIPTDIR'): if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg.addnzbget() migratecfg.addnzbget()
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) nzbtomedia_configure_logging(LOG_FILE)
Logger = logging.getLogger(__name__) Logger = logging.getLogger(__name__)
Logger.info("====================") # Seperate old from new log Logger.info("====================") # Seperate old from new log

View file

@ -138,7 +138,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
if os.environ.has_key('NZBOP_SCRIPTDIR'): if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg.addnzbget() migratecfg.addnzbget()
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) nzbtomedia_configure_logging(LOG_FILE)
Logger = logging.getLogger(__name__) Logger = logging.getLogger(__name__)
Logger.info("====================") # Seperate old from new log Logger.info("====================") # Seperate old from new log