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
| Attribute | Type | Description |
|---|---|---|
| callback | callable | A 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
| Name | Type | Description |
|---|---|---|
| callback | callable | A callable that accepts a log record and returns a boolean-like value. |
Signature
def CallbackFilter(
callback: callable
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| callback | callable | A 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
| Name | Type | Description |
|---|---|---|
| record | LogRecord | The logging record object to be evaluated by the callback function. |
Returns
| Type | Description |
|---|---|
int | Returns 1 if the callback evaluates to true (allowing the record to be logged), or 0 if it evaluates to false (suppressing the record). |