Class DebwinLogger
- Namespace
- combit.Logging
- Assembly
- combit.ListLabel31.CrossPlatform.dll
Represents a logger implementation for writing log messages to a Debwin4 log file.
public class DebwinLogger : ILogger, IDisposable
- Inheritance
-
DebwinLogger
- Implements
- Inherited Members
Constructors
DebwinLogger(Stream, LogLevel, string)
Initializes a new instance of the DebwinLogger class with the specified log stream, minimal log level, and category name.
public DebwinLogger(Stream stream, LogLevel minimalLogLevel = LogLevel.Debug, string categoryName = "ListLabel")
Parameters
streamStreamThe stream to write log messages to.
minimalLogLevelLogLevelThe minimal log level to write to the log stream.
categoryNamestringThe category name for the logger.
DebwinLogger(string, LogLevel, string)
Initializes a new instance of the DebwinLogger class with the specified log file path, minimal log level, and category name.
public DebwinLogger(string filePath, LogLevel minimalLogLevel = LogLevel.Debug, string categoryName = "ListLabel")
Parameters
filePathstringThe path to the log file.
minimalLogLevelLogLevelThe minimal log level to write to the log file.
categoryNamestringThe category name for the logger.
DebwinLogger(string, int, LogLevel, string)
Initializes a new instance of the DebwinLogger class that logs UDP messages to the specified host name, port, minimal log level, and category name.
public DebwinLogger(string hostName, int port, LogLevel minimalLogLevel = LogLevel.Debug, string categoryName = "ListLabel")
Parameters
hostNamestringThe host name of the UDP server.
portintThe port of the UDP server.
minimalLogLevelLogLevelThe minimal log level to write to the log.
categoryNamestringThe category name for the logger.
Methods
BeginScope<TState>(TState)
Begins a logical operation scope.
public IDisposable BeginScope<TState>(TState state) where TState : notnull
Parameters
stateTStateThe state associated with the scope.
Returns
- IDisposable
An IDisposable object that ends the logical operation scope when disposed.
Type Parameters
TStateThe type of the state.
Dispose()
Disposes the logger and releases any resources used.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the logger and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbooltrueto release both managed and unmanaged resources;falseto release only unmanaged resources.
Remarks
This method stops the logging thread, signals any waiting log events, and disposes of the stream writer and UDP client if they exist.
IsEnabled(LogLevel)
Determines whether the specified log level is enabled.
public bool IsEnabled(LogLevel logLevel)
Parameters
logLevelLogLevelThe log level to check.
Returns
- bool
trueif the log level is enabled; otherwise,false.
Log<TState>(LogLevel, EventId, TState, Exception?, Func<TState, Exception?, string>)
Writes a log message.
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
Parameters
logLevelLogLevelThe log level of the message.
eventIdEventIdThe event ID of the message.
stateTStateThe state of the message.
exceptionExceptionThe exception associated with the message, if any.
formatterFunc<TState, Exception, string>A function that formats the state and exception into a log message.
Type Parameters
TStateThe type of the state.