Table of Contents

Class TestLogger

Namespace
SunamoTest
Assembly
SunamoTest.dll

A test implementation of ILogger that throws exceptions for error-level log messages.

public class TestLogger : ILogger
Inheritance
TestLogger
Implements
Inherited Members
Extension Methods

Constructors

TestLogger()

Initializes a new instance of the TestLogger class.

public TestLogger()

Properties

Instance

Singleton instance of the test logger.

public static TestLogger Instance { get; set; }

Property Value

TestLogger

Methods

BeginScope<TState>(TState)

Begins a logical operation scope. Returns null as scoping is not supported.

public IDisposable? BeginScope<TState>(TState state) where TState : notnull

Parameters

state TState

The scope state.

Returns

IDisposable

Always returns null.

Type Parameters

TState

The type of the state object.

IsEnabled(LogLevel)

Checks whether logging is enabled for the specified log level. Always returns true.

public bool IsEnabled(LogLevel logLevel)

Parameters

logLevel LogLevel

The log level to check.

Returns

bool

Always returns true.

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

Logs a message. Throws an exception if the log level is Error or Critical to surface test failures.

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)

Parameters

logLevel LogLevel

The severity level of the log entry.

eventId EventId

The event identifier.

state TState

The log state object.

exception Exception

The exception associated with the log entry, if any.

formatter Func<TState, Exception, string>

The function to format the state and exception into a message string.

Type Parameters

TState

The type of the state object.