Class Log
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
public static TextWriter? ErrSink { get; set; }
Property Value
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
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
Methods
Debug(string)
public static void Debug(string message)
Parameters
messagestring
Error(string)
public static void Error(string message)
Parameters
messagestring
Info(string)
public static void Info(string message)
Parameters
messagestring
IsEnabled(LogLevel)
True when level is at or above
MinLevel. Use to gate expensive message formatting.
public static bool IsEnabled(LogLevel level)
Parameters
levelLogLevel
Returns
Success(string)
public static void Success(string message)
Parameters
messagestring
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
sinkTextWriter
Returns
Warn(string)
public static void Warn(string message)
Parameters
messagestring
Write(LogLevel, string)
Write a single log line at the given level.
public static void Write(LogLevel level, string message)