Logger Class
Namespace: Stride.Core.DiagnosticsAssembly: Stride.Core.dll
Base implementation for ILogger.
public abstract class Logger : ILogger
Name | Description | |
---|---|---|
Constructors | ||
Logger() | Initializes a new instance of the Logger class. |
|
Fields | ||
EnableTypes | ||
IsDebugEnabled | True if the debug level is enabled at a global level |
|
IsVerboseEnabled | True if the verbose level is enabled at a global level |
|
Properties | ||
HasErrors | Gets or sets a value indicating whether this instance has errors. |
|
MinimumLevelEnabled | Gets the minimum level enabled from the config file. Can be overridden by the user. |
|
Module | Gets the module name. read-only. |
|
Methods | ||
Activated(LogMessageType) | Returns a boolean indicating if a particular LogMessageType is activated. |
|
ActivateLog(LogMessageType, LogMessageType, Boolean) | Activates the log for this logger for a range of LogMessageType. |
|
ActivateLog(LogMessageType, Boolean) | Activates the log for this logger for a specific LogMessageType. |
|
Debug(String, CallerInfo) | Logs the specified debug message. |
|
Debug(String, Exception, CallerInfo) | Logs the specified debug message with an exception. |
|
Error(String, CallerInfo) | Logs the specified error message. |
|
Error(String, Exception, CallerInfo) | Logs the specified error message with an exception. |
|
Fatal(String, CallerInfo) | Logs the specified fatal message. |
|
Fatal(String, Exception, CallerInfo) | Logs the specified fatal message with an exception. |
|
Info(String, CallerInfo) | Logs the specified info message. |
|
Info(String, Exception, CallerInfo) | Logs the specified info message with an exception. |
|
Log(ILogMessage) | ||
LogRaw(ILogMessage) | Internal method used to log a message. All Info, Debug, Error...etc. methods are calling this method. |
|
Verbose(String, CallerInfo) | Logs the specified verbose message. |
|
Verbose(String, Exception, CallerInfo) | Logs the specified verbose message with an exception. |
|
Warning(String, CallerInfo) | Logs the specified warning message. |
|
Warning(String, Exception, CallerInfo) | Logs the specified warning message with an exception. |
|
Events | ||
MessageLogged | Occurs when a message is logged. |
Constructors
Logger()
Initializes a new instance of the Logger class.
protected Logger()
Fields
EnableTypes
protected readonly bool[] EnableTypes
Field Value
Type | Description |
---|---|
System.Boolean[] |
IsDebugEnabled
True if the debug level is enabled at a global level
public static readonly bool IsDebugEnabled
Field Value
Type | Description |
---|---|
System.Boolean |
IsVerboseEnabled
True if the verbose level is enabled at a global level
public static readonly bool IsVerboseEnabled
Field Value
Type | Description |
---|---|
System.Boolean |
Properties
HasErrors
Gets or sets a value indicating whether this instance has errors.
public bool HasErrors { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
MinimumLevelEnabled
Gets the minimum level enabled from the config file. Can be overridden by the user.
public static LogMessageType MinimumLevelEnabled { get; set; }
Property Value
Type | Description |
---|---|
LogMessageType |
Module
Gets the module name. read-only.
public string Module { get; protected set; }
Property Value
Type | Description |
---|---|
System.String | The module name. |
Methods
Activated(LogMessageType)
Returns a boolean indicating if a particular LogMessageType is activated.
public bool Activated(LogMessageType type)
Parameters
Type | Name | Description |
---|---|---|
LogMessageType | type | The type. |
Returns
Type | Description |
---|---|
System.Boolean | True if the log is activated, otherwise false. |
ActivateLog(LogMessageType, LogMessageType, Boolean)
Activates the log for this logger for a range of LogMessageType.
public void ActivateLog(LogMessageType fromLevel, LogMessageType toLevel = LogMessageType.Fatal, bool enabledFlag = true)
Parameters
Type | Name | Description |
---|---|---|
LogMessageType | fromLevel | The lowest inclusive level to log for. |
LogMessageType | toLevel | The highest inclusive level to log for. |
System.Boolean | enabledFlag | if set to |
Remarks
Outside the specified range the log message type are disabled (!enabledFlag).
ActivateLog(LogMessageType, Boolean)
Activates the log for this logger for a specific LogMessageType.
public void ActivateLog(LogMessageType type, bool enabledFlag)
Parameters
Type | Name | Description |
---|---|---|
LogMessageType | type | The type. |
System.Boolean | enabledFlag | if set to |
Remarks
All other activated type are leaved intact.
Debug(String, CallerInfo)
Logs the specified debug message.
public void Debug(string message, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The debug message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Debug(String, Exception, CallerInfo)
Logs the specified debug message with an exception.
public void Debug(string message, Exception exception, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The debug message. |
System.Exception | exception | An exception to log with the message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Error(String, CallerInfo)
Logs the specified error message.
public void Error(string message, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The error message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Error(String, Exception, CallerInfo)
Logs the specified error message with an exception.
public void Error(string message, Exception exception, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The error message. |
System.Exception | exception | An exception to log with the message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Fatal(String, CallerInfo)
Logs the specified fatal message.
public void Fatal(string message, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The fatal message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Fatal(String, Exception, CallerInfo)
Logs the specified fatal message with an exception.
public void Fatal(string message, Exception exception, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The fatal message. |
System.Exception | exception | An exception to log with the message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Info(String, CallerInfo)
Logs the specified info message.
public void Info(string message, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The info message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Info(String, Exception, CallerInfo)
Logs the specified info message with an exception.
public void Info(string message, Exception exception, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The info message. |
System.Exception | exception | An exception to log with the message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Log(ILogMessage)
public void Log(ILogMessage logMessage)
Parameters
Type | Name | Description |
---|---|---|
ILogMessage | logMessage |
LogRaw(ILogMessage)
Internal method used to log a message. All Info, Debug, Error...etc. methods are calling this method.
protected abstract void LogRaw(ILogMessage logMessage)
Parameters
Type | Name | Description |
---|---|---|
ILogMessage | logMessage | The log message. |
Verbose(String, CallerInfo)
Logs the specified verbose message.
public void Verbose(string message, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The verbose message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Verbose(String, Exception, CallerInfo)
Logs the specified verbose message with an exception.
public void Verbose(string message, Exception exception, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The verbose message. |
System.Exception | exception | An exception to log with the message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Warning(String, CallerInfo)
Logs the specified warning message.
public void Warning(string message, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The warning message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Warning(String, Exception, CallerInfo)
Logs the specified warning message with an exception.
public void Warning(string message, Exception exception, CallerInfo callerInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The warning message. |
System.Exception | exception | An exception to log with the message. |
CallerInfo | callerInfo | Information about the caller. Default is null, otherwise use Get(String, String, Int32). |
Events
MessageLogged
Occurs when a message is logged.
public event EventHandler<MessageLoggedEventArgs> MessageLogged
Event Type
Type | Description |
---|---|
System.EventHandler<MessageLoggedEventArgs> |