logo
logo

Interface ILogger

Base interface for SDK loggers.

Namespace: Stylelabs.M.Sdk.Contracts.Logging
Assembly: Stylelabs.M.Sdk.dll
Syntax
public interface ILogger
Remarks

Performance tips:

  • For static or constant strings, construct and pass the string directly.
  • For dynamic strings that require IO, make sure to pass a to the logger.
  • It is recommended to always pass a for debugging messages. This way, when debugging is disabled, the debug calls will have virtually no overhead. If you construct and pass strings directly, it will always have more overhead.

Properties

IsDebugEnabled

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

Declaration
bool IsDebugEnabled { get; }
Property Value
Type Description
System.Boolean

IsErrorEnabled

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

Declaration
bool IsErrorEnabled { get; }
Property Value
Type Description
System.Boolean

IsInfoEnabled

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

Declaration
bool IsInfoEnabled { get; }
Property Value
Type Description
System.Boolean

IsWarnEnabled

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

Declaration
bool IsWarnEnabled { get; }
Property Value
Type Description
System.Boolean

MinimumLogLevel

Gets or sets the minimum enabled log level.

Declaration
LogLevel MinimumLogLevel { get; set; }
Property Value
Type Description
LogLevel

Methods

Debug(Func<String>)

Logs debug-level information.

Declaration
void Debug(Func<string> message)
Parameters
Type Name Description
Func<System.String> message

Function that generates the log message.

Debug(String)

Logs debug-level information.

Declaration
void Debug(string message)
Parameters
Type Name Description
System.String message

Message to log.

DebugAsync(Func<Task<String>>)

Async version of Debug(Func<String>).

Declaration
Task DebugAsync(Func<Task<string>> message)
Parameters
Type Name Description
Func<Task<System.String>> message

Message to log.

Returns
Type Description
Task

A representing the asynchronous operation.

Error(Exception)

Logs error-level information.

Declaration
void Error(Exception exception)
Parameters
Type Name Description
Exception exception

The exception that occurred.

Error(Func<String>, Exception)

Logs error-level information.

Declaration
void Error(Func<string> message, Exception exception = null)
Parameters
Type Name Description
Func<System.String> message

Function that generates the log message.

Exception exception

The exception that occurred.

Error(String, Exception)

Logs error-level information.

Declaration
void Error(string message, Exception exception = null)
Parameters
Type Name Description
System.String message

Message to log.

Exception exception

The exception that occurred.

ErrorAsync(Func<Task<String>>, Exception)

Declaration
Task ErrorAsync(Func<Task<string>> message, Exception exception = null)
Parameters
Type Name Description
Func<Task<System.String>> message

Function that generates the log message.

Exception exception

The exception that occurred.

Returns
Type Description
Task

A representing the asynchronous operation.

Info(Func<String>)

Logs info-level information.

Declaration
void Info(Func<string> message)
Parameters
Type Name Description
Func<System.String> message

Function that generates the log message.

Info(String)

Logs info-level information.

Declaration
void Info(string message)
Parameters
Type Name Description
System.String message

Message to log.

InfoAsync(Func<Task<String>>)

Async version of Info(Func<String>).

Declaration
Task InfoAsync(Func<Task<string>> message)
Parameters
Type Name Description
Func<Task<System.String>> message

Function that generates the log message.

Returns
Type Description
Task

A representing the asynchronous operation.

Warn(Func<String>)

Logs warning-level information.

Declaration
void Warn(Func<string> message)
Parameters
Type Name Description
Func<System.String> message

Function that generates the log message.

Warn(String)

Logs warning-level information.

Declaration
void Warn(string message)
Parameters
Type Name Description
System.String message

Message to log.

WarnAsync(Func<Task<String>>)

Async version of Warn(Func<String>).

Declaration
Task WarnAsync(Func<Task<string>> message)
Parameters
Type Name Description
Func<Task<System.String>> message

Function that generates the log message.

Returns
Type Description
Task

A representing the asynchronous operation.

Events

OnLog

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

Declaration
event EventHandler<LogEventArgs> OnLog
Event Type
Type Description
EventHandler<LogEventArgs>

Can we improve this article ? Provide feedback