hutch_python.log_setup.ObjectFilter

class hutch_python.log_setup.ObjectFilter(*objects: ophyd.ophydobj.OphydObject, level: str = 'WARNING', whitelist_all_level: str = 'WARNING', noisy_threshold_1s: int = 20, noisy_threshold_10s: int = 50, noisy_threshold_60s: int = 100, whitelist: Optional[list[str]] = None, blacklist: Optional[list[str]] = None, allow_other_messages: bool = True)

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

To be paired with a logging handler added to the ophyd object logger.

Additionally has the capability of filtering out noisy loggers based on three thresholds: log message rates at 1 second, 10 seconds, and 60 seconds.

Parameters
  • objs (iterable of OphydObject) – Ophyd objects to filter.

  • level (str or int) – Cut-off level for log messages. Default is ‘WARNING’. Python log level names or their corresponding integers are accepted.

  • whitelist_all_level (str or int) – Cut-off level for log messages. Default is ‘WARNING’. Python log level names or their corresponding integers are accepted.

  • allow_other_messages (bool, optional) – Allow messages through the filter that are not specific to ophyd objects. Ophyd object-related messages _must_ pass the filter.

  • noisy_threshold_1s (int, optional) – If a single ophyd object logs over noisy_threshold_1s log messages in one second, consider it a noisy logger and silence it. May be disabled by setting to 0.

  • noisy_threshold_10s (int, optional) – If a single ophyd object logs over noisy_threshold_10s log messages in ten seconds, consider it a noisy logger and silence it. May be disabled by setting to 0.

  • noisy_threshold_60s (int, optional) – If a single ophyd object logs over noisy_threshold_60s log messages in 60 seconds, consider it a noisy logger and silence it. May be disabled by setting to 0.

  • whitelist (list of str, optional) – Logger or object names that are not subject to the thresholds above.

  • blacklist (list of str, optional) – Logger or object names that should always be filtered out.

blacklist

Logger names that should always be filtered out.

Type

list of str

whitelist

List of noisy loggers or object names that are exempt from the noise thresholds.

Type

list of str

noisy_loggers

Loggers marked as noisy and to be filtered out, unless in the whitelist.

Type

set of str

__init__(*objects: ophyd.ophydobj.OphydObject, level: str = 'WARNING', whitelist_all_level: str = 'WARNING', noisy_threshold_1s: int = 20, noisy_threshold_10s: int = 50, noisy_threshold_60s: int = 100, whitelist: Optional[list[str]] = None, blacklist: Optional[list[str]] = None, allow_other_messages: bool = True)

Initialize a filter.

Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event.

Methods

__init__(*objects[, level, ...])

Initialize a filter.

disable()

Disable the filter.

filter(record)

Determine if the specified record is to be logged.

stop()

Stop updating logging rates in the background.

Attributes

description

A description of the current configuration.

level

The logging level name.

levelno

The logging level number.

object_names

The names of all contained objects.

objects

The objects to log.

whitelist_all_level

The logging level at which we whitelist all objects.

allow_other_messages

name_to_log_count_1s

name_to_log_count_10s

name_to_log_count_60s

noisy_threshold_1s

noisy_threshold_10s

noisy_threshold_60s

whitelist

noisy_loggers

blacklist