1. Stylelabs.M.Sdk.Models.Logging

Class LoggerBase

Base implementation of ILogger.

The minimum log level is info by default.

Inheritance

object

LoggerBase

ConsoleLogger

NullLogger

Implements

ILogger

Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ModelsLogging

Assembly: Stylelabs.M.Sdk.dll

Syntax

public abstract class LoggerBase : ILogger

Properties

IsDebugEnabled

Gets a value indicating whether debug-level logging is enabled.

Declaration

public bool IsDebugEnabled { get; }

Property Value

TypeDescription
bool

IsErrorEnabled

Gets a value indicating whether error-level logging is enabled.

Declaration

public bool IsErrorEnabled { get; }

Property Value

TypeDescription
bool

IsInfoEnabled

Gets a value indicating whether info-level logging is enabled.

Declaration

public bool IsInfoEnabled { get; }

Property Value

TypeDescription
bool

IsWarnEnabled

Gets a value indicating whether warning-level logging is enabled.

Declaration

public bool IsWarnEnabled { get; }

Property Value

TypeDescription
bool

MinimumLogLevel

Gets or sets the minimum enabled log level.

Declaration

public virtual LogLevel MinimumLogLevel { get; set; }

Property Value

TypeDescription
LogLevel

Methods

Debug(Func)

Logs debug-level information.

Declaration

public void Debug(Func<string> message)

Parameters

TypeNameDescription
Func<>stringmessageFunction that generates the log message.

Debug(string)

Logs debug-level information.

Declaration

public void Debug(string message)

Parameters

TypeNameDescription
stringmessageMessage to log.

DebugAsync(Func<Task>)

Async version of Debug(Func).

Declaration

public Task DebugAsync(Func<Task<string>> message)

Parameters

TypeNameDescription
Func<>Task<>stringmessageMessage to log.

Returns

TypeDescription
TaskA representing the asynchronous operation.

Error(Exception)

Logs error-level information.

Declaration

public void Error(Exception exception)

Parameters

TypeNameDescription
ExceptionexceptionThe exception that occurred.

Error(Func, Exception)

Logs error-level information.

Declaration

public void Error(Func<string> message, Exception exception = null)

Parameters

TypeNameDescription
Func<>stringmessageFunction that generates the log message.
ExceptionexceptionThe exception that occurred.

Error(string, Exception)

Logs error-level information.

Declaration

public void Error(string message, Exception exception = null)

Parameters

TypeNameDescription
stringmessageMessage to log.
ExceptionexceptionThe exception that occurred.

ErrorAsync(Func<Task>, Exception)

Async version of Error(Func, Exception).

Declaration

public Task ErrorAsync(Func<Task<string>> message, Exception exception = null)

Parameters

TypeNameDescription
Func<>Task<>stringmessageFunction that generates the log message.
ExceptionexceptionThe exception that occurred.

Returns

TypeDescription
TaskA representing the asynchronous operation.

Info(Func)

Logs info-level information.

Declaration

public void Info(Func<string> message)

Parameters

TypeNameDescription
Func<>stringmessageFunction that generates the log message.

Info(string)

Logs info-level information.

Declaration

public void Info(string message)

Parameters

TypeNameDescription
stringmessageMessage to log.

InfoAsync(Func<Task>)

Async version of Info(Func).

Declaration

public Task InfoAsync(Func<Task<string>> message)

Parameters

TypeNameDescription
Func<>Task<>stringmessageFunction that generates the log message.

Returns

TypeDescription
TaskA representing the asynchronous operation.

LogDebug(string)

Logs debug-level information.

Declaration

protected abstract void LogDebug(string message)

Parameters

TypeNameDescription
stringmessageThe message to log.

LogError(Exception)

Logs error-level information.

Declaration

protected abstract void LogError(Exception exception)

Parameters

TypeNameDescription
ExceptionexceptionThe exception to log.

LogError(string, Exception)

Logs error-level information.

Declaration

protected abstract void LogError(string message, Exception exception = null)

Parameters

TypeNameDescription
stringmessageThe message to log.
ExceptionexceptionThe exception to log.

LogInfo(string)

Logs info-level information.

Declaration

protected abstract void LogInfo(string message)

Parameters

TypeNameDescription
stringmessageThe message to log.

LogWarn(string)

Logs warning-level information.

Declaration

protected abstract void LogWarn(string message)

Parameters

TypeNameDescription
stringmessageThe message to log.

Warn(Func)

Logs warning-level information.

Declaration

public void Warn(Func<string> message)

Parameters

TypeNameDescription
Func<>stringmessageFunction that generates the log message.

Warn(string)

Logs warning-level information.

Declaration

public void Warn(string message)

Parameters

TypeNameDescription
stringmessageMessage to log.

WarnAsync(Func<Task>)

Async version of Warn(Func).

Declaration

public Task WarnAsync(Func<Task<string>> message)

Parameters

TypeNameDescription
Func<>Task<>stringmessageFunction that generates the log message.

Returns

TypeDescription
TaskA representing the asynchronous operation.

Events

OnLog

Fires an event just before something is about to be logged.

Declaration

public event EventHandler<LogEventArgs> OnLog

Event Type

TypeDescription
EventHandler<>LogEventArgs

Implements

ILogger

If you have suggestions for improving this article, let us know!