DebuggerLogger Class

Defines an implementation of Logger that writes to standard Debug or Trace output.

public class DebuggerLogger : Logger
Inheritance:
object Logger object

Constructors

DebuggerLogger(string)

Initializes a new instance of the DebuggerLogger class.

public DebuggerLogger(string categoryName)
Parameter Type Description
categoryName string

The category name of the logger, or null if a category is not used.

Methods

BeginScope(string?, params object?[])

Begins a new scope.

public override IDisposable BeginScope(string? messageFormat, params object?[] args)
Parameter Type Description
messageFormat string
args object[]

The optional values to be used when formatting the scope message.

Returns

IDisposable:

An IDisposable that should be disposed to close the scope, or null if scopes are not supported by the logger.

DebugWriteLine(LogLevel, Exception?, string?)

Writes a line to debug output.

protected virtual void DebugWriteLine(LogLevel logLevel, Exception? exception, string? text)
Parameter Type Description
logLevel LogLevel

The log level.

exception Exception

The exception, if any, associated with the message.

text string

The line of text to be written.

GetLogLevelDisplayText(LogLevel)

Gets the display text for the given log level.

protected static string GetLogLevelDisplayText(LogLevel logLevel)
Parameter Type Description
logLevel LogLevel

The log level.

Returns

string:

A string of the display text to be used for the log level.

IsEnabled(LogLevel)

Gets if the given LogLevel is currently enabled. When not enabled, messages of that level will not be written.

public override bool IsEnabled(LogLevel logLevel)
Parameter Type Description
logLevel LogLevel

The LogLevel to test.

Returns

bool:

true if the given LogLevel is enabled; otherwise false.

Log(LogLevel, Func<string?>, Exception?)

Writes data to the logger with the given LogLevel.

public override void Log(LogLevel logLevel, Func<string?> messageFactory, Exception? exception)
Parameter Type Description
logLevel LogLevel

The level of logging associated with the message.

messageFactory Func<string>

The function that is invoked to generate the message.

exception Exception

The Exception, if any, associated with the message.

Inherited Members

Extension Methods