Table of Contents

Class Log

Namespace
Retro.Crt
Assembly
Retro.Crt.dll

Tiny semantic logger — not an ILogger replacement. Prints HH:MM:SS LEVEL message with a colored level tag. Warn/Error go to Error; everything else to Out, unless redirected via OutSink / ErrSink.

public static class Log
Inheritance
Log
Inherited Members

Properties

ErrSink

Override for the Warn and Error destination. null uses Error.

public static TextWriter? ErrSink { get; set; }

Property Value

TextWriter

MinLevel

Lines below this level are dropped on the floor. Defaults to Debug (everything passes). Set to Warn in production / quiet modes.

public static LogLevel MinLevel { get; set; }

Property Value

LogLevel

OutSink

Override for the Info, Debug, and Success destination. null uses Out. Useful for tests, log files, or routing to a specific TextWriter.

public static TextWriter? OutSink { get; set; }

Property Value

TextWriter

Methods

Debug(string)

public static void Debug(string message)

Parameters

message string

Error(string)

public static void Error(string message)

Parameters

message string

Info(string)

public static void Info(string message)

Parameters

message string

IsEnabled(LogLevel)

True when level is at or above MinLevel. Use to gate expensive message formatting.

public static bool IsEnabled(LogLevel level)

Parameters

level LogLevel

Returns

bool

Success(string)

public static void Success(string message)

Parameters

message string

UseSink(TextWriter)

Route both OutSink and ErrSink to sink for the duration of the returned scope. Restores the previous overrides on dispose. Useful for capturing log output into a string, file, or test buffer without touching the global Console redirection.

public static IDisposable UseSink(TextWriter sink)

Parameters

sink TextWriter

Returns

IDisposable

Warn(string)

public static void Warn(string message)

Parameters

message string

Write(LogLevel, string)

Write a single log line at the given level.

public static void Write(LogLevel level, string message)

Parameters

level LogLevel
message string