From d137ef15276fa6697a01fb6231ad84c4d6a4c5ad Mon Sep 17 00:00:00 2001 From: Tobias Specht Date: Wed, 24 Jul 2024 14:21:24 +0200 Subject: [PATCH] fix(logger): use name instead of file for logger base --- docs/logging.md | 2 +- src/gallia/command/base.py | 2 +- src/gallia/command/uds.py | 2 +- src/gallia/commands/discover/doip.py | 2 +- src/gallia/commands/discover/find_xcp.py | 2 +- src/gallia/commands/discover/uds/isotp.py | 2 +- src/gallia/commands/fuzz/uds/pdu.py | 2 +- src/gallia/commands/primitive/uds/dtc.py | 2 +- src/gallia/commands/primitive/uds/ecu_reset.py | 2 +- src/gallia/commands/primitive/uds/iocbi.py | 2 +- src/gallia/commands/primitive/uds/pdu.py | 2 +- src/gallia/commands/primitive/uds/ping.py | 2 +- src/gallia/commands/primitive/uds/rdbi.py | 2 +- src/gallia/commands/primitive/uds/rmba.py | 2 +- src/gallia/commands/primitive/uds/rtcl.py | 2 +- src/gallia/commands/primitive/uds/vin.py | 2 +- src/gallia/commands/primitive/uds/wdbi.py | 2 +- src/gallia/commands/primitive/uds/wmba.py | 2 +- src/gallia/commands/scan/uds/identifiers.py | 2 +- src/gallia/commands/scan/uds/memory.py | 2 +- src/gallia/commands/scan/uds/reset.py | 2 +- src/gallia/commands/scan/uds/sa_dump_seeds.py | 2 +- src/gallia/commands/scan/uds/services.py | 2 +- src/gallia/commands/scan/uds/sessions.py | 2 +- src/gallia/commands/script/vecu.py | 2 +- src/gallia/db/handler.py | 2 +- src/gallia/dumpcap.py | 2 +- src/gallia/powersupply.py | 2 +- src/gallia/services/uds/core/client.py | 2 +- src/gallia/services/uds/core/service.py | 2 +- src/gallia/services/uds/ecu.py | 2 +- src/gallia/services/uds/server.py | 2 +- src/gallia/services/xcp/__init__.py | 2 +- src/gallia/transports/base.py | 2 +- src/gallia/transports/can.py | 2 +- src/gallia/transports/doip.py | 2 +- src/gallia/transports/isotp.py | 2 +- src/gallia/transports/tcp.py | 2 +- src/gallia/transports/unix.py | 2 +- 39 files changed, 39 insertions(+), 39 deletions(-) diff --git a/docs/logging.md b/docs/logging.md index ec5308ce1..829ee186a 100644 --- a/docs/logging.md +++ b/docs/logging.md @@ -30,7 +30,7 @@ from gallia.log import get_logger, setup_logging, Loglevel # The logfile's loglevel is Loglevel.DEBUG. # It can be set with the keyword argument file_level. setup_logging(level=Loglevel.INFO) -logger = get_logger(__file__) +logger = get_logger(__name__) logger.info("hello world") logger.debug("hello debug") ``` diff --git a/src/gallia/command/base.py b/src/gallia/command/base.py index 451523cd0..c12187b55 100644 --- a/src/gallia/command/base.py +++ b/src/gallia/command/base.py @@ -68,7 +68,7 @@ def json(self) -> str: return msgspec.json.encode(self).decode() -logger = get_logger(__file__) +logger = get_logger(__name__) if sys.platform.startswith("linux") or sys.platform == "darwin": diff --git a/src/gallia/command/uds.py b/src/gallia/command/uds.py index c575b5733..147fd67ff 100644 --- a/src/gallia/command/uds.py +++ b/src/gallia/command/uds.py @@ -15,7 +15,7 @@ from gallia.services.uds.ecu import ECU from gallia.services.uds.helpers import raise_for_error -logger = get_logger(__file__) +logger = get_logger(__name__) class UDSScanner(Scanner): diff --git a/src/gallia/commands/discover/doip.py b/src/gallia/commands/discover/doip.py index fd2dc258d..a655676d3 100644 --- a/src/gallia/commands/discover/doip.py +++ b/src/gallia/commands/discover/doip.py @@ -34,7 +34,7 @@ VehicleAnnouncementMessage, ) -logger = get_logger(__file__) +logger = get_logger(__name__) class DoIPDiscoverer(AsyncScript): diff --git a/src/gallia/commands/discover/find_xcp.py b/src/gallia/commands/discover/find_xcp.py index a8b52c68c..9d0423e9e 100644 --- a/src/gallia/commands/discover/find_xcp.py +++ b/src/gallia/commands/discover/find_xcp.py @@ -16,7 +16,7 @@ from gallia.transports import RawCANTransport, TargetURI from gallia.utils import auto_int, can_id_repr -logger = get_logger(__file__) +logger = get_logger(__name__) class FindXCP(AsyncScript): diff --git a/src/gallia/commands/discover/uds/isotp.py b/src/gallia/commands/discover/uds/isotp.py index 90f517393..86dc78b56 100644 --- a/src/gallia/commands/discover/uds/isotp.py +++ b/src/gallia/commands/discover/uds/isotp.py @@ -16,7 +16,7 @@ from gallia.transports import ISOTPTransport, RawCANTransport, TargetURI from gallia.utils import auto_int, can_id_repr, write_target_list -logger = get_logger(__file__) +logger = get_logger(__name__) class IsotpDiscoverer(UDSDiscoveryScanner): diff --git a/src/gallia/commands/fuzz/uds/pdu.py b/src/gallia/commands/fuzz/uds/pdu.py index 875736223..1ec87afde 100644 --- a/src/gallia/commands/fuzz/uds/pdu.py +++ b/src/gallia/commands/fuzz/uds/pdu.py @@ -20,7 +20,7 @@ from gallia.transports import RawCANTransport, TargetURI from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class PDUFuzzer(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/dtc.py b/src/gallia/commands/primitive/uds/dtc.py index 88eb309e6..91df3ad64 100644 --- a/src/gallia/commands/primitive/uds/dtc.py +++ b/src/gallia/commands/primitive/uds/dtc.py @@ -19,7 +19,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class DTCPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/ecu_reset.py b/src/gallia/commands/primitive/uds/ecu_reset.py index b872218d2..a36df4485 100644 --- a/src/gallia/commands/primitive/uds/ecu_reset.py +++ b/src/gallia/commands/primitive/uds/ecu_reset.py @@ -11,7 +11,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class ECUResetPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/iocbi.py b/src/gallia/commands/primitive/uds/iocbi.py index 73e72f2b7..b54ef74ca 100644 --- a/src/gallia/commands/primitive/uds/iocbi.py +++ b/src/gallia/commands/primitive/uds/iocbi.py @@ -12,7 +12,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class IOCBIPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/pdu.py b/src/gallia/commands/primitive/uds/pdu.py index d49470aef..b75762b5c 100644 --- a/src/gallia/commands/primitive/uds/pdu.py +++ b/src/gallia/commands/primitive/uds/pdu.py @@ -19,7 +19,7 @@ from gallia.services.uds.helpers import raise_for_error from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class SendPDUPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/ping.py b/src/gallia/commands/primitive/uds/ping.py index 325a5745e..e0f7c5f32 100644 --- a/src/gallia/commands/primitive/uds/ping.py +++ b/src/gallia/commands/primitive/uds/ping.py @@ -11,7 +11,7 @@ from gallia.services.uds.core.service import NegativeResponse from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class PingPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/rdbi.py b/src/gallia/commands/primitive/uds/rdbi.py index 2d1e04df1..2449d3d59 100644 --- a/src/gallia/commands/primitive/uds/rdbi.py +++ b/src/gallia/commands/primitive/uds/rdbi.py @@ -10,7 +10,7 @@ from gallia.services.uds.core.service import NegativeResponse from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class ReadByIdentifierPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/rmba.py b/src/gallia/commands/primitive/uds/rmba.py index df48783c3..f87dfea36 100644 --- a/src/gallia/commands/primitive/uds/rmba.py +++ b/src/gallia/commands/primitive/uds/rmba.py @@ -11,7 +11,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class RMBAPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/rtcl.py b/src/gallia/commands/primitive/uds/rtcl.py index 28d5f11ce..5ef5ac1cc 100644 --- a/src/gallia/commands/primitive/uds/rtcl.py +++ b/src/gallia/commands/primitive/uds/rtcl.py @@ -14,7 +14,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class RTCLPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/vin.py b/src/gallia/commands/primitive/uds/vin.py index bbfebb7ef..e37030bb9 100644 --- a/src/gallia/commands/primitive/uds/vin.py +++ b/src/gallia/commands/primitive/uds/vin.py @@ -8,7 +8,7 @@ from gallia.log import get_logger from gallia.services.uds.core.service import NegativeResponse -logger = get_logger(__file__) +logger = get_logger(__name__) class VINPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/wdbi.py b/src/gallia/commands/primitive/uds/wdbi.py index da821abf5..cb5de73d1 100644 --- a/src/gallia/commands/primitive/uds/wdbi.py +++ b/src/gallia/commands/primitive/uds/wdbi.py @@ -12,7 +12,7 @@ from gallia.services.uds import NegativeResponse, UDSResponse from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class WriteByIdentifierPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/wmba.py b/src/gallia/commands/primitive/uds/wmba.py index 791749e03..84c697cd9 100644 --- a/src/gallia/commands/primitive/uds/wmba.py +++ b/src/gallia/commands/primitive/uds/wmba.py @@ -13,7 +13,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class WMBAPrimitive(UDSScanner): diff --git a/src/gallia/commands/scan/uds/identifiers.py b/src/gallia/commands/scan/uds/identifiers.py index a333da74f..f614336ab 100644 --- a/src/gallia/commands/scan/uds/identifiers.py +++ b/src/gallia/commands/scan/uds/identifiers.py @@ -21,7 +21,7 @@ from gallia.services.uds.helpers import suggests_service_not_supported from gallia.utils import ParseSkips, auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class ScanIdentifiers(UDSScanner): diff --git a/src/gallia/commands/scan/uds/memory.py b/src/gallia/commands/scan/uds/memory.py index 54fa65825..5fe64ae4d 100644 --- a/src/gallia/commands/scan/uds/memory.py +++ b/src/gallia/commands/scan/uds/memory.py @@ -12,7 +12,7 @@ from gallia.services.uds.core.utils import g_repr, uds_memory_parameters from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class MemoryFunctionsScanner(UDSScanner): diff --git a/src/gallia/commands/scan/uds/reset.py b/src/gallia/commands/scan/uds/reset.py index a33ff28be..a1fde67a5 100644 --- a/src/gallia/commands/scan/uds/reset.py +++ b/src/gallia/commands/scan/uds/reset.py @@ -18,7 +18,7 @@ from gallia.services.uds.helpers import suggests_sub_function_not_supported from gallia.utils import ParseSkips, auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class ResetScanner(UDSScanner): diff --git a/src/gallia/commands/scan/uds/sa_dump_seeds.py b/src/gallia/commands/scan/uds/sa_dump_seeds.py index a6bf07e22..95bf4c975 100644 --- a/src/gallia/commands/scan/uds/sa_dump_seeds.py +++ b/src/gallia/commands/scan/uds/sa_dump_seeds.py @@ -17,7 +17,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class SASeedsDumper(UDSScanner): diff --git a/src/gallia/commands/scan/uds/services.py b/src/gallia/commands/scan/uds/services.py index c871c746b..a87668d5b 100644 --- a/src/gallia/commands/scan/uds/services.py +++ b/src/gallia/commands/scan/uds/services.py @@ -19,7 +19,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import ParseSkips, auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class ServicesScanner(UDSScanner): diff --git a/src/gallia/commands/scan/uds/sessions.py b/src/gallia/commands/scan/uds/sessions.py index 23b4d4ddc..4ac76e796 100644 --- a/src/gallia/commands/scan/uds/sessions.py +++ b/src/gallia/commands/scan/uds/sessions.py @@ -20,7 +20,7 @@ from gallia.services.uds.core.utils import g_repr from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) class SessionsScanner(UDSScanner): diff --git a/src/gallia/commands/script/vecu.py b/src/gallia/commands/script/vecu.py index d0cde7966..2c4655bfc 100644 --- a/src/gallia/commands/script/vecu.py +++ b/src/gallia/commands/script/vecu.py @@ -23,7 +23,7 @@ dynamic_attr_prefix = "dynamic_attr_" -logger = get_logger(__file__) +logger = get_logger(__name__) class VirtualECU(AsyncScript): diff --git a/src/gallia/db/handler.py b/src/gallia/db/handler.py index f1d795b5c..0b4f07598 100644 --- a/src/gallia/db/handler.py +++ b/src/gallia/db/handler.py @@ -131,7 +131,7 @@ def bytes_repr(data: bytes) -> str: INSERT OR IGNORE INTO version VALUES('main', '{schema_version}'); """ -logger = get_logger(__file__) +logger = get_logger(__name__) class DBHandler: diff --git a/src/gallia/dumpcap.py b/src/gallia/dumpcap.py index 53aa32653..a22f6d344 100644 --- a/src/gallia/dumpcap.py +++ b/src/gallia/dumpcap.py @@ -20,7 +20,7 @@ from gallia.transports import TargetURI, TransportScheme from gallia.utils import auto_int, split_host_port -logger = get_logger(__file__) +logger = get_logger(__name__) if sys.platform.startswith("linux") or sys.platform == "darwin": diff --git a/src/gallia/powersupply.py b/src/gallia/powersupply.py index 67510d453..5edfca218 100644 --- a/src/gallia/powersupply.py +++ b/src/gallia/powersupply.py @@ -14,7 +14,7 @@ from gallia.log import get_logger from gallia.transports import TargetURI -logger = get_logger(__file__) +logger = get_logger(__name__) class PowerSupplyURI(TargetURI): diff --git a/src/gallia/services/uds/core/client.py b/src/gallia/services/uds/core/client.py index dea28c05a..4c192a661 100644 --- a/src/gallia/services/uds/core/client.py +++ b/src/gallia/services/uds/core/client.py @@ -30,7 +30,7 @@ class UDSRequestConfig: tags: list[str] | None = None -logger = get_logger(__file__) +logger = get_logger(__name__) class UDSClient: diff --git a/src/gallia/services/uds/core/service.py b/src/gallia/services/uds/core/service.py index 1dbc4fed5..23d8b121c 100644 --- a/src/gallia/services/uds/core/service.py +++ b/src/gallia/services/uds/core/service.py @@ -37,7 +37,7 @@ uds_memory_parameters, ) -logger = get_logger(__file__) +logger = get_logger(__name__) # **************** # * Base classes * diff --git a/src/gallia/services/uds/ecu.py b/src/gallia/services/uds/ecu.py index b4eed9693..a37a3ba58 100644 --- a/src/gallia/services/uds/ecu.py +++ b/src/gallia/services/uds/ecu.py @@ -45,7 +45,7 @@ def __repr__(self) -> str: return f'{type(self).__name__}({", ".join(f"{key}={g_repr(value)}" for key, value in self.__dict__.items())})' -logger = get_logger(__file__) +logger = get_logger(__name__) class ECU(UDSClient): diff --git a/src/gallia/services/uds/server.py b/src/gallia/services/uds/server.py index ae5de3a29..7bdfbd355 100644 --- a/src/gallia/services/uds/server.py +++ b/src/gallia/services/uds/server.py @@ -30,7 +30,7 @@ from gallia.services.uds.ecu import ECUState from gallia.transports import TargetURI -logger = get_logger(__file__) +logger = get_logger(__name__) class UDSServer(ABC): diff --git a/src/gallia/services/xcp/__init__.py b/src/gallia/services/xcp/__init__.py index 9eaeaba7d..e0cbb0ab0 100644 --- a/src/gallia/services/xcp/__init__.py +++ b/src/gallia/services/xcp/__init__.py @@ -12,7 +12,7 @@ from gallia.transports import BaseTransport from gallia.transports.can import RawCANTransport -logger = get_logger(__file__) +logger = get_logger(__name__) class XCPService: diff --git a/src/gallia/transports/base.py b/src/gallia/transports/base.py index 1edf045c7..c79882949 100644 --- a/src/gallia/transports/base.py +++ b/src/gallia/transports/base.py @@ -13,7 +13,7 @@ from gallia.transports.schemes import TransportScheme from gallia.utils import join_host_port -logger = get_logger(__file__) +logger = get_logger(__name__) class TargetURI: diff --git a/src/gallia/transports/can.py b/src/gallia/transports/can.py index cd4e2e006..9b938db3f 100644 --- a/src/gallia/transports/can.py +++ b/src/gallia/transports/can.py @@ -18,7 +18,7 @@ from gallia.transports.base import BaseTransport, TargetURI from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) CANFD_MTU = 72 CAN_MTU = 16 diff --git a/src/gallia/transports/doip.py b/src/gallia/transports/doip.py index 142bdd3bd..4117093a8 100644 --- a/src/gallia/transports/doip.py +++ b/src/gallia/transports/doip.py @@ -17,7 +17,7 @@ from gallia.transports.base import BaseTransport, TargetURI from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) @unique diff --git a/src/gallia/transports/isotp.py b/src/gallia/transports/isotp.py index 4f80a6560..d406f5b92 100644 --- a/src/gallia/transports/isotp.py +++ b/src/gallia/transports/isotp.py @@ -17,7 +17,7 @@ from gallia.transports.base import BaseTransport, TargetURI from gallia.utils import auto_int -logger = get_logger(__file__) +logger = get_logger(__name__) # Socket Constants not available in the socket module, # see linux/can/isotp.h diff --git a/src/gallia/transports/tcp.py b/src/gallia/transports/tcp.py index 44f6f585e..0a640c2ae 100644 --- a/src/gallia/transports/tcp.py +++ b/src/gallia/transports/tcp.py @@ -10,7 +10,7 @@ from gallia.log import get_logger from gallia.transports.base import BaseTransport, LinesTransportMixin, TargetURI -logger = get_logger(__file__) +logger = get_logger(__name__) class TCPTransport(BaseTransport, scheme="tcp"): diff --git a/src/gallia/transports/unix.py b/src/gallia/transports/unix.py index b9d531a0b..14d41ad43 100644 --- a/src/gallia/transports/unix.py +++ b/src/gallia/transports/unix.py @@ -11,7 +11,7 @@ from gallia.log import get_logger from gallia.transports.base import BaseTransport, LinesTransportMixin, TargetURI -logger = get_logger(__file__) +logger = get_logger(__name__) class UnixTransport(BaseTransport, scheme="unix"):