< Summary

Information
Class: Trailblazer.TrailblazerLogger
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Diagnostics/TrailblazerLogger.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 100
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
get_EnableDebugLogging()100%11100%
set_EnableDebugLogging(...)100%11100%
get_Channel()100%11100%
get_DebugChannel()100%11100%
get_MinimumLevel()100%11100%
set_MinimumLevel(...)100%11100%
get_LogHandler()100%11100%
set_LogHandler(...)100%11100%
get_CustomFormatter()100%11100%
set_CustomFormatter(...)100%11100%
IsEnabled(...)100%11100%
DefaultLogHandler(...)100%11100%
DefaultLogFormatter(...)100%11100%
.ctor()100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Diagnostics/TrailblazerLogger.cs

#LineLine coverage
 1global using SwiftCollections.Diagnostics;
 2
 3using System;
 4
 5namespace Trailblazer;
 6
 7/// <summary>
 8/// Provides centralized diagnostics for Trailblazer runtime code.
 9/// </summary>
 10/// <remarks>
 11/// Warning and error diagnostics are controlled through <see cref="MinimumLevel"/>.
 12/// Trace-style diagnostics that were previously debug-only are additionally gated by
 13/// <see cref="EnableDebugLogging"/> so hosts can opt into verbose runtime output explicitly.
 14/// </remarks>
 15public static class TrailblazerLogger
 16{
 117    private static readonly TrailblazerDiagnosticLogger _logger = new();
 18
 19    /// <summary>
 20    /// Gets or sets a value indicating whether verbose debug diagnostics should be emitted.
 21    /// </summary>
 22    public static bool EnableDebugLogging
 23    {
 624        get => _logger.EnableDebugLogging;
 1125        set => _logger.EnableDebugLogging = value;
 26    }
 27
 28    /// <summary>
 29    /// Gets the diagnostic channel used for Trailblazer warnings and errors.
 30    /// </summary>
 6231    public static DiagnosticChannel Channel => _logger.Channel;
 32
 33    /// <summary>
 34    /// Gets the diagnostic channel used for verbose debug diagnostics.
 35    /// </summary>
 211836    public static DiagnosticChannel DebugChannel => _logger.DebugChannel;
 37
 38    /// <summary>
 39    /// Gets or sets the minimum severity required for non-debug diagnostics to be emitted.
 40    /// </summary>
 41    public static DiagnosticLevel MinimumLevel
 42    {
 643        get => _logger.MinimumLevel;
 1444        set => _logger.MinimumLevel = value;
 45    }
 46
 47    /// <summary>
 48    /// Gets or sets the delegate used to write formatted log messages.
 49    /// Assigning <see langword="null"/> restores <see cref="DefaultLogHandler"/>.
 50    /// </summary>
 51    public static Action<DiagnosticLevel, string, string> LogHandler
 52    {
 653        get => _logger.LogHandler;
 1054        set => _logger.LogHandler = value;
 55    }
 56
 57    /// <summary>
 58    /// Gets or sets the formatter used to transform log arguments into a final log entry.
 59    /// Assigning <see langword="null"/> restores <see cref="DefaultLogFormatter"/>.
 60    /// </summary>
 61    public static Func<DiagnosticLevel, string, string, string> CustomFormatter
 62    {
 663        get => _logger.CustomFormatter;
 664        set => _logger.CustomFormatter = value;
 65    }
 66
 67    /// <summary>
 68    /// Determines whether non-debug diagnostics at the specified level are currently enabled.
 69    /// </summary>
 70    /// <param name="level">The diagnostic level to evaluate.</param>
 71    /// <returns><see langword="true"/> when messages at <paramref name="level"/> will be emitted; otherwise, <see langw
 72    public static bool IsEnabled(DiagnosticLevel level)
 73    {
 474        return _logger.IsEnabled(level);
 75    }
 76
 77    /// <summary>
 78    /// The default handler for Trailblazer log messages.
 79    /// </summary>
 80    public static void DefaultLogHandler(DiagnosticLevel level, string message, string source)
 81    {
 182        _logger.DefaultLogHandler(level, message, source);
 183    }
 84
 85    /// <summary>
 86    /// Formats a Trailblazer log entry using a deterministic, source-first layout.
 87    /// </summary>
 88    public static string DefaultLogFormatter(DiagnosticLevel level, string message, string source)
 89    {
 190        return _logger.DefaultLogFormatter(level, message, source);
 91    }
 92
 93    private sealed class TrailblazerDiagnosticLogger : DiagnosticLogger
 94    {
 95        public TrailblazerDiagnosticLogger()
 196            : base("Trailblazer")
 97        {
 198        }
 99    }
 100}