Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Initialise dodal logger in external callbacks #1287

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/hyperion/external_interaction/callbacks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Callable, Sequence

from bluesky.callbacks.zmq import Proxy, RemoteDispatcher
from dodal.log import LOGGER as dodal_logger
from dodal.log import set_up_all_logging_handlers

from hyperion.external_interaction.callbacks.log_uid_tag_callback import (
Expand Down Expand Up @@ -65,6 +66,7 @@ def setup_logging(dev_mode: bool):
log_info(f"Loggers initialised with dev_mode={dev_mode}")
nexgen_logger = logging.getLogger("nexgen")
nexgen_logger.parent = NEXUS_LOGGER
dodal_logger.parent = ISPYB_LOGGER
log_debug("nexgen logger added to nexus logger")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest
from bluesky.callbacks.zmq import Proxy, RemoteDispatcher
from dodal.log import LOGGER as DODAL_LOGGER

from hyperion.external_interaction.callbacks.__main__ import (
main,
Expand Down Expand Up @@ -49,11 +50,13 @@ def test_setup_callbacks():
return_value=True,
)
def test_setup_logging(parse_callback_cli_args):
assert DODAL_LOGGER.parent != ISPYB_LOGGER
assert len(ISPYB_LOGGER.handlers) == 0
assert len(NEXUS_LOGGER.handlers) == 0
setup_logging(parse_callback_cli_args())
assert len(ISPYB_LOGGER.handlers) == 4
assert len(NEXUS_LOGGER.handlers) == 4
assert DODAL_LOGGER.parent == ISPYB_LOGGER
setup_logging(parse_callback_cli_args())
assert len(ISPYB_LOGGER.handlers) == 4
assert len(NEXUS_LOGGER.handlers) == 4
Expand Down
Loading