Merge pull request #122 from lbryio/add-debug-logging

Add debug logging
This commit is contained in:
Jack Robison 2016-08-17 01:33:07 -04:00 committed by GitHub
commit c061fe091b
4 changed files with 18 additions and 13 deletions

View file

@ -1,8 +1,2 @@
import logging
log = logging.getLogger(__name__)
logging.getLogger(__name__).addHandler(logging.NullHandler())
log.setLevel(logging.INFO)
__version__ = "0.3.17"
version = tuple(__version__.split('.'))

View file

@ -55,18 +55,28 @@ def _log_decorator(fn):
def helper(*args, **kwargs):
log = kwargs.pop('log', logging.getLogger())
level = kwargs.pop('level', logging.INFO)
if not isinstance(level, int):
# despite the name, getLevelName returns
# the numeric level when passed a text level
level = logging.getLevelName(level)
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"""

View file

@ -240,9 +240,9 @@ class Node(object):
known_nodes = {}
def log_error(err, n):
log.error("error storing blob_hash %s at %s", binascii.hexlify(blob_hash), str(n))
log.error(err.getErrorMessage())
log.error(err.getTraceback())
log.debug("error storing blob_hash %s at %s", binascii.hexlify(blob_hash), str(n))
log.debug(err.getErrorMessage())
log.debug(err.getTraceback())
def log_success(res):
log.debug("Response to store request: %s", str(res))

View file

@ -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()