From eb79f786e2cef99fea2dd706bc33a3eebb437e62 Mon Sep 17 00:00:00 2001 From: Stefan Tatschner Date: Wed, 17 Jul 2024 14:54:38 +0200 Subject: [PATCH] chore: Cleanup logger creation Run: $ rg -l 'get_logger\(".*"\)' | xargs sed -iE 's|get_logger(".*")|get_logger(__file__)|' get_logger(__file__) does what you expect without typos. --- 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 58c5e236f..ec5308ce1 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("test") +logger = get_logger(__file__) logger.info("hello world") logger.debug("hello debug") ``` diff --git a/src/gallia/command/base.py b/src/gallia/command/base.py index 2e58aa0e4..451523cd0 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("gallia.base") +logger = get_logger(__file__) if sys.platform.startswith("linux") or sys.platform == "darwin": diff --git a/src/gallia/command/uds.py b/src/gallia/command/uds.py index 9b8fe38b8..c575b5733 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("gallia.base.udsscan") +logger = get_logger(__file__) class UDSScanner(Scanner): diff --git a/src/gallia/commands/discover/doip.py b/src/gallia/commands/discover/doip.py index 31e31c0e7..fd2dc258d 100644 --- a/src/gallia/commands/discover/doip.py +++ b/src/gallia/commands/discover/doip.py @@ -34,7 +34,7 @@ VehicleAnnouncementMessage, ) -logger = get_logger("gallia.discover.doip") +logger = get_logger(__file__) class DoIPDiscoverer(AsyncScript): diff --git a/src/gallia/commands/discover/find_xcp.py b/src/gallia/commands/discover/find_xcp.py index 555a6781e..a8b52c68c 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("gallia.discover.xcp") +logger = get_logger(__file__) class FindXCP(AsyncScript): diff --git a/src/gallia/commands/discover/uds/isotp.py b/src/gallia/commands/discover/uds/isotp.py index 5ee5c89ab..90f517393 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("gallia.discover.isotp") +logger = get_logger(__file__) class IsotpDiscoverer(UDSDiscoveryScanner): diff --git a/src/gallia/commands/fuzz/uds/pdu.py b/src/gallia/commands/fuzz/uds/pdu.py index e7a1d9a71..875736223 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("gallia.fuzz.uds") +logger = get_logger(__file__) class PDUFuzzer(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/dtc.py b/src/gallia/commands/primitive/uds/dtc.py index a510f5a97..88eb309e6 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("gallia.primitive.dtc") +logger = get_logger(__file__) class DTCPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/ecu_reset.py b/src/gallia/commands/primitive/uds/ecu_reset.py index 69c092335..b872218d2 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("gallia.primitive.reset") +logger = get_logger(__file__) class ECUResetPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/iocbi.py b/src/gallia/commands/primitive/uds/iocbi.py index 3e47beeac..73e72f2b7 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("gallia.primitive.iocbi") +logger = get_logger(__file__) class IOCBIPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/pdu.py b/src/gallia/commands/primitive/uds/pdu.py index c421e7bf7..d49470aef 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("gallia.primitive.pdu") +logger = get_logger(__file__) class SendPDUPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/ping.py b/src/gallia/commands/primitive/uds/ping.py index 22de03b8c..325a5745e 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("gallia.primitive.ping") +logger = get_logger(__file__) class PingPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/rdbi.py b/src/gallia/commands/primitive/uds/rdbi.py index 85a68ce5b..2d1e04df1 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("gallia.primitive.rdbi") +logger = get_logger(__file__) class ReadByIdentifierPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/rmba.py b/src/gallia/commands/primitive/uds/rmba.py index 37ddd3b08..df48783c3 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("gallia.primitive.rmba") +logger = get_logger(__file__) class RMBAPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/rtcl.py b/src/gallia/commands/primitive/uds/rtcl.py index 90097e4cb..28d5f11ce 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("gallia.primitive.rtcl") +logger = get_logger(__file__) class RTCLPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/vin.py b/src/gallia/commands/primitive/uds/vin.py index 131f10480..bbfebb7ef 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("gallia.primitive.vin") +logger = get_logger(__file__) class VINPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/wdbi.py b/src/gallia/commands/primitive/uds/wdbi.py index f97364537..da821abf5 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("gallia.primitive.wdbi") +logger = get_logger(__file__) class WriteByIdentifierPrimitive(UDSScanner): diff --git a/src/gallia/commands/primitive/uds/wmba.py b/src/gallia/commands/primitive/uds/wmba.py index e851f15f7..791749e03 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("gallia.primitive.wmba") +logger = get_logger(__file__) class WMBAPrimitive(UDSScanner): diff --git a/src/gallia/commands/scan/uds/identifiers.py b/src/gallia/commands/scan/uds/identifiers.py index effc7a458..a333da74f 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("gallia.scan.identifiers") +logger = get_logger(__file__) class ScanIdentifiers(UDSScanner): diff --git a/src/gallia/commands/scan/uds/memory.py b/src/gallia/commands/scan/uds/memory.py index ae2746428..54fa65825 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("gallia.scan.memory") +logger = get_logger(__file__) class MemoryFunctionsScanner(UDSScanner): diff --git a/src/gallia/commands/scan/uds/reset.py b/src/gallia/commands/scan/uds/reset.py index a7476898b..a33ff28be 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("gallia.scan.reset") +logger = get_logger(__file__) 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 087dc8d65..a6bf07e22 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("gallia.scan.dump-seeds") +logger = get_logger(__file__) class SASeedsDumper(UDSScanner): diff --git a/src/gallia/commands/scan/uds/services.py b/src/gallia/commands/scan/uds/services.py index e2264e5f6..c871c746b 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("gallia.scan.services") +logger = get_logger(__file__) class ServicesScanner(UDSScanner): diff --git a/src/gallia/commands/scan/uds/sessions.py b/src/gallia/commands/scan/uds/sessions.py index 2f9274c5a..23b4d4ddc 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("gallia.scan.sessions") +logger = get_logger(__file__) class SessionsScanner(UDSScanner): diff --git a/src/gallia/commands/script/vecu.py b/src/gallia/commands/script/vecu.py index eff4f37d1..d0cde7966 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("gallia.vecu.main") +logger = get_logger(__file__) class VirtualECU(AsyncScript): diff --git a/src/gallia/db/handler.py b/src/gallia/db/handler.py index 4ea1d8906..f1d795b5c 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("gallia.db") +logger = get_logger(__file__) class DBHandler: diff --git a/src/gallia/dumpcap.py b/src/gallia/dumpcap.py index 33ab4dee8..53aa32653 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("gallia.dumpcap") +logger = get_logger(__file__) if sys.platform.startswith("linux") or sys.platform == "darwin": diff --git a/src/gallia/powersupply.py b/src/gallia/powersupply.py index ed2d6e051..67510d453 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("gallia.power-supply") +logger = get_logger(__file__) class PowerSupplyURI(TargetURI): diff --git a/src/gallia/services/uds/core/client.py b/src/gallia/services/uds/core/client.py index ded2d047b..dea28c05a 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("gallia.uds.client") +logger = get_logger(__file__) class UDSClient: diff --git a/src/gallia/services/uds/core/service.py b/src/gallia/services/uds/core/service.py index 70dd6c02e..1dbc4fed5 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("gallia.uds.service") +logger = get_logger(__file__) # **************** # * Base classes * diff --git a/src/gallia/services/uds/ecu.py b/src/gallia/services/uds/ecu.py index d3bae0699..b4eed9693 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("gallia.uds.ecu") +logger = get_logger(__file__) class ECU(UDSClient): diff --git a/src/gallia/services/uds/server.py b/src/gallia/services/uds/server.py index 481a4e44f..ae5de3a29 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("gallia.vecu.server") +logger = get_logger(__file__) class UDSServer(ABC): diff --git a/src/gallia/services/xcp/__init__.py b/src/gallia/services/xcp/__init__.py index 32d07dd30..9eaeaba7d 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("gallia.xcp") +logger = get_logger(__file__) class XCPService: diff --git a/src/gallia/transports/base.py b/src/gallia/transports/base.py index c5d6530a8..1edf045c7 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("gallia.transport.base") +logger = get_logger(__file__) class TargetURI: diff --git a/src/gallia/transports/can.py b/src/gallia/transports/can.py index f07ab2a9c..cd4e2e006 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("gallia.transport.can-raw") +logger = get_logger(__file__) CANFD_MTU = 72 CAN_MTU = 16 diff --git a/src/gallia/transports/doip.py b/src/gallia/transports/doip.py index f16638068..142bdd3bd 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("gallia.transport.doip") +logger = get_logger(__file__) @unique diff --git a/src/gallia/transports/isotp.py b/src/gallia/transports/isotp.py index df333f3c9..4f80a6560 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("gallia.transport.isotp") +logger = get_logger(__file__) # 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 01fa39f58..44f6f585e 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("gallia.transport.tcp") +logger = get_logger(__file__) class TCPTransport(BaseTransport, scheme="tcp"): diff --git a/src/gallia/transports/unix.py b/src/gallia/transports/unix.py index 83c278653..b9d531a0b 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("gallia.transport.unix") +logger = get_logger(__file__) class UnixTransport(BaseTransport, scheme="unix"):