< Summary

Information
Class: MyNet.Utilities.Logging.Log<T>
Assembly: MyNet.Utilities
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Utilities/Logging/Log.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 48
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
get_Instance()100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Utilities/Logging/Log.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="Log.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using Microsoft.Extensions.Logging;
 8using Microsoft.Extensions.Logging.Abstractions;
 9
 10namespace MyNet.Utilities.Logging;
 11
 12/// <summary>
 13/// Provides a static logging utility that allows for creating loggers using a configurable logger factory, with a conve
 14/// </summary>
 15/// <typeparam name="T">The type to use as the logger category.</typeparam>
 16public static class Log<T>
 17{
 18    /// <summary>
 19    /// Gets a logger instance for the specified category type using the configured logger factory. This property provid
 20    /// </summary>
 321    public static ILogger Instance => Log.Factory.CreateLogger<T>();
 22}
 23
 24/// <summary>
 25/// Provides a static logging utility that allows for creating loggers using a configurable logger factory.
 26/// </summary>
 27public static class Log
 28{
 29    /// <summary>
 30    /// Gets or sets the logger factory used to create loggers. By default, it is set to a null logger factory that prod
 31    /// </summary>
 32    public static ILoggerFactory Factory { get; set; } = NullLoggerFactory.Instance;
 33
 34    /// <summary>
 35    /// Creates a logger for the specified category type using the configured logger factory.
 36    /// </summary>
 37    /// <typeparam name="T">The type to use as the logger category.</typeparam>
 38    /// <returns>A logger instance for the specified category type.</returns>
 39    public static ILogger<T> Create<T>() => Factory.CreateLogger<T>();
 40
 41    /// <summary>
 42    /// Creates a logger for the specified category name using the configured logger factory.
 43    /// </summary>
 44    /// <param name="category">The category name for the logger.</param>
 45    /// <returns>A logger instance for the specified category name.</returns>
 46    public static ILogger Create(string category) => Factory.CreateLogger(category);
 47}
 48

Methods/Properties

get_Instance()