pcdsutils.log.OphydCallbackExceptionDemoter

class pcdsutils.log.OphydCallbackExceptionDemoter(level: str | int = 10, only_duplicates: bool = True)[source]

Filter that demotes the logging level of callback exceptions.

Ophyd object callback exceptions are logged at ERROR level. This causes some usage problems when the user is trying to use the terminal and a callback exception is being thrown on every update of a fast-updating PV.

This filter will apply itself to the ophyd.objects logger, and will switch the log level of either all exceptions or repeat exceptions only depending on the initialization arguments.

This filter incorporates a resettable counter that will count the number of demoted log messages.

Parameters:
levelstr or int, optional

The log level or name of the log level to reduce duplicate log messages to. Defaults to logging.DEBUG.

only_duplicates: bool, optional

If True, the default, only apply this to duplicated log messages. If False, apply it to all log messages.

Methods

filter(record)

Demote the log message if appropriate, return True to let it pass.

install([level, only_duplicates, logger])

Create and apply the DemotionFilter to a specific logger, or the default logger.

install_self([logger])

Convenience method for adding this filter to a logger.

record_dataclass

alias of OphydObjectRecordInfo

should_demote(record, info)

Return True if we should demote the record, False otherwise.

uninstall()

Convenience method for removing this filter.

reset_counter

__init__(level: str | int = 10, only_duplicates: 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__([level, only_duplicates])

Initialize a filter.

filter(record)

Demote the log message if appropriate, return True to let it pass.

install([level, only_duplicates, logger])

Create and apply the DemotionFilter to a specific logger, or the default logger.

install_self([logger])

Convenience method for adding this filter to a logger.

reset_counter()

should_demote(record, info)

Return True if we should demote the record, False otherwise.

uninstall()

Convenience method for removing this filter.

Attributes

default_logger

cache

levelno

levelname

only_duplicates

counter