Lookback Handler

class starlog.LookbackHandler(capacity, max_age=3600, flush_level=40, **kwargs)

LookbackHandler is a handler which buffers logging records.

Flushing occurs whenever an event of certain severity or greater is seen.

When the buffer is full, logging records of lower severity levels are dropped.

Parameters:
  • capacity – the number of logging records to buffer per thread/process
  • max_age (int) – the number of seconds after which logging records are dropped
  • flush_level – flush buffered logging records if a logging record seen with this log level or higher
emit(record)

Emit a record.

Append the record. If shouldFlush() tells us to, call flush_sub_buffer() to process the buffer.

flush()

Flush all sub buffers.

flush_sub_buffer(records)

Sends buffered records of the thread/process record buffer to the target handler.

key(record)

Key of the record to identify the sub buffer. It returns a tuple of thread-id and process id of the record.

shouldFlush(record)

Check for record at the flushLevel or higher.

trim()

Deletes buffered logging records reaching the buffer capacity. Also deletes logging records older than max_age.