class documentation

class ACMERingBufferLogHandler(logging.Handler, RingBuffer[LogRecord]):

Constructor: ACMERingBufferLogHandler(capacity)

View In Hierarchy

A ring buffer handler for logging. It buffers log records and flushes them to the console or file when the buffer is full.

Method __init__ Initialize the ring buffer handler with a given capacity.
Method emit Emit a log record to the buffer.
Method getLogEntryAsString Get a log entry from the buffer by index.

Inherited from RingBuffer:

Method __getitem__ Get an item from the buffer by index.
Method append Add an item to the ring buffer. If the buffer is full, the oldest item is removed.
Method incrementHead Increment the head in a circular manner.
Method nextIndex Increment an index in a circular manner without modifying the current index.
Instance Variable buffer The internal storage for the ring buffer, initialized with None values.
Instance Variable capacity The maximum number of items the buffer can hold.
Instance Variable head The current head index of the ring buffer, initialized to -1 indicating an empty buffer.
def __init__(self, capacity: int = 10):

Initialize the ring buffer handler with a given capacity.

Parameters
capacity:intThe maximum number of log records to keep in the buffer.
def emit(self, record: LogRecord):

Emit a log record to the buffer.

Parameters
record:LogRecordThe log record to emit.
def getLogEntryAsString(self, index: int) -> str | None:

Get a log entry from the buffer by index.

Parameters
index:intThe index of the log entry to get.
Returns
str | NoneThe log entry as a string, or None if the index is out of bounds.