Skip to content
ConsoleMonster
Class

LogRegion

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

The newest lines of a log: lines fill from the top and, once the region is full, the newest line stays at the bottom. It is the capture target of a live session: Console.Out, Console.Error and PowerShell streams arrive here instead of writing at a random cursor position. Only warning and error tags carry colour; source tags get a stable series colour each. Live operation: write (Text, State = level, Key = source tag).

Inheritance

Usage

Explore 58 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 30

Constructors

public LogRegion(string widgetId = "log") #

Creates a log region.

Parameters

widgetId string = "log" optional
The live name (default log).

Methods

public override void Apply(LiveEvent liveEvent) #

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event.
public override string? Describe(LiveEvent liveEvent) #

Returns a line describing the event for line-based outputs (Stream/Plain), or null when the event is not worth a line (for example a single counter increment). Called after ILiveTarget.Apply.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event that was applied.

Returns

string? A plain line or null.
public LogHandle Handle(ILiveDispatcher dispatcher) #

Returns a handle that writes through a dispatcher.

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher required
The dispatcher.

Returns

LogHandle The handle.
public override Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public override void Render(Region region, RenderContext context) #

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.
Write 3 overloads
public void Write(string text, string level = "info", TimeSpan time = default) #

Appends text; line breaks create several entries.

Parameters

text string required
The text.
level string = "info" optional
The level.
time System.TimeSpan = default optional
Session time.
public void Write(LogEntry entry) #

Appends an entry, preserving its selected rich line, level, session time and source timestamp. Caller-created multiline entries expand into lines.

Parameters

entry ConsoleMonster.Widgets.LogEntry required
An existing log entry or a new message entry.

Exceptions

  • ArgumentNullException โ€“ The entry is null.
public void Write(RichText text, string level = "info", TimeSpan time = default) #

Appends rich text as separate lines, preserving styles across line breaks. Malformed markup is literal.

Parameters

text ConsoleMonster.Text.RichText required
The rich text.
level string = "info" optional
The level.
time System.TimeSpan = default optional
Session time.
public void WriteTimestamped(string text, string level, DateTimeOffset? timestamp) #

Appends literal text with an optional source timestamp; no session time is invented.

Parameters

text string required
The original text; line breaks create several entries.
level string required
The level.
timestamp System.DateTimeOffset? required
The source timestamp, or null when unknown.

Properties

public int Capacity { get; set; } #

How many lines are kept (default 1000).

public bool Scrollback { get; set; } #

Also append each entry to normal scrollback above an inline live area. The retained entries still obey LogRegion.Capacity.

public int PreferredHeight { get; set; } #

Rows requested when measured without a height limit (default 8).

public bool FitToEntries { get; set; } #

Takes only the rows its newest entries need, up to LogRegion.PreferredHeight, under a height limit too, and no rows while it is empty, so a message area in an inline live view appears and grows as messages arrive. Off by default: a dashboard keeps a stable LogRegion.PreferredHeight (and an empty log panel keeps a blank row).

public bool ShowElapsed { get; set; } #

Whether entries show their session time (default true).

public int ScrollOffset { get; set; } #

Entries skipped from the newest end while scrolling; zero follows the newest entries.

public bool ShowTimestamp { get; set; } #

Shows source timestamps instead of session time; missing timestamps reserve a blank aligned cell.

public string TimestampFormat { get; set; } #

Source timestamp format, using invariant culture (default ISO date, time, milliseconds and offset).

public string? HighlightText { get; set; } #

Literal ordinal case-insensitive substring to emphasize in plain-text entries; null or empty disables it.

public bool Wrap { get; set; } #

Whether long entries continue on further rows, aligned under the message, instead of being truncated (default false). Lines break after spaces, then after separators, as everywhere else.

public int MaxLinesPerEntry { get; set; } #

The most rows one entry may use when LogRegion.Wrap is on; the last row ends with an ellipsis when cut (default 3).

public IReadOnlyCollection<LogEntry> Entries { get; } #

The kept entries, oldest first.

public LogFilter? Filter { get; set; } #

Which kept entries are drawn, or null for all of them. Hidden entries stay kept and count toward LogRegion.Capacity.

public long TotalLines { get; private set; } #

Total lines received (including dropped ones).

public ColumnFormat LevelColumn { get; set; } #

Layout of the level column (ERR, WARN, VERB...). Every row shares its width, including info lines that have no tag, so messages always start in the same column; the width never shrinks during a session.

Fields

public const int MaxLineLength #

The most characters a literal entry keeps (16,384). A longer line ends with an ellipsis: no row can show it, and LogRegion.Capacity bounds the number of entries, not their size.

Value: 16384

Extension Methods

public static LogRegion Capacity(LogRegion logRegion, int value) #

Sets LogRegion.Capacity: How many lines are kept (default 1000).

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value int required
The value.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                         // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { Capacity = value };    Ui.LogRegion().Capacity(value);
public static LogRegion Filter(LogRegion logRegion, LogFilter? value) #

Sets LogRegion.Filter: Which kept entries are drawn, or null for all of them. Hidden entries stay kept and count toward LogRegion.Capacity.

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value ConsoleMonster.Widgets.LogFilter? required
The value.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                       // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { Filter = value };    Ui.LogRegion().Filter(value);
public static LogRegion FitToEntries(LogRegion logRegion, bool value = true) #

Sets LogRegion.FitToEntries: Takes only the rows its newest entries need, up to LogRegion.PreferredHeight, under a height limit too, and no rows while it is empty, so a message area in an inline live view appears and grows as messages arrive. Off by default: a dashboard keeps a stable LogRegion.PreferredHeight (and an empty log panel keeps a blank row).

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value bool = true optional
The value; true when omitted.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                             // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { FitToEntries = value };    Ui.LogRegion().FitToEntries(value);
public static LogRegion HighlightText(LogRegion logRegion, string? value) #

Sets LogRegion.HighlightText: Literal ordinal case-insensitive substring to emphasize in plain-text entries; null or empty disables it.

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value string? required
The value.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                              // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { HighlightText = value };    Ui.LogRegion().HighlightText(value);
LevelColumn 2 overloads
public static LogRegion LevelColumn(LogRegion logRegion, ColumnFormat value) #

Sets LogRegion.LevelColumn: Layout of the level column (ERR, WARN, VERB...). Every row shares its width, including info lines that have no tag, so messages always start in the same column; the width never shrinks during a session.

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value ConsoleMonster.Layout.ColumnFormat required
The value.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                            // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { LevelColumn = value };    Ui.LogRegion().LevelColumn(value);
public static LogRegion LevelColumn(LogRegion logRegion, Action<ColumnFormat> configure) #

Configures LogRegion.LevelColumn in place: Layout of the level column (ERR, WARN, VERB...). Every row shares its width, including info lines that have no tag, so messages always start in the same column; the width never shrinks during a session.

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
configure System.Action<ConsoleMonster.Layout.ColumnFormat> required
Configures the value.

Returns

LogRegion The same instance.
public static LogRegion MaxLinesPerEntry(LogRegion logRegion, int value) #

Sets LogRegion.MaxLinesPerEntry: The most rows one entry may use when LogRegion.Wrap is on; the last row ends with an ellipsis when cut (default 3).

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value int required
The value.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                                 // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { MaxLinesPerEntry = value };    Ui.LogRegion().MaxLinesPerEntry(value);
public static LogRegion PreferredHeight(LogRegion logRegion, int value) #

Sets LogRegion.PreferredHeight: Rows requested when measured without a height limit (default 8).

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value int required
The value.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                                // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { PreferredHeight = value };    Ui.LogRegion().PreferredHeight(value);
public static LogRegion Scrollback(LogRegion logRegion, bool value = true) #

Sets LogRegion.Scrollback: Also append each entry to normal scrollback above an inline live area. The retained entries still obey LogRegion.Capacity.

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value bool = true optional
The value; true when omitted.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                           // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { Scrollback = value };    Ui.LogRegion().Scrollback(value);
public static LogRegion ScrollOffset(LogRegion logRegion, int value) #

Sets LogRegion.ScrollOffset: Entries skipped from the newest end while scrolling; zero follows the newest entries.

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value int required
The value.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                             // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { ScrollOffset = value };    Ui.LogRegion().ScrollOffset(value);
public static LogRegion ShowElapsed(LogRegion logRegion, bool value = true) #

Sets LogRegion.ShowElapsed: Whether entries show their session time (default true).

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value bool = true optional
The value; true when omitted.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                            // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { ShowElapsed = value };    Ui.LogRegion().ShowElapsed(value);
public static LogRegion ShowTimestamp(LogRegion logRegion, bool value = true) #

Sets LogRegion.ShowTimestamp: Shows source timestamps instead of session time; missing timestamps reserve a blank aligned cell.

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value bool = true optional
The value; true when omitted.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                              // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { ShowTimestamp = value };    Ui.LogRegion().ShowTimestamp(value);
public static LogRegion TimestampFormat(LogRegion logRegion, string value) #

Sets LogRegion.TimestampFormat: Source timestamp format, using invariant culture (default ISO date, time, milliseconds and offset).

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value string required
The value.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                                // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { TimestampFormat = value };    Ui.LogRegion().TimestampFormat(value);
public static LogRegion Wrap(LogRegion logRegion, bool value = true) #

Sets LogRegion.Wrap: Whether long entries continue on further rows, aligned under the message, instead of being truncated (default false). Lines break after spaces, then after separators, as everywhere else.

Parameters

logRegion ConsoleMonster.Widgets.LogRegion required
The instance.
value bool = true optional
The value; true when omitted.

Returns

LogRegion The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.LogRegion { Wrap = value };    Ui.LogRegion().Wrap(value);