Table of Contents

Class Trace

Namespace
Terminal.Gui.Tracing
Assembly
Terminal.Gui.dll

Provides unified tracing for debugging and testing. Supports independent enable/disable for different trace categories. Traces are only captured in DEBUG builds.

public static class Trace
Inheritance
Trace
Inherited Members

Remarks

By default, all tracing is disabled. Enable categories via EnabledCategories:

Trace.EnabledCategories = TraceCategory.Command | TraceCategory.Mouse;

All trace methods are marked with [Conditional("DEBUG")], so they have zero overhead in Release builds.

When a category is enabled, if no backend has been set, LoggingBackend is automatically used so traces appear in the log output.

Properties

Backend

Gets or sets the trace backend for the current async context. Default is NullBackend. Each async flow (test, thread) has its own backend instance.

EnabledCategories

Gets or sets the enabled trace categories for the current async context. This property is thread-safe and isolated per async flow.

Methods

Command(View, string, string?, string)

Traces a command routing step from a context.

Command(View, Command, CommandRouting, string, string?, string)

Traces a command routing step.

Command(View, ICommandContext?, string, string?, string)

Traces a command routing step from a context.

Configuration(string?, string, string?, string)

Traces a configuration management operation.

Draw(string?, string, string?, string)

Traces a draw operation.

Keyboard(string, Key, string, string?, string)

Traces a keyboard event at the Driver or Application level (no view context).

Keyboard(PlatformKeyBinding, string, string?, string)

Traces a keyboard binding event.

Keyboard(View, Key, string, string?, string)

Traces a keyboard event at the View level.

Lifecycle(string?, string, string?, string)

Traces a command routing step.

Mouse(string, Mouse, string, string?, string)

Traces a mouse event with a Mouse object at the Driver or Application level.

Mouse(string, MouseFlags, Point, string, string?, string)

Traces a mouse event at the Driver or Application level (no view context).

Mouse(View, Mouse, string, string?, string)

Traces a mouse event with a Mouse object at the View level.

Mouse(View, MouseFlags, Point, string, string?, string)

Traces a mouse event at the View level.

PushScope(TraceCategory, ITraceBackend?)

Pushes a trace scope that enables the specified categories and optionally sets a backend. Returns an IDisposable that restores the previous state when disposed. This is thread-safe and works correctly with parallel tests.