log_setup.py

This module is used to set up and manipulate the logging configuration for utilities like debug mode.

Functionality overview

By way of hutch_python.ipython_log.IPythonLogger, log the following to {{LOG_DIR}}/year_month/user_timestamp.log:

  • All IPython input

  • Any DEBUG message (well, _level 5+_) - Exception: hushed loggers, listed below - Exception: Only whitelisted ophyd object logs, down to DEBUG level (or 5)

Log to both the above file and console: * Any INFO, WARNING, ERROR, CRITICAL messages

console exceptions: * ophydobject INFO should be treated as DEBUG

Hush entirely - neither the file nor the console should see:
  • ophyd.event_dispatcher

  • parso

  • pyPDB.dbd.yacc

setup_logging

Sets up the logging configuration.

get_session_logfiles

Get the path to the current debug log file

get_console_handler

Helper function to find the console StreamHandler.

get_console_level

Helper function to get the console’s log level.

set_console_level

Helper function to set the console’s log level.

debug_mode

Enable, disable, or check if we’re in debug mode.

debug_context

Context manager for running a block of code in debug_mode.

debug_wrapper

Wrapper for running a function in debug_mode.