Skip to main content

CallbackFilter

A logging filter that checks the return value of a given callable (which takes the record-to-be-logged as its only parameter) to decide whether to log a record.

Attributes

AttributeTypeDescription
callbackcallableA callable object that accepts a log record as its single argument and returns a truthy value to allow the record or a falsy value to discard it.

Constructor

Signature

def CallbackFilter(
callback: callable
) - > null

Parameters

NameTypeDescription
callbackcallableA callable that accepts a log record and returns a boolean-like value.

Signature

def CallbackFilter(
callback: callable
) - > null

Parameters

NameTypeDescription
callbackcallableA function or callable object that accepts a single LogRecord argument and returns a truthy value to allow logging or falsy to suppress it.

Methods


filter()

@classmethod
def filter(
record: LogRecord
) - > int

Determines whether a log record should be processed by executing the configured callback function.

Parameters

NameTypeDescription
recordLogRecordThe logging record object to be evaluated by the callback function.

Returns

TypeDescription
intReturns 1 if the callback evaluates to true (allowing the record to be logged), or 0 if it evaluates to false (suppressing the record).