Skip to content
ConsoleMonster

API Reference

Class

LogRegion

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. Live operation: write (Text, State = level).

Inheritance

Usage

Explore 24 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 12

Constructors

public LogRegion(String name = "log") #

Creates a log region.

Parameters

name System.String = "log" optionalposition: 0
The live name (default log).

Methods

public override Void Apply(LiveEvent liveEvent) #
Returns: Void

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent requiredposition: 0
The event.
public override String? Describe(LiveEvent liveEvent) #
Returns: String?

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 requiredposition: 0
The event that was applied.

Returns

A plain line or null.

public LogHandle Handle(ILiveDispatcher dispatcher) #
Returns: LogHandle

Returns a handle that writes through a dispatcher.

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher requiredposition: 0
The dispatcher.

Returns

The handle.

public override Size Measure(Constraints constraints, RenderContext context) #
Returns: Size

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints requiredposition: 0
The space offered.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.

Returns

The desired size, never larger than the constraints.

public override Void Render(Region region, RenderContext context) #
Returns: Void

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

Parameters

region ConsoleMonster.Canvas.Region requiredposition: 0
The target region.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.
Write 2 overloads
public Void Write(String text, String level = "info", TimeSpan time = default) #
Returns: Void

Appends text; line breaks create several entries.

Parameters

text System.String requiredposition: 0
The text.
level System.String = "info" optionalposition: 1
The level.
time System.TimeSpan = default optionalposition: 2
Session time.
public Void Write(RichText text, String level = "info", TimeSpan time = default) #
Returns: Void

Appends a multicolour line (line breaks inside it create several entries, each keeping its styles).

Parameters

text ConsoleMonster.Text.RichText requiredposition: 0
The rich text.
level System.String = "info" optionalposition: 1
The level.
time System.TimeSpan = default optionalposition: 2
Session time.

Properties

public Int32 Capacity { get; set; } #

How many lines are kept (default 1000).

public Int32 PreferredHeight { get; set; } #

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

public Boolean ShowTime { get; set; } #

Whether entries show their session time (default true).

public Boolean 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 Int32 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 Int64 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.

Extension Methods

public static LogRegion WithCapacity(LogRegion logRegion, Int32 value) #
Returns: LogRegion

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

Parameters

logRegion ConsoleMonster.Widgets.LogRegion requiredposition: 0
The instance.
value System.Int32 requiredposition: 1
The value.

Returns

The same instance.

WithLevelColumn 2 overloads
public static LogRegion WithLevelColumn(LogRegion logRegion, ColumnFormat value) #
Returns: LogRegion

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 requiredposition: 0
The instance.
value ConsoleMonster.Layout.ColumnFormat requiredposition: 1
The value.

Returns

The same instance.

public static LogRegion WithLevelColumn(LogRegion logRegion, Action<ColumnFormat> configure) #
Returns: LogRegion

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 requiredposition: 0
The instance.
configure System.Action<ConsoleMonster.Layout.ColumnFormat> requiredposition: 1
Configures the value.

Returns

The same instance.

public static LogRegion WithMaxLinesPerEntry(LogRegion logRegion, Int32 value) #
Returns: LogRegion

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 requiredposition: 0
The instance.
value System.Int32 requiredposition: 1
The value.

Returns

The same instance.

public static LogRegion WithPreferredHeight(LogRegion logRegion, Int32 value) #
Returns: LogRegion

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

Parameters

logRegion ConsoleMonster.Widgets.LogRegion requiredposition: 0
The instance.
value System.Int32 requiredposition: 1
The value.

Returns

The same instance.

public static LogRegion WithShowTime(LogRegion logRegion, Boolean value = true) #
Returns: LogRegion

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

Parameters

logRegion ConsoleMonster.Widgets.LogRegion requiredposition: 0
The instance.
value System.Boolean = true optionalposition: 1
The value (default true).

Returns

The same instance.

public static LogRegion WithWrap(LogRegion logRegion, Boolean value = true) #
Returns: LogRegion

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 requiredposition: 0
The instance.
value System.Boolean = true optionalposition: 1
The value (default true).

Returns

The same instance.