From 324b88e099cb2ec7c0d82ceb11c4c3175695567a Mon Sep 17 00:00:00 2001 From: fametrano Date: Wed, 2 Aug 2023 21:59:10 +0200 Subject: [PATCH 1/2] nest loggers in the proper way --- hwilib/devices/jadepy/jade.py | 4 ++-- hwilib/devices/jadepy/jade_serial.py | 2 +- hwilib/devices/jadepy/jade_tcp.py | 2 +- hwilib/devices/ledger_bitcoin/ledgercomm/log.py | 2 +- hwilib/devices/trezorlib/log.py | 2 +- test/authproxy.py | 2 +- test/test_jade.py | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hwilib/devices/jadepy/jade.py b/hwilib/devices/jadepy/jade.py index 4db212163..3ea523c35 100644 --- a/hwilib/devices/jadepy/jade.py +++ b/hwilib/devices/jadepy/jade.py @@ -17,8 +17,8 @@ from .jade_tcp import JadeTCPImpl # 'jade' logger -logger = logging.getLogger('jade') -device_logger = logging.getLogger('jade-device') +logger = logging.getLogger(__name__) +device_logger = logging.getLogger(f'{__name__}-device') # Default serial connection diff --git a/hwilib/devices/jadepy/jade_serial.py b/hwilib/devices/jadepy/jade_serial.py index 0a6fc2be5..615ea0275 100644 --- a/hwilib/devices/jadepy/jade_serial.py +++ b/hwilib/devices/jadepy/jade_serial.py @@ -2,7 +2,7 @@ import logging -logger = logging.getLogger('jade.serial') +logger = logging.getLogger(__name__) # diff --git a/hwilib/devices/jadepy/jade_tcp.py b/hwilib/devices/jadepy/jade_tcp.py index a76d5001d..84d9cc82a 100644 --- a/hwilib/devices/jadepy/jade_tcp.py +++ b/hwilib/devices/jadepy/jade_tcp.py @@ -2,7 +2,7 @@ import logging -logger = logging.getLogger('jade.tcp') +logger = logging.getLogger(__name__) # diff --git a/hwilib/devices/ledger_bitcoin/ledgercomm/log.py b/hwilib/devices/ledger_bitcoin/ledgercomm/log.py index ecfe18127..0fc8eff02 100644 --- a/hwilib/devices/ledger_bitcoin/ledgercomm/log.py +++ b/hwilib/devices/ledger_bitcoin/ledgercomm/log.py @@ -2,4 +2,4 @@ import logging -LOG = logging.getLogger("ledgercomm") +LOG = logging.getLogger(__name__) diff --git a/hwilib/devices/trezorlib/log.py b/hwilib/devices/trezorlib/log.py index 9cc4a6b9a..2b63df2d4 100644 --- a/hwilib/devices/trezorlib/log.py +++ b/hwilib/devices/trezorlib/log.py @@ -70,6 +70,6 @@ def enable_debug_output( if verbosity > 2: level = DUMP_PACKETS - logger = logging.getLogger("trezorlib") + logger = logging.getLogger(__name__) logger.setLevel(level) logger.addHandler(handler) diff --git a/test/authproxy.py b/test/authproxy.py index 4ba6ac1db..950a6f608 100644 --- a/test/authproxy.py +++ b/test/authproxy.py @@ -47,7 +47,7 @@ HTTP_TIMEOUT = 30 USER_AGENT = "AuthServiceProxy/0.1" -log = logging.getLogger("BitcoinRPC") +log = logging.getLogger(__name__) class JSONRPCException(Exception): def __init__(self, rpc_error, http_status=None): diff --git a/test/test_jade.py b/test/test_jade.py index 9670ffee2..9e8e57220 100755 --- a/test/test_jade.py +++ b/test/test_jade.py @@ -31,9 +31,9 @@ # Enable jade logging if LOGGING: - logger = logging.getLogger('jade') + logger = logging.getLogger("hwilib.devices.jadepy.jade") logger.setLevel(LOGGING) - device_logger = logging.getLogger('jade-device') + device_logger = logging.getLogger("hwilib.devices.jadepy.jade-device") device_logger.setLevel(LOGGING) class JadeEmulator(DeviceEmulator): From 75af80b0695f9b08c6df356a6548c627b3c8eb9b Mon Sep 17 00:00:00 2001 From: fametrano Date: Wed, 2 Aug 2023 22:46:13 +0200 Subject: [PATCH 2/2] present naming preference (without trailing .log) --- hwilib/devices/ledger_bitcoin/ledgercomm/log.py | 2 +- hwilib/devices/trezorlib/log.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hwilib/devices/ledger_bitcoin/ledgercomm/log.py b/hwilib/devices/ledger_bitcoin/ledgercomm/log.py index 0fc8eff02..6fbd23159 100644 --- a/hwilib/devices/ledger_bitcoin/ledgercomm/log.py +++ b/hwilib/devices/ledger_bitcoin/ledgercomm/log.py @@ -2,4 +2,4 @@ import logging -LOG = logging.getLogger(__name__) +LOG = logging.getLogger(__name__.rsplit(".", 1)[0]) diff --git a/hwilib/devices/trezorlib/log.py b/hwilib/devices/trezorlib/log.py index 2b63df2d4..6a6c3717c 100644 --- a/hwilib/devices/trezorlib/log.py +++ b/hwilib/devices/trezorlib/log.py @@ -70,6 +70,6 @@ def enable_debug_output( if verbosity > 2: level = DUMP_PACKETS - logger = logging.getLogger(__name__) + logger = logging.getLogger(__name__.rsplit(".", 1)[0]) logger.setLevel(level) logger.addHandler(handler)