public sealed class RingBufferSinkThe always-on log sink: the last N records in a ring, in memory, in every build. The editor console reads it live and the crash reporter dumps it.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
A log that only exists on disk is a log nobody has when it matters — the interesting moment is usually the thirty seconds before a crash, and asking a player for a file is asking for nothing. A bounded ring costs a fixed amount of memory and always has that thirty seconds.
Per-category minimum levels come from LogFilter, so "turn on verbose asset loading without drowning in render spam" works. Rate limiting is available and off: everything else is a view of the log and can afford to lose repeats, whereas this is the record the crash reporter dumps, and a ring that dropped the four thousand identical lines before the crash would be hiding the shape of the failure.
Where this is not yet what doc 13 asks for. Records hold a formatted String, not UTF-8 bytes with the structured fields intact, so an enabled log line allocates. The disabled path already allocates nothing — a [LoggerMessage] method returns before touching its arguments — and the enabled path is not in any hot loop, because [HotPath] methods are barred from logging. Packing records into a byte ring is the optimisation to make when a profile asks for it, and doing it now would be guessing at the field layout the editor console wants.
Fields and properties (5)
public const int DefaultCapacityHow many records the ring holds when no capacity is given.
public int CapacityHow many records the ring holds.
public int CountHow many records it currently holds.
public long DroppedCountHow many records have been overwritten. Distinguishes "the log is missing its beginning" from "nothing was logged", which a bare ring cannot.
public long WrittenHow many records have ever reached the ring, the overwritten ones included.
Methods (6)
public RingBufferSink(int capacity = 100000, LogFilter? filter = null)Creates a sink holding at most records.
public LogRecord[] Snapshot()Copies the records out, oldest first.
public int CopyTail(Span<LogRecord> destination)Copies the newest records out, oldest of them first.
public int CopySince(ref long sequence, Span<LogRecord> destination)Copies the records written since a sequence number.
public void Clear()Empties the ring. Does not reset DroppedCount.
protected override void Write(LogRecord record)Writes one record wherever this sink writes.
Used by (13)
- AppBuilderVixen.App.Hosting
- AppServicesVixen.App.Hosting
- DiagnosticOverlayTestsVixen.Engine.Tests
- DiagnosticsTestsVixen.Core.Diagnostics.Tests
- LogOverlayVixen.Engine
- SinkTestsVixen.Core.Diagnostics.Tests
- ChromeFixtureVixen.Editor.Ui.Tests
- ConsoleModelVixen.Editor.Ui
- ConsoleTestsVixen.Editor.Ui.Tests
- ConsoleViewTestsVixen.Editor.Ui.Tests
- EditorApplicationVixen.Editor.App
- EditorLogVixen.Editor.App
- StartupSceneTestsVixen.App.Tests