Class DiagnosticLogger
- Namespace
- SwiftCollections.Diagnostics
- Assembly
- SwiftCollections.dll
Provides reusable logger state and diagnostic channels for libraries built on SwiftCollections diagnostics.
public abstract class DiagnosticLogger
- Inheritance
-
DiagnosticLogger
- Inherited Members
Remarks
Static logger facades can delegate to a derived instance of this type while keeping their existing public API.
Constructors
DiagnosticLogger(string)
Initializes a new instance of the DiagnosticLogger class.
protected DiagnosticLogger(string channelName)
Parameters
channelNamestringThe diagnostic channel name.
Properties
Channel
Gets the diagnostic channel used for normal diagnostics.
public DiagnosticChannel Channel { get; }
Property Value
CustomFormatter
Gets or sets the formatter used to transform log arguments into a final log entry. Assigning null restores DefaultLogFormatter(DiagnosticLevel, string, string).
public Func<DiagnosticLevel, string, string, string> CustomFormatter { get; set; }
Property Value
DebugChannel
Gets the diagnostic channel used for verbose debug diagnostics.
public DiagnosticChannel DebugChannel { get; }
Property Value
EnableDebugLogging
Gets or sets a value indicating whether verbose debug diagnostics should be emitted.
public bool EnableDebugLogging { get; set; }
Property Value
LogHandler
Gets or sets the delegate used to write formatted log messages. Assigning null restores DefaultLogHandler(DiagnosticLevel, string, string).
public Action<DiagnosticLevel, string, string> LogHandler { get; set; }
Property Value
MinimumLevel
Gets or sets the minimum severity required for normal diagnostics to be emitted.
public DiagnosticLevel MinimumLevel { get; set; }
Property Value
Name
Gets the logger name.
public string Name { get; }
Property Value
Methods
DefaultLogFormatter(DiagnosticLevel, string, string)
Formats a log entry using a deterministic, source-first layout.
public virtual string DefaultLogFormatter(DiagnosticLevel level, string message, string source)
Parameters
levelDiagnosticLevelThe severity level of the log message.
messagestringThe log message.
sourcestringThe source of the log message.
Returns
- string
A formatted log entry.
DefaultLogHandler(DiagnosticLevel, string, string)
Writes a log message using the current CustomFormatter.
public virtual void DefaultLogHandler(DiagnosticLevel level, string message, string source)
Parameters
levelDiagnosticLevelThe severity level of the log message.
messagestringThe log message.
sourcestringThe source of the log message.
HandleDiagnosticEvent(in DiagnosticEvent)
Receives diagnostics emitted by either channel.
protected virtual void HandleDiagnosticEvent(in DiagnosticEvent diagnostic)
Parameters
diagnosticDiagnosticEventThe emitted diagnostic event.
IsEnabled(DiagnosticLevel)
Determines whether normal diagnostics at the specified level are currently enabled.
public bool IsEnabled(DiagnosticLevel level)
Parameters
levelDiagnosticLevelThe diagnostic level to evaluate.
Returns
ResolveSource(in DiagnosticEvent)
Resolves the source value passed to LogHandler.
protected virtual string ResolveSource(in DiagnosticEvent diagnostic)
Parameters
diagnosticDiagnosticEventThe emitted diagnostic event.
Returns
- string
The resolved source.