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
| Member | Summary |
|---|---|
LogBuffer(Repaint) | Creates the buffer. |
Properties
| Member | Summary |
|---|---|
Capacity | How many lines to keep before the oldest start falling off the back. |
Count | How many lines are held. Can change between two reads if something logs meanwhile. |
Methods
| Member | Summary |
|---|---|
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
| Name | Type | Description |
|---|---|---|
repaint | Repaint | Asked 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
| Name | Type | Description |
|---|---|---|
entry | LogEntry | The 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.