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
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
stateTStateThe scope state.
Returns
- IDisposable
Always returns null.
Type Parameters
TStateThe 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
logLevelLogLevelThe 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
logLevelLogLevelThe severity level of the log entry.
eventIdEventIdThe event identifier.
stateTStateThe log state object.
exceptionExceptionThe exception associated with the log entry, if any.
formatterFunc<TState, Exception, string>The function to format the state and exception into a message string.
Type Parameters
TStateThe type of the state object.