From 09297b853b4c18fff1dc4f451e26047de71d0744 Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 16 Jun 2014 17:48:22 -0700 Subject: [PATCH 1/5] Fix for autoreload issues --- SickBeard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SickBeard.py b/SickBeard.py index ad2fb4ca..aa0a4c6b 100755 --- a/SickBeard.py +++ b/SickBeard.py @@ -60,6 +60,7 @@ from sickbeard import db from sickbeard.tv import TVShow from sickbeard import logger from sickbeard import webserveInit +from sickbeard import autoreload_shutdown from sickbeard.version import SICKBEARD_VERSION from sickbeard.databases.mainDB import MIN_DB_VERSION from sickbeard.databases.mainDB import MAX_DB_VERSION @@ -390,7 +391,7 @@ def main(): # autoreload. if sickbeard.AUTO_UPDATE: tornado.autoreload.start(io_loop) - tornado.autoreload.add_reload_hook(sickbeard.autoreload_shutdown) + tornado.autoreload.add_reload_hook(autoreload_shutdown) # start IOLoop. io_loop.start() From c57e34c9f9c0b2339e3e80fb33dc2cb8acf1b07e Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 16 Jun 2014 19:55:46 -0700 Subject: [PATCH 2/5] Added logging for tornado web server for helping in debugging issues. --- sickbeard/logger.py | 18 ++++++++++++++++-- sickbeard/webserveInit.py | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sickbeard/logger.py b/sickbeard/logger.py index 987cfe8d..60c3435c 100644 --- a/sickbeard/logger.py +++ b/sickbeard/logger.py @@ -71,10 +71,12 @@ class SBRotatingLogHandler(object): sb_logger = logging.getLogger('sickbeard') sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') + tornado_logger = logging.getLogger('tornado') sb_logger.removeHandler(handler) sub_logger.removeHandler(handler) imdb_logger.removeHandler(handler) + tornado_logger.removeHandler(handler) handler.flush() handler.close() @@ -108,12 +110,16 @@ class SBRotatingLogHandler(object): {'sickbeard': logging.Formatter('%(asctime)s %(levelname)s::%(message)s', '%H:%M:%S'), 'subliminal': logging.Formatter('%(asctime)s %(levelname)s::SUBLIMINAL :: %(message)s', '%H:%M:%S'), - 'imdbpy': logging.Formatter('%(asctime)s %(levelname)s::IMDBPY :: %(message)s', '%H:%M:%S') + 'imdbpy': logging.Formatter('%(asctime)s %(levelname)s::IMDBPY :: %(message)s', '%H:%M:%S'), + 'tornado.access': logging.Formatter('%(asctime)s %(levelname)s::TORNADO :: %(message)s', '%H:%M:%S'), + 'tornado.general': logging.Formatter('%(asctime)s %(levelname)s::TORNADO :: %(message)s', '%H:%M:%S'), + 'tornado.application': logging.Formatter('%(asctime)s %(levelname)s::TORNADO :: %(message)s', '%H:%M:%S') }, logging.Formatter('%(message)s'), )) # add the handler to the root logger logging.getLogger('sickbeard').addHandler(console) + logging.getLogger('tornado').addHandler(console) logging.getLogger('subliminal').addHandler(console) logging.getLogger('imdbpy').addHandler(console) @@ -121,10 +127,12 @@ class SBRotatingLogHandler(object): self.cur_handler = self._config_handler() logging.getLogger('sickbeard').addHandler(self.cur_handler) + logging.getLogger('tornado').addHandler(self.cur_handler) logging.getLogger('subliminal').addHandler(self.cur_handler) logging.getLogger('imdbpy').addHandler(self.cur_handler) logging.getLogger('sickbeard').setLevel(DB) + logging.getLogger('tornado').setLevel(logging.WARNING) logging.getLogger('subliminal').setLevel(logging.WARNING) logging.getLogger('imdbpy').setLevel(logging.WARNING) @@ -151,7 +159,10 @@ class SBRotatingLogHandler(object): {'sickbeard': logging.Formatter('%(asctime)s %(levelname)-8s %(message)s', '%Y-%m-%d %H:%M:%S'), 'subliminal': logging.Formatter('%(asctime)s %(levelname)-8s SUBLIMINAL :: %(message)s', '%Y-%m-%d %H:%M:%S'), - 'imdbpy': logging.Formatter('%(asctime)s %(levelname)-8s IMDBPY :: %(message)s', '%Y-%m-%d %H:%M:%S') + 'imdbpy': logging.Formatter('%(asctime)s %(levelname)-8s IMDBPY :: %(message)s', '%Y-%m-%d %H:%M:%S'), + #'tornado.access': logging.Formatter('%(asctime)s %(levelname)-8s TORNADO :: %(message)s','%Y-%m-%d %H:%M:%S'), + 'tornado.general': logging.Formatter('%(asctime)s %(levelname)-8s TORNADO :: %(message)s', '%Y-%m-%d %H:%M:%S'), + 'tornado.application': logging.Formatter('%(asctime)s %(levelname)-8s TORNADO :: %(message)s', '%Y-%m-%d %H:%M:%S') }, logging.Formatter('%(message)s'), )) @@ -184,6 +195,7 @@ class SBRotatingLogHandler(object): sb_logger = logging.getLogger('sickbeard') sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') + tornado_logger = logging.getLogger('tornado') # delete the old handler if self.cur_handler: @@ -208,6 +220,7 @@ class SBRotatingLogHandler(object): sb_logger.addHandler(new_file_handler) sub_logger.addHandler(new_file_handler) imdb_logger.addHandler(new_file_handler) + tornado_logger.addHandler(new_file_handler) def log(self, toLog, logLevel=MESSAGE): @@ -231,6 +244,7 @@ class SBRotatingLogHandler(object): sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') + tornado_logger = logging.getLogger('tornado') try: if logLevel == DEBUG: diff --git a/sickbeard/webserveInit.py b/sickbeard/webserveInit.py index 9644953f..00048311 100644 --- a/sickbeard/webserveInit.py +++ b/sickbeard/webserveInit.py @@ -4,6 +4,7 @@ import sickbeard import webserve import webapi +import tornado.options from sickbeard import logger from sickbeard.helpers import create_https_certificates from tornado.web import Application, StaticFileHandler, RedirectHandler, HTTPError @@ -97,7 +98,6 @@ def initWebServer(options={}): # Load the app app = Application([], - log_function=lambda x: None, debug=False, gzip=True, autoreload=sickbeard.AUTO_UPDATE, From 98e4710d89cc006d033976e7ec286d13cd583564 Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 16 Jun 2014 19:59:35 -0700 Subject: [PATCH 3/5] Setting debug = 1 in config now sets log level to debug for all processes --- sickbeard/logger.py | 11 ++++++++--- sickbeard/webserveInit.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sickbeard/logger.py b/sickbeard/logger.py index 60c3435c..6f9d23d8 100644 --- a/sickbeard/logger.py +++ b/sickbeard/logger.py @@ -132,9 +132,14 @@ class SBRotatingLogHandler(object): logging.getLogger('imdbpy').addHandler(self.cur_handler) logging.getLogger('sickbeard').setLevel(DB) - logging.getLogger('tornado').setLevel(logging.WARNING) - logging.getLogger('subliminal').setLevel(logging.WARNING) - logging.getLogger('imdbpy').setLevel(logging.WARNING) + + log_level = logging.WARNING + if sickbeard.DEBUG: + log_level = logging.DEBUG + + logging.getLogger('tornado').setLevel(log_level) + logging.getLogger('subliminal').setLevel(log_level) + logging.getLogger('imdbpy').setLevel(log_level) # already logging in new log folder, close the old handler if old_handler: diff --git a/sickbeard/webserveInit.py b/sickbeard/webserveInit.py index 00048311..1be54a56 100644 --- a/sickbeard/webserveInit.py +++ b/sickbeard/webserveInit.py @@ -98,7 +98,7 @@ def initWebServer(options={}): # Load the app app = Application([], - debug=False, + debug=sickbeard.DEBUG, gzip=True, autoreload=sickbeard.AUTO_UPDATE, xheaders=True, From 53e7c53b8afd9c1cdc00b58667b5556892f511d9 Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 16 Jun 2014 20:24:07 -0700 Subject: [PATCH 4/5] Disabled logging of tornado.access --- sickbeard/logger.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sickbeard/logger.py b/sickbeard/logger.py index 6f9d23d8..98201a92 100644 --- a/sickbeard/logger.py +++ b/sickbeard/logger.py @@ -71,12 +71,14 @@ class SBRotatingLogHandler(object): sb_logger = logging.getLogger('sickbeard') sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') - tornado_logger = logging.getLogger('tornado') + tornado_general_logger = logging.getLogger('tornado.general') + tornado_application_logger = logging.getLogger('tornado.application') sb_logger.removeHandler(handler) sub_logger.removeHandler(handler) imdb_logger.removeHandler(handler) - tornado_logger.removeHandler(handler) + tornado_general_logger.removeHandler(handler) + tornado_application_logger.removeHandler(handler) handler.flush() handler.close() @@ -111,7 +113,6 @@ class SBRotatingLogHandler(object): 'subliminal': logging.Formatter('%(asctime)s %(levelname)s::SUBLIMINAL :: %(message)s', '%H:%M:%S'), 'imdbpy': logging.Formatter('%(asctime)s %(levelname)s::IMDBPY :: %(message)s', '%H:%M:%S'), - 'tornado.access': logging.Formatter('%(asctime)s %(levelname)s::TORNADO :: %(message)s', '%H:%M:%S'), 'tornado.general': logging.Formatter('%(asctime)s %(levelname)s::TORNADO :: %(message)s', '%H:%M:%S'), 'tornado.application': logging.Formatter('%(asctime)s %(levelname)s::TORNADO :: %(message)s', '%H:%M:%S') }, @@ -119,7 +120,8 @@ class SBRotatingLogHandler(object): # add the handler to the root logger logging.getLogger('sickbeard').addHandler(console) - logging.getLogger('tornado').addHandler(console) + logging.getLogger('tornado.general').addHandler(console) + logging.getLogger('tornado.application').addHandler(console) logging.getLogger('subliminal').addHandler(console) logging.getLogger('imdbpy').addHandler(console) @@ -127,7 +129,8 @@ class SBRotatingLogHandler(object): self.cur_handler = self._config_handler() logging.getLogger('sickbeard').addHandler(self.cur_handler) - logging.getLogger('tornado').addHandler(self.cur_handler) + logging.getLogger('tornado.general').addHandler(self.cur_handler) + logging.getLogger('tornado.application').addHandler(self.cur_handler) logging.getLogger('subliminal').addHandler(self.cur_handler) logging.getLogger('imdbpy').addHandler(self.cur_handler) @@ -137,7 +140,8 @@ class SBRotatingLogHandler(object): if sickbeard.DEBUG: log_level = logging.DEBUG - logging.getLogger('tornado').setLevel(log_level) + logging.getLogger('tornado.general').setLevel(log_level) + logging.getLogger('tornado.application').setLevel(log_level) logging.getLogger('subliminal').setLevel(log_level) logging.getLogger('imdbpy').setLevel(log_level) @@ -165,7 +169,6 @@ class SBRotatingLogHandler(object): 'subliminal': logging.Formatter('%(asctime)s %(levelname)-8s SUBLIMINAL :: %(message)s', '%Y-%m-%d %H:%M:%S'), 'imdbpy': logging.Formatter('%(asctime)s %(levelname)-8s IMDBPY :: %(message)s', '%Y-%m-%d %H:%M:%S'), - #'tornado.access': logging.Formatter('%(asctime)s %(levelname)-8s TORNADO :: %(message)s','%Y-%m-%d %H:%M:%S'), 'tornado.general': logging.Formatter('%(asctime)s %(levelname)-8s TORNADO :: %(message)s', '%Y-%m-%d %H:%M:%S'), 'tornado.application': logging.Formatter('%(asctime)s %(levelname)-8s TORNADO :: %(message)s', '%Y-%m-%d %H:%M:%S') }, @@ -200,7 +203,8 @@ class SBRotatingLogHandler(object): sb_logger = logging.getLogger('sickbeard') sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') - tornado_logger = logging.getLogger('tornado') + tornado_general_logger = logging.getLogger('tornado.general') + tornado_application_logger = logging.getLogger('tornado.application') # delete the old handler if self.cur_handler: @@ -225,7 +229,8 @@ class SBRotatingLogHandler(object): sb_logger.addHandler(new_file_handler) sub_logger.addHandler(new_file_handler) imdb_logger.addHandler(new_file_handler) - tornado_logger.addHandler(new_file_handler) + tornado_general_logger.addHandler(new_file_handler) + tornado_application_logger.addHandler(new_file_handler) def log(self, toLog, logLevel=MESSAGE): @@ -249,7 +254,8 @@ class SBRotatingLogHandler(object): sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') - tornado_logger = logging.getLogger('tornado') + tornado_general_logger = logging.getLogger('tornado.general') + tornado_application_logger = logging.getLogger('tornado.application') try: if logLevel == DEBUG: From 38edbc8b8b2360f4733b77c0a2420071e6e0b55b Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 16 Jun 2014 20:35:52 -0700 Subject: [PATCH 5/5] Logging for tornado.access is now sent to NullHandler so it doesnt complain that it has no handler, still disables logging for tornado.access --- sickbeard/logger.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sickbeard/logger.py b/sickbeard/logger.py index 98201a92..368dbf30 100644 --- a/sickbeard/logger.py +++ b/sickbeard/logger.py @@ -71,14 +71,12 @@ class SBRotatingLogHandler(object): sb_logger = logging.getLogger('sickbeard') sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') - tornado_general_logger = logging.getLogger('tornado.general') - tornado_application_logger = logging.getLogger('tornado.application') + tornado_logger = logging.getLogger('tornado') sb_logger.removeHandler(handler) sub_logger.removeHandler(handler) imdb_logger.removeHandler(handler) - tornado_general_logger.removeHandler(handler) - tornado_application_logger.removeHandler(handler) + tornado_logger.removeHandler(handler) handler.flush() handler.close() @@ -145,6 +143,9 @@ class SBRotatingLogHandler(object): logging.getLogger('subliminal').setLevel(log_level) logging.getLogger('imdbpy').setLevel(log_level) + # send logging to null + logging.getLogger('tornado.access').addHandler(logging.NullHandler()) + # already logging in new log folder, close the old handler if old_handler: self.close_log(old_handler) @@ -203,8 +204,7 @@ class SBRotatingLogHandler(object): sb_logger = logging.getLogger('sickbeard') sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') - tornado_general_logger = logging.getLogger('tornado.general') - tornado_application_logger = logging.getLogger('tornado.application') + tornado_logger = logging.getLogger('tornado') # delete the old handler if self.cur_handler: @@ -229,8 +229,7 @@ class SBRotatingLogHandler(object): sb_logger.addHandler(new_file_handler) sub_logger.addHandler(new_file_handler) imdb_logger.addHandler(new_file_handler) - tornado_general_logger.addHandler(new_file_handler) - tornado_application_logger.addHandler(new_file_handler) + tornado_logger.addHandler(new_file_handler) def log(self, toLog, logLevel=MESSAGE): @@ -254,8 +253,7 @@ class SBRotatingLogHandler(object): sub_logger = logging.getLogger('subliminal') imdb_logger = logging.getLogger('imdbpy') - tornado_general_logger = logging.getLogger('tornado.general') - tornado_application_logger = logging.getLogger('tornado.application') + tornado_logger = logging.getLogger('tornado') try: if logLevel == DEBUG: