class documentation

class OFMHandler(logging.Handler): (source)

Constructor: OFMHandler(level, max_logs)

View In Hierarchy

A logging.Handler that stores the most recent logs for access by the server.

Method __init__ Initialise the handler with a set logging level and message buffer size.
Method append_record Append the record as a dictionary to a log of records.
Method emit Emit will save the logged record to the log.
Property get_formatted_log_history Return the log history as a formatted string.
Property log_history Return the log history up to the maximum number of logs.
Method _as_record_dict Format the record into the dictionary structure expected by the server.
Instance Variable _log Undocumented
Instance Variable _max_logs Undocumented
Instance Variable _running_counter Undocumented
def __init__(self, level: int = logging.INFO, max_logs: int = 250): (source)

Initialise the handler with a set logging level and message buffer size.

Parameters
level:intThe level of logs captured. As standard logs of INFO and above are captured.
max_logs:intThe maximum number of logs to hold in memory. This sets how many can be returned over HTTP.
def append_record(self, record: logging.LogRecord): (source)

Append the record as a dictionary to a log of records.

Any records in excess of the maximum number of logs are removed.

def emit(self, record: logging.LogRecord): (source)

Emit will save the logged record to the log.

@property
get_formatted_log_history: str = (source)

Return the log history as a formatted string.

This is to be used for the fallback server, the formatting does not contain invocation IDs as no actions should have started.

@property
log_history: list[dict] = (source)

Return the log history up to the maximum number of logs.

Order is reversed so most recent logs are at the top.

def _as_record_dict(self, record: logging.LogRecord) -> dict: (source)

Format the record into the dictionary structure expected by the server.

_log: list[dict] = (source)

Undocumented

_max_logs = (source)

Undocumented

_running_counter: int = (source)

Undocumented