From 623fda3087ad31ea9d8c72f82c1d2c909688d038 Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Thu, 11 Aug 2016 05:14:21 +0000 Subject: [PATCH] improve logging --- lbrynet/core/log_support.py | 10 ++++++++-- lbrynet/lbrynet_daemon/LBRYDaemonControl.py | 3 ++- lbrynet/reflector/server/server.py | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lbrynet/core/log_support.py b/lbrynet/core/log_support.py index 50fb35e83..f393a3210 100644 --- a/lbrynet/core/log_support.py +++ b/lbrynet/core/log_support.py @@ -58,15 +58,21 @@ def _log_decorator(fn): handler = fn(*args, **kwargs) if handler.name: remove_handlers(log, handler.name) + handler.setLevel(level) log.addHandler(handler) - log.setLevel(level) + if log.level > level: + log.setLevel(level) return helper -def disable_noisy_loggers(): +def disable_third_party_loggers(): logging.getLogger('requests').setLevel(logging.WARNING) +def disable_noisy_loggers(): + logging.getLogger('lbrynet.dht').setLevel(logging.INFO) + + @_log_decorator def configure_console(**kwargs): """Convenience function to configure a logger that outputs to stdout""" diff --git a/lbrynet/lbrynet_daemon/LBRYDaemonControl.py b/lbrynet/lbrynet_daemon/LBRYDaemonControl.py index 76cbe5152..ce4b0f54a 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemonControl.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemonControl.py @@ -73,11 +73,12 @@ def start(): parser.set_defaults(branch=False, launchui=True, logtoconsole=False, quiet=False) args = parser.parse_args() - log_support.disable_noisy_loggers() log_support.configure_file_handler(lbrynet_log) log_support.configure_loggly_handler() if args.logtoconsole: log_support.configure_console(level='DEBUG') + log_support.disable_third_party_loggers() + log_support.disable_noisy_loggers() try: JSONRPCProxy.from_url(API_CONNECTION_STRING).is_running() diff --git a/lbrynet/reflector/server/server.py b/lbrynet/reflector/server/server.py index d2569b6aa..fc015cbf6 100644 --- a/lbrynet/reflector/server/server.py +++ b/lbrynet/reflector/server/server.py @@ -14,6 +14,7 @@ class ReflectorServer(Protocol): def connectionMade(self): peer_info = self.transport.getPeer() + log.debug('Connection made to %s', peer_info) self.peer = self.factory.peer_manager.get_peer(peer_info.host, peer_info.port) self.blob_manager = self.factory.blob_manager self.received_handshake = False @@ -45,7 +46,7 @@ class ReflectorServer(Protocol): extra_data = None response = None curr_pos = 0 - while 1: + while True: next_close_paren = response_msg.find('}', curr_pos) if next_close_paren != -1: curr_pos = next_close_paren + 1