Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make common MX bluesky logging #580

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

olliesilvester
Copy link
Contributor

@olliesilvester olliesilvester commented Oct 16, 2024

Fixes #574

I will either put the below instructions in the docs or as a helper function:

A beamline should use these logs by:

  1. Creating a new global logger, eg LOGGER = logging.getLogger("Hyperion")
  2. Importing the dodal logger and setting this as the parent
  3. Running do_default_logging_setup

eg:

from dodal.log import LOGGER as dodal_logger
from mx_bluesky.common.utils.log import do_default_logging_setup
LOGGER = logging.getLogger("Hyperion")
LOGGER.parent = dodal_logger
do_default_logging_setup(...)

@olliesilvester olliesilvester changed the title Move hyperion logs to somewhere common and generalise get_logging_dir Make common MX bluesky logging Oct 16, 2024
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 88.67925% with 6 lines in your changes missing coverage. Please review.

Project coverage is 78.24%. Comparing base (2957b1e) to head (026e3ce).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #580      +/-   ##
==========================================
+ Coverage   78.21%   78.24%   +0.03%     
==========================================
  Files          92       93       +1     
  Lines        6797     6809      +12     
==========================================
+ Hits         5316     5328      +12     
  Misses       1481     1481              
Components Coverage Δ
i24 SSX 57.17% <ø> (ø)
hyperion 96.37% <100.00%> (+0.13%) ⬆️
other 95.52% <85.71%> (-4.48%) ⬇️

@noemifrisina
Copy link
Contributor

I will either put the below instructions in the docs or as a helper function

Something in the developer docs about how the logs work and how to set them up would definitely be helpful - thinking mainly in terms of having a reference for the future.

tag_filter.run_uid = uid


def do_default_logging_setup(file_name: str, graylog_port: int, dev_mode: bool = False):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noemifrisina has requested an option to toggle whether or not this function runs integrate_bluesky_and_ophyd_logging, so I'll add that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Whats the usecase for dropping all the ophyd/bluesky logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what @noemifrisina was saying (but correct me if I'm wrong), it's useful to see the sys.sterr logs on i24, and it gets cluttered with ophyd+bluesky+ophyd-async logs. Also, she was seeing an issue where ophyd debug logs were appearing even when it wasn't set to debug level

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, mainly to have the choice of getting everything or just setting up the ones we're interested in (in i24 case we don't need the debug logs from ophyd, just ophyd_async).

@DominicOram
Copy link
Contributor

Can we replace some of the code in i24/serial/log.py with calls to this common one to make it consistent?

@olliesilvester
Copy link
Contributor Author

Can we replace some of the code in i24/serial/log.py with calls to this common one to make it consistent?

Yes, I was thinking this could be done in separate PR (maybe #572). Happy to do it in here instead though

@noemifrisina
Copy link
Contributor

We could do this here, or I can pull the changes from this branch into #572 and do that bit in there. I'm fine either way, if we're going to have that in this PR I'll just close the other one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make common MX logging
3 participants