Open sandboxFocus

Class ConsoleTheme

A simple implementation of a color theme that allows only for two colors per LogLevel.

Inheritance
ConsoleTheme
Implements
Namespace: PostSharp.Patterns.Diagnostics.Backends.Console
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
public class ConsoleTheme : IConsoleTheme
Remarks

Each part of a log record is rendered with either the normal style (NormalStyles) or the highlighted style (HightlightedStyles) of the record level. By default, variable parts such as parameter values, return values, execution times and exceptions are highlighted. Call AddHightlightedItem(ConsoleThemeItem) or RemoveHighlightedItem(ConsoleThemeItem) to change which items are highlighted.

To customize an existing theme such as Dark, call Clone() or the copy constructor and edit the copy. A theme on which Freeze() has been called, including Dark, throws an InvalidOperationException when it is modified.

When two styles per level are not enough, override GetStyle(string, LogLevel, LogRecordKind, ConsoleThemeItem) or implement IConsoleTheme directly. Assign the theme to Theme.

Constructors

Name Description
ConsoleTheme(ConsoleTheme)

Initializes a new instance of the ConsoleTheme class and copies all values from another ConsoleTheme.

ConsoleTheme(bool)

Initializes a new instance of the ConsoleTheme class.

Properties

Name Description
HightlightedStyles

Gets the styles used for highlighted text.

NormalStyles

Gets the styles used for normal text.

SupportsAnsiCodes

Gets a value indicating whether the theme supports VT escape codes.

Methods

Name Description
AddHightlightedItem(ConsoleThemeItem)

Specifies that a ConsoleThemeItem should be formatted using the highlighted style.

Clone()

Returns an editable copy of the current ConsoleTheme.

Freeze()

Prevents modifications to the current ConsoleTheme.

GetStyle(string, LogLevel, LogRecordKind, ConsoleThemeItem)

Gets the ConsoleThemeStyle for a specific theme item.

RemoveHighlightedItem(ConsoleThemeItem)

Specifies that a ConsoleThemeItem should be formatted using the normal style.

See Also