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

  • By way of pcdsutils.log.install_log_warning_handler, log all calls to warnings.warn at WARNING level

console exceptions:

  • ophydobject INFO should be treated as DEBUG

  • loggers which exceed the configurable log rate thresholds should be filtered out with an accompanying initial notification

  • repeat warning logs and all callback exception logs should be treated as DEBUG instead of as WARNING and ERROR respectively

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_log_directory

Get the currently configured logging path.

get_console_handler

Helper function to find the console StreamHandler.

get_console_level

Helper function to get the console's log level.

get_console_level_name

Helper function to get the console's log level name.

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.

ObjectFilter

A logging filter that limits log messages to a specific object or objects.

log_objects

Configure a custom logging handler on the specified object(s), and record log messages to files and (optionally) to the console.

log_objects_off

Return to default logging behavior and do not treat objects specially.