Class Logger
- Namespace
- Stride.Core.Diagnostics
- Assembly
- Stride.Core.dll
Base implementation for ILogger.
public abstract class Logger : ILogger
- Inheritance
-
objectLogger
- Implements
- Derived
- Extension Methods
Constructors
Logger()
Initializes a new instance of the Logger class.
protected Logger()
Fields
EnableTypes
protected readonly bool[] EnableTypes
Field Value
- bool[]
IsDebugEnabled
True if the debug level is enabled at a global level
public static readonly bool IsDebugEnabled
Field Value
IsVerboseEnabled
True if the verbose level is enabled at a global level
public static readonly bool IsVerboseEnabled
Field Value
Properties
HasErrors
Gets or sets a value indicating whether this instance has errors.
public bool HasErrors { get; set; }
Property Value
- bool
trueif this instance has errors; otherwise,false.
MinimumLevelEnabled
Gets the minimum level enabled from the config file. Can be overridden by the user.
public static LogMessageType MinimumLevelEnabled { get; set; }
Property Value
Module
Gets the module name. read-only.
public string? Module { get; protected set; }
Property Value
- string
The module name.
Methods
ActivateLog(LogMessageType, LogMessageType, bool)
Activates the log for this logger for a range of LogMessageType.
public void ActivateLog(LogMessageType fromLevel, LogMessageType toLevel = LogMessageType.Fatal, bool enabledFlag = true)
Parameters
fromLevelLogMessageTypeThe lowest inclusive level to log for.
toLevelLogMessageTypeThe highest inclusive level to log for.
enabledFlagboolif set to
truethis will enable the log, false otherwise. Default is true.
Remarks
Outside the specified range the log message type are disabled (!enabledFlag).
ActivateLog(LogMessageType, bool)
Activates the log for this logger for a specific LogMessageType.
public void ActivateLog(LogMessageType type, bool enabledFlag)
Parameters
typeLogMessageTypeThe type.
enabledFlagboolif set to
true[enabled flag].
Remarks
All other activated type are leaved intact.
Activated(LogMessageType)
Returns a boolean indicating if a particular LogMessageType is activated.
public bool Activated(LogMessageType type)
Parameters
typeLogMessageTypeThe type.
Returns
- bool
True if the log is activated, otherwise false.
Debug(string, CallerInfo?)
Logs the specified debug message.
public void Debug(string message, CallerInfo? callerInfo = null)
Parameters
messagestringThe debug message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Debug(string, Exception?, CallerInfo?)
Logs the specified debug message with an exception.
public void Debug(string message, Exception? exception, CallerInfo? callerInfo = null)
Parameters
messagestringThe debug message.
exceptionExceptionAn exception to log with the message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Error(string, CallerInfo?)
Logs the specified error message.
public void Error(string message, CallerInfo? callerInfo = null)
Parameters
messagestringThe error message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Error(string, Exception?, CallerInfo?)
Logs the specified error message with an exception.
public void Error(string message, Exception? exception, CallerInfo? callerInfo = null)
Parameters
messagestringThe error message.
exceptionExceptionAn exception to log with the message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Fatal(string, CallerInfo?)
Logs the specified fatal message.
public void Fatal(string message, CallerInfo? callerInfo = null)
Parameters
messagestringThe fatal message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Fatal(string, Exception?, CallerInfo?)
Logs the specified fatal message with an exception.
public void Fatal(string message, Exception? exception, CallerInfo? callerInfo = null)
Parameters
messagestringThe fatal message.
exceptionExceptionAn exception to log with the message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Info(string, CallerInfo?)
Logs the specified info message.
public void Info(string message, CallerInfo? callerInfo = null)
Parameters
messagestringThe info message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Info(string, Exception?, CallerInfo?)
Logs the specified info message with an exception.
public void Info(string message, Exception? exception, CallerInfo? callerInfo = null)
Parameters
messagestringThe info message.
exceptionExceptionAn exception to log with the message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Log(ILogMessage)
Logs the specified log message.
public void Log(ILogMessage logMessage)
Parameters
logMessageILogMessageThe log message.
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
logMessageILogMessageThe log message.
Verbose(string, CallerInfo?)
Logs the specified verbose message.
public void Verbose(string message, CallerInfo? callerInfo = null)
Parameters
messagestringThe verbose message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Verbose(string, Exception?, CallerInfo?)
Logs the specified verbose message with an exception.
public void Verbose(string message, Exception? exception, CallerInfo? callerInfo = null)
Parameters
messagestringThe verbose message.
exceptionExceptionAn exception to log with the message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Warning(string, CallerInfo?)
Logs the specified warning message.
public void Warning(string message, CallerInfo? callerInfo = null)
Parameters
messagestringThe warning message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Warning(string, Exception?, CallerInfo?)
Logs the specified warning message with an exception.
public void Warning(string message, Exception? exception, CallerInfo? callerInfo = null)
Parameters
messagestringThe warning message.
exceptionExceptionAn exception to log with the message.
callerInfoCallerInfoInformation about the caller. Default is null, otherwise use Get(string, string, int).
Events
MessageLogged
Occurs when a message is logged.
public event EventHandler<MessageLoggedEventArgs>? MessageLogged