Skip to main content

LogBuffer class

Namespace: Arlecchino.Diagnostics · Assembly: Arlecchino

The last few log lines, held in memory for the overlay to draw, since a terminal application cannot write them to the console. Logging happens on any thread, so the oldest are dropped under a lock.

public sealed class LogBuffer

Constructors

MemberSummary
LogBuffer(Repaint)Creates the buffer.

Properties

MemberSummary
CapacityHow many lines to keep before the oldest start falling off the back.
CountHow many lines are held. Can change between two reads if something logs meanwhile.

Methods

MemberSummary
Add(LogEntry)Records a line, dropping the oldest when the buffer is full. Safe from any thread.
Clear()Throws away every line held.
Snapshot()The lines held, the oldest first, as they were at this moment. A copy, because anything may be logging while the overlay draws.

Constructors in detail

LogBuffer(Repaint)

public LogBuffer(Repaint repaint);

Creates the buffer.

Parameters

NameTypeDescription
repaintRepaintAsked for a frame when a line arrives, so the overlay stays current.

Properties in detail

Capacity

public int Capacity { get; set; }

How many lines to keep before the oldest start falling off the back.

Type int

Count

public int Count { get; }

How many lines are held. Can change between two reads if something logs meanwhile.

Type int

Methods in detail

Add(LogEntry)

public void Add(LogEntry entry);

Records a line, dropping the oldest when the buffer is full. Safe from any thread.

Parameters

NameTypeDescription
entryLogEntryThe line.

Clear()

public void Clear();

Throws away every line held.

Snapshot()

public IReadOnlyList<LogEntry> Snapshot();

The lines held, the oldest first, as they were at this moment. A copy, because anything may be logging while the overlay draws.

Returns IReadOnlyList<T><LogEntry> — The lines.