Class LogListener
- Namespace
- Stride.Core.Diagnostics
- Assembly
- Stride.Core.dll
A base class to implement a log listener
public abstract class LogListener : IDisposable
- Inheritance
-
objectLogListener
- Implements
- Derived
- Extension Methods
Constructors
LogListener()
Initializes a new instance of the LogListener class.
protected LogListener()
Properties
LogCountFlushLimit
Gets or sets the log count flush limit. Default is on every message.
public int LogCountFlushLimit { get; set; }
Property Value
- int
The log count flush limit.
LogMessageCount
Gets the log message count.
public int LogMessageCount { get; }
Property Value
- int
The log message count.
MinimumLevel
Gets or sets the minimum severity this listener handles; messages below it are dropped. Defaults to Debug, which lets everything through.
public LogMessageType MinimumLevel { get; set; }
Property Value
ModuleLevels
Gets the per-module overrides of MinimumLevel, keyed by Module. A listener can stay quiet overall while still following a few modules in detail. Safe to update while the listener is attached.
public ConcurrentDictionary<string, LogMessageType> ModuleLevels { get; }
Property Value
TextFormatter
Gets or sets the function that convert a ILogMessage instance into a string.
public Func<ILogMessage, string?> TextFormatter { get; set; }
Property Value
UseFlushAsync
Gets or sets a value indicating whether [use flush async].
public bool UseFlushAsync { get; set; }
Property Value
- bool
trueif [use flush async]; otherwise,false.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public virtual void Dispose()
Flush()
Flush the log, method to be implemented in a subclass.
protected virtual void Flush()
GetDefaultText(ILogMessage)
Gets the default text for a particular log message.
protected virtual string? GetDefaultText(ILogMessage logMessage)
Parameters
logMessageILogMessageThe log message.
Returns
- string
A textual representation of a message.
GetExceptionText(ILogMessage)
Gets the text that describes the exception associated to a particular log message.
protected virtual string GetExceptionText(ILogMessage message)
Parameters
messageILogMessageThe log message.
Returns
- string
A textual representation of the exception, or Empty if no exception is associated to this log message.
IsEnabled(ILogMessage)
Returns whether a message passes this listener's filter, and so should reach OnLog(ILogMessage). The default compares its severity against ModuleLevels, falling back to MinimumLevel. Override to add conditions of your own.
protected virtual bool IsEnabled(ILogMessage logMessage)
Parameters
logMessageILogMessageThe log message.
Returns
OnLog(ILogMessage)
Called when a log occurred.
protected abstract void OnLog(ILogMessage logMessage)
Parameters
logMessageILogMessageThe log message.
ShouldFlush(ILogMessage)
Returns a boolean indicating whether the log should be flushed. By default, flushing is occurring if the message has a higher level than Info
protected virtual bool ShouldFlush(ILogMessage logMessage)
Parameters
logMessageILogMessageThe log message.
Returns
- bool
trueif the log should be flushed,falseotherwise
Operators
implicit operator Action<ILogMessage>(LogListener)
Performs an implicit conversion from LogListener to Action<T>.
public static implicit operator Action<ILogMessage>(LogListener logListener)
Parameters
logListenerLogListenerThe log listener.
Returns
- Action<ILogMessage>
The result of the conversion.