forked from LBRYCommunity/lbry-sdk
improve logging
This commit is contained in:
parent
f9ed9a4505
commit
9b1d5213a6
2 changed files with 11 additions and 4 deletions
|
@ -62,15 +62,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"""
|
||||
|
|
|
@ -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()
|
||||
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()
|
||||
|
|
Loading…
Reference in a new issue