Skip to content

Commit

Permalink
Merge pull request #279 from klauer/logging_objects
Browse files Browse the repository at this point in the history
ENH/REF: Selective verbose logging of ophyd objects
  • Loading branch information
ZLLentz authored Jun 4, 2021
2 parents 2d8653a + ab38c6f commit 615b5a6
Show file tree
Hide file tree
Showing 6 changed files with 458 additions and 45 deletions.
19 changes: 19 additions & 0 deletions docs/source/releases.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
Release History
###############

v1.11.0 (2021-06-04)
===================

Features
--------
- Added ability to opt-in to specific Ophyd Object instance DEBUG logs. Call
``logs.log_objects(obj1, obj2)`` to configure it for ``obj1`` and ``obj2``,
for example, and clear it by way of ``logs.log_objects_off()``.
- Added a new ``logs`` object in the IPython namespace, offering easy access
to common log-related tools.


Fixes and Maintenance
---------------------
- Refactored logging setup to be more modular and slightly better documented.
The ophyd logger is no longer "hushed", but is now filtered through the
new ``ObjectFilter`` mechanism.


v1.10.1 (2021-06-03)
===================

Expand Down
6 changes: 4 additions & 2 deletions hutch_python/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from .constants import CONDA_BASE, DIR_MODULE
from .load_conf import load
from .log_setup import debug_mode, setup_logging
from .log_setup import configure_log_directory, debug_mode, setup_logging

logger = logging.getLogger(__name__)
opts_cache = {}
Expand Down Expand Up @@ -110,7 +110,9 @@ def main():
log_dir = None
else:
log_dir = os.path.join(os.path.dirname(args.cfg), 'logs')
setup_logging(dir_logs=log_dir)

configure_log_directory(log_dir)
setup_logging()

# Debug mode next
if args.debug:
Expand Down
15 changes: 14 additions & 1 deletion hutch_python/load_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pcdsdaq.scan_vars import ScanVars
from pcdsdevices.interface import setup_preset_paths

from . import calc_defaults, plan_defaults, sim
from . import calc_defaults, plan_defaults, sim, log_setup
from .cache import LoadCache
from .cam_load import read_camviewer_cfg
from .constants import CAMVIEWER_CFG, VALID_KEYS
Expand Down Expand Up @@ -235,6 +235,19 @@ def load_conf(conf, hutch_dir=None):
with safe_load('configure ophyd'):
setup_ophyd()

cache(
logs=HelpfulNamespace(
log_objects=log_setup.log_objects,
log_objects_off=log_setup.log_objects_off,
get_log_directory=log_setup.get_log_directory,
get_session_logfiles=log_setup.get_session_logfiles,
get_console_level_name=log_setup.get_console_level_name,
set_console_level=log_setup.set_console_level,
debug_mode=log_setup.debug_mode,
debug_context=log_setup.debug_context,
)
)

# Make RunEngine
with safe_load('run engine'):
RE = RunEngine({})
Expand Down
Loading

0 comments on commit 615b5a6

Please sign in to comment.