Interface ILogger

Base interface for SDK loggers.

Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ContractsLogging
Assembly: Stylelabs.M.Sdk.dll
Syntax
RequestResponse
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
RequestResponse
bool IsDebugEnabled { get; }
Property Value
TypeDescription
bool

IsErrorEnabled

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

Declaration
RequestResponse
bool IsErrorEnabled { get; }
Property Value
TypeDescription
bool

IsInfoEnabled

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

Declaration
RequestResponse
bool IsInfoEnabled { get; }
Property Value
TypeDescription
bool

IsWarnEnabled

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

Declaration
RequestResponse
bool IsWarnEnabled { get; }
Property Value
TypeDescription
bool

MinimumLogLevel

Gets or sets the minimum enabled log level.

Declaration
RequestResponse
LogLevel MinimumLogLevel { get; set; }
Property Value
TypeDescription
LogLevel

Methods

Debug(Func<string>)

Logs debug-level information.

Declaration
RequestResponse
void Debug(Func<string> message)
Parameters
TypeNameDescription
Func<>stringmessage

Function that generates the log message.

Debug(string)

Logs debug-level information.

Declaration
RequestResponse
void Debug(string message)
Parameters
TypeNameDescription
stringmessage

Message to log.

DebugAsync(Func<Task<string>>)

Async version of Debug(Func<string>).

Declaration
RequestResponse
Task DebugAsync(Func<Task<string>> message)
Parameters
TypeNameDescription
Func<>Task<>stringmessage

Message to log.

Returns
TypeDescription
Task

A representing the asynchronous operation.

Error(Exception)

Logs error-level information.

Declaration
RequestResponse
void Error(Exception exception)
Parameters
TypeNameDescription
Exceptionexception

The exception that occurred.

Error(Func<string>, Exception)

Logs error-level information.

Declaration
RequestResponse
void Error(Func<string> message, Exception exception = null)
Parameters
TypeNameDescription
Func<>stringmessage

Function that generates the log message.

Exceptionexception

The exception that occurred.

Error(string, Exception)

Logs error-level information.

Declaration
RequestResponse
void Error(string message, Exception exception = null)
Parameters
TypeNameDescription
stringmessage

Message to log.

Exceptionexception

The exception that occurred.

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

Async version of Error(Func<string>, Exception).

Declaration
RequestResponse
Task ErrorAsync(Func<Task<string>> message, Exception exception = null)
Parameters
TypeNameDescription
Func<>Task<>stringmessage

Function that generates the log message.

Exceptionexception

The exception that occurred.

Returns
TypeDescription
Task

A representing the asynchronous operation.

Info(Func<string>)

Logs info-level information.

Declaration
RequestResponse
void Info(Func<string> message)
Parameters
TypeNameDescription
Func<>stringmessage

Function that generates the log message.

Info(string)

Logs info-level information.

Declaration
RequestResponse
void Info(string message)
Parameters
TypeNameDescription
stringmessage

Message to log.

InfoAsync(Func<Task<string>>)

Async version of Info(Func<string>).

Declaration
RequestResponse
Task InfoAsync(Func<Task<string>> message)
Parameters
TypeNameDescription
Func<>Task<>stringmessage

Function that generates the log message.

Returns
TypeDescription
Task

A representing the asynchronous operation.

Warn(Func<string>)

Logs warning-level information.

Declaration
RequestResponse
void Warn(Func<string> message)
Parameters
TypeNameDescription
Func<>stringmessage

Function that generates the log message.

Warn(string)

Logs warning-level information.

Declaration
RequestResponse
void Warn(string message)
Parameters
TypeNameDescription
stringmessage

Message to log.

WarnAsync(Func<Task<string>>)

Async version of Warn(Func<string>).

Declaration
RequestResponse
Task WarnAsync(Func<Task<string>> message)
Parameters
TypeNameDescription
Func<>Task<>stringmessage

Function that generates the log message.

Returns
TypeDescription
Task

A representing the asynchronous operation.

Events

OnLog

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

Declaration
RequestResponse
event EventHandler<LogEventArgs> OnLog
Event Type
TypeDescription
EventHandler<>LogEventArgs

Do you have some feedback for us?

If you have suggestions for improving this article,