Skip to content

Commit

Permalink
chore: Cleanup logger creation
Browse files Browse the repository at this point in the history
Run:

        $ rg -l 'get_logger\(".*"\)' | xargs sed -iE 's|get_logger(".*")|get_logger(__file__)|'

get_logger(__file__) does what you expect without typos.
  • Loading branch information
rumpelsepp committed Jul 21, 2024
1 parent 158e061 commit eb79f78
Show file tree
Hide file tree
Showing 39 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/command/uds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/discover/doip.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
VehicleAnnouncementMessage,
)

logger = get_logger("gallia.discover.doip")
logger = get_logger(__file__)


class DoIPDiscoverer(AsyncScript):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/discover/find_xcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/discover/uds/isotp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/fuzz/uds/pdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/dtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/ecu_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/iocbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/pdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/rdbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/rmba.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/rtcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/vin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/wdbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/primitive/uds/wmba.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/scan/uds/identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/scan/uds/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/scan/uds/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/scan/uds/sa_dump_seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/scan/uds/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/scan/uds/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/script/vecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
dynamic_attr_prefix = "dynamic_attr_"


logger = get_logger("gallia.vecu.main")
logger = get_logger(__file__)


class VirtualECU(AsyncScript):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/db/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/dumpcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/powersupply.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/services/uds/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UDSRequestConfig:
tags: list[str] | None = None


logger = get_logger("gallia.uds.client")
logger = get_logger(__file__)


class UDSClient:
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/services/uds/core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
uds_memory_parameters,
)

logger = get_logger("gallia.uds.service")
logger = get_logger(__file__)

# ****************
# * Base classes *
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/services/uds/ecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/services/uds/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/services/xcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/transports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/transports/can.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/transports/doip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/transports/isotp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/transports/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/transports/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit eb79f78

Please sign in to comment.