diff --git a/.github/pages/make_switcher.py b/.github/pages/make_switcher.py index c06813afad..3bfd558d41 100755 --- a/.github/pages/make_switcher.py +++ b/.github/pages/make_switcher.py @@ -33,7 +33,7 @@ def get_versions(ref: str, add: str | None) -> list[str]: builds = set(get_branch_contents(ref)) except CalledProcessError: builds = set() - logging.warning(f"Cannot get {ref} contents") + logging.warning(f"Cannot get {ref} contents") # noqa: LOG015 # Add and remove from the list of builds if add: diff --git a/pyproject.toml b/pyproject.toml index e25494a4ba..17515991f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -155,6 +155,7 @@ lint.select = [ "UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up "SLF", # self - https://docs.astral.sh/ruff/settings/#lintflake8-self "PLC2701", # private import - https://docs.astral.sh/ruff/rules/import-private-name/ + "LOG015", # root logger call - https://docs.astral.sh/ruff/rules/root-logger-call/ ] lint.ignore = [ "B901", # Return in a generator is needed for plans diff --git a/src/ophyd_async/core/_utils.py b/src/ophyd_async/core/_utils.py index 16368204a3..b19540e101 100644 --- a/src/ophyd_async/core/_utils.py +++ b/src/ophyd_async/core/_utils.py @@ -16,6 +16,8 @@ DEFAULT_TIMEOUT = 10.0 ErrorText = str | Mapping[str, Exception] +logger = logging.getLogger("ophyd_async") + class StrictEnumMeta(EnumMeta): def __new__(metacls, *args, **kwargs): @@ -114,7 +116,7 @@ def with_other_exceptions_logged( ) -> NotConnected: for name, exception in exceptions.items(): if not isinstance(exception, NotConnected): - logging.exception( + logger.exception( f"device `{name}` raised unexpected exception " f"{type(exception).__name__}", exc_info=exception, diff --git a/src/ophyd_async/epics/core/_aioca.py b/src/ophyd_async/epics/core/_aioca.py index 44f0d1e5e8..d424dd1edd 100644 --- a/src/ophyd_async/epics/core/_aioca.py +++ b/src/ophyd_async/epics/core/_aioca.py @@ -35,6 +35,8 @@ from ._util import EpicsSignalBackend, format_datatype, get_supported_values +logger = logging.getLogger("ophyd_async") + def _limits_from_augmented_value(value: AugmentedValue) -> Limits: def get_limits(limit: str) -> LimitsRange | None: @@ -258,7 +260,7 @@ async def _store_initial_value(self, pv: str, timeout: float): pv, format=FORMAT_CTRL, timeout=timeout ) except CANothing as exc: - logging.debug(f"signal ca://{pv} timed out") + logger.debug(f"signal ca://{pv} timed out") raise NotConnected(f"ca://{pv}") from exc async def connect(self, timeout: float): diff --git a/src/ophyd_async/epics/core/_p4p.py b/src/ophyd_async/epics/core/_p4p.py index 73fc919cb8..020ce01757 100644 --- a/src/ophyd_async/epics/core/_p4p.py +++ b/src/ophyd_async/epics/core/_p4p.py @@ -31,6 +31,8 @@ from ._util import EpicsSignalBackend, format_datatype, get_supported_values +logger = logging.getLogger("ophyd_async") + def _limits_from_value(value: Any) -> Limits: def get_limits( @@ -321,7 +323,7 @@ async def pvget_with_timeout(pv: str, timeout: float) -> Any: try: return await asyncio.wait_for(context().get(pv), timeout=timeout) except asyncio.TimeoutError as exc: - logging.debug(f"signal pva://{pv} timed out", exc_info=True) + logger.debug(f"signal pva://{pv} timed out", exc_info=True) raise NotConnected(f"pva://{pv}") from exc diff --git a/src/ophyd_async/tango/core/_signal.py b/src/ophyd_async/tango/core/_signal.py index ab173e35dd..3623afbd77 100644 --- a/src/ophyd_async/tango/core/_signal.py +++ b/src/ophyd_async/tango/core/_signal.py @@ -28,6 +28,8 @@ from ._tango_transport import TangoSignalBackend, get_python_type +logger = logging.getLogger("ophyd_async") + def make_backend( datatype: type[SignalDatatypeT] | None, @@ -205,7 +207,7 @@ async def infer_signal_type( if config.in_type == CmdArgType.DevVoid: return SignalX elif config.in_type != config.out_type: - logging.debug("Commands with different in and out dtypes are not supported") + logger.debug("Commands with different in and out dtypes are not supported") return None else: return SignalRW