forked from LBRYCommunity/lbry-sdk
improve logging
This commit is contained in:
parent
80f27f2b29
commit
623fda3087
3 changed files with 12 additions and 4 deletions
|
@ -58,15 +58,21 @@ def _log_decorator(fn):
|
||||||
handler = fn(*args, **kwargs)
|
handler = fn(*args, **kwargs)
|
||||||
if handler.name:
|
if handler.name:
|
||||||
remove_handlers(log, handler.name)
|
remove_handlers(log, handler.name)
|
||||||
|
handler.setLevel(level)
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
log.setLevel(level)
|
if log.level > level:
|
||||||
|
log.setLevel(level)
|
||||||
return helper
|
return helper
|
||||||
|
|
||||||
|
|
||||||
def disable_noisy_loggers():
|
def disable_third_party_loggers():
|
||||||
logging.getLogger('requests').setLevel(logging.WARNING)
|
logging.getLogger('requests').setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
|
||||||
|
def disable_noisy_loggers():
|
||||||
|
logging.getLogger('lbrynet.dht').setLevel(logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
@_log_decorator
|
@_log_decorator
|
||||||
def configure_console(**kwargs):
|
def configure_console(**kwargs):
|
||||||
"""Convenience function to configure a logger that outputs to stdout"""
|
"""Convenience function to configure a logger that outputs to stdout"""
|
||||||
|
|
|
@ -73,11 +73,12 @@ def start():
|
||||||
parser.set_defaults(branch=False, launchui=True, logtoconsole=False, quiet=False)
|
parser.set_defaults(branch=False, launchui=True, logtoconsole=False, quiet=False)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
log_support.disable_noisy_loggers()
|
|
||||||
log_support.configure_file_handler(lbrynet_log)
|
log_support.configure_file_handler(lbrynet_log)
|
||||||
log_support.configure_loggly_handler()
|
log_support.configure_loggly_handler()
|
||||||
if args.logtoconsole:
|
if args.logtoconsole:
|
||||||
log_support.configure_console(level='DEBUG')
|
log_support.configure_console(level='DEBUG')
|
||||||
|
log_support.disable_third_party_loggers()
|
||||||
|
log_support.disable_noisy_loggers()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
JSONRPCProxy.from_url(API_CONNECTION_STRING).is_running()
|
JSONRPCProxy.from_url(API_CONNECTION_STRING).is_running()
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ReflectorServer(Protocol):
|
||||||
|
|
||||||
def connectionMade(self):
|
def connectionMade(self):
|
||||||
peer_info = self.transport.getPeer()
|
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.peer = self.factory.peer_manager.get_peer(peer_info.host, peer_info.port)
|
||||||
self.blob_manager = self.factory.blob_manager
|
self.blob_manager = self.factory.blob_manager
|
||||||
self.received_handshake = False
|
self.received_handshake = False
|
||||||
|
@ -45,7 +46,7 @@ class ReflectorServer(Protocol):
|
||||||
extra_data = None
|
extra_data = None
|
||||||
response = None
|
response = None
|
||||||
curr_pos = 0
|
curr_pos = 0
|
||||||
while 1:
|
while True:
|
||||||
next_close_paren = response_msg.find('}', curr_pos)
|
next_close_paren = response_msg.find('}', curr_pos)
|
||||||
if next_close_paren != -1:
|
if next_close_paren != -1:
|
||||||
curr_pos = next_close_paren + 1
|
curr_pos = next_close_paren + 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue