Vixen
02b45cc4
csharp
public sealed class ConsoleModel

What the console is showing, and why it is not the whole ring.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The half of the console that is not chrome, and the half worth testing. Which records are visible, what a level toggle means, what "collapse duplicates" collapses and what the badges count are all decisions with answers, and none of them needs a UiDocument to check. ConsoleView is the rows and the buttons over this.

⚠ It must not allocate per line, and doc 20 says so in as many words: "a game logging per frame into a panel that keeps strings is a leak with a UI". Three things make that true. The sink's ring is fixed-size and already holds the records; this pulls only what is new through CopySince into a buffer it keeps, rather than snapshotting a hundred thousand records to find the four that arrived; and the visible set is a list of indices, so a filter that matches nothing still costs nothing.

⚠ It keeps its own bounded copy rather than reading the ring on demand. A console filtered to errors has to know about errors that scrolled out of the last screenful, and a ring read positionally would renumber underneath the filter every time a record arrived. The copy is references to records the sink already allocated, capped at Capacity, and trimmed in blocks — a per-record RemoveAt(0) on a list of ten thousand is the shape of the problem this paragraph is about.

Fields and properties (14)

  • public const int DefaultCapacity

    How many records a console keeps when no capacity is given.

  • public int Capacity

    How many records it keeps.

  • public ConsoleLevels Levels

    Which severities are shown.

  • public string? Search

    What the search box says, or .

  • public string? Category

    Which category is shown, or for all of them.

  • public bool Collapse

    Whether identical lines are folded into one row with a count.

  • public int Count

    How many rows are visible.

  • public ConsoleRow this[int index]

    A visible row.

  • public IReadOnlyList<string> Categories

    Every category seen since the console was cleared, in the order they first appeared.

  • public int Errors

    How many errors have been received, whatever the filter says.

  • public int Warnings
  • public int Infos
  • public int Verbose
  • public long Dropped

    How many records were logged faster than this could keep up with.

Events (1)

  • public Action<ConsoleModel>? Changed

    Raised when the visible set changed.

Methods (4)

  • public ConsoleModel(RingBufferSink sink, int capacity = 10000)

    Watches a sink.

  • public bool Pull()

    Takes whatever has been logged since the last call.

  • public void Clear()

    Throws away everything the console is showing.

  • public static ConsoleLevels BucketOf(LogLevel level)

    Which of the four buttons a level belongs to.

Used by (6)

  • ChromeFixtureVixen.Editor.Ui.Tests
  • ConsolePanelTestsVixen.Editor.App.Tests
  • ConsoleTestsVixen.Editor.Ui.Tests
  • ConsoleViewVixen.Editor.Ui
  • ConsoleViewTestsVixen.Editor.Ui.Tests
  • EditorApplicationVixen.Editor.App