Table of Contents

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

stream Stream

The stream to write log messages to.

minimalLogLevel LogLevel

The minimal log level to write to the log stream.

categoryName string

The 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

filePath string

The path to the log file.

minimalLogLevel LogLevel

The minimal log level to write to the log file.

categoryName string

The 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

hostName string

The host name of the UDP server.

port int

The port of the UDP server.

minimalLogLevel LogLevel

The minimal log level to write to the log.

categoryName string

The category name for the logger.

Methods

BeginScope<TState>(TState)

Begins a logical operation scope.

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

Parameters

state TState

The state associated with the scope.

Returns

IDisposable

An IDisposable object that ends the logical operation scope when disposed.

Type Parameters

TState

The 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

disposing bool

true to release both managed and unmanaged resources; false to 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

logLevel LogLevel

The log level to check.

Returns

bool

true if 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

logLevel LogLevel

The log level of the message.

eventId EventId

The event ID of the message.

state TState

The state of the message.

exception Exception

The exception associated with the message, if any.

formatter Func<TState, Exception, string>

A function that formats the state and exception into a log message.

Type Parameters

TState

The type of the state.