< Summary - Jellyfin

Information
Class: Jellyfin.Server.ServerSetupApp.StartupLogger<T>
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/ServerSetupApp/StartupLoggerOfCategory.cs
Line coverage
28%
Covered lines: 4
Uncovered lines: 10
Coverable lines: 14
Total lines: 56
Line coverage: 28.5%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
.ctor(...)100%11100%
Jellyfin.Server.ServerSetupApp.IStartupLogger<TCategory>.BeginGroup(...)0%2040%
Jellyfin.Server.ServerSetupApp.IStartupLogger<TCategory>.With(...)100%210%

File(s)

/srv/git/jellyfin/Jellyfin.Server/ServerSetupApp/StartupLoggerOfCategory.cs

#LineLine coverage
 1using System;
 2using System.Globalization;
 3using Microsoft.Extensions.Logging;
 4
 5namespace Jellyfin.Server.ServerSetupApp;
 6
 7/// <summary>
 8/// Startup logger for usage with DI that utilises an underlying logger from the DI.
 9/// </summary>
 10/// <typeparam name="TCategory">The category of the underlying logger.</typeparam>
 11#pragma warning disable SA1649 // File name should match first type name
 12public class StartupLogger<TCategory> : StartupLogger, IStartupLogger<TCategory>
 13#pragma warning restore SA1649 // File name should match first type name
 14{
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="StartupLogger{TCategory}"/> class.
 17    /// </summary>
 18    /// <param name="logger">The injected base logger.</param>
 2119    public StartupLogger(ILogger<TCategory> logger) : base(logger)
 20    {
 2121    }
 22
 23    /// <summary>
 24    /// Initializes a new instance of the <see cref="StartupLogger{TCategory}"/> class.
 25    /// </summary>
 26    /// <param name="logger">The underlying base logger.</param>
 27    /// <param name="groupEntry">The group for this logger.</param>
 2128    internal StartupLogger(ILogger logger, StartupLogTopic? groupEntry) : base(logger, groupEntry)
 29    {
 2130    }
 31
 32    IStartupLogger<TCategory> IStartupLogger<TCategory>.BeginGroup(FormattableString logEntry)
 33    {
 034        var startupEntry = new StartupLogTopic()
 035        {
 036            Content = logEntry.ToString(CultureInfo.InvariantCulture),
 037            DateOfCreation = DateTimeOffset.Now
 038        };
 39
 040        if (Topic is null)
 41        {
 042            SetupServer.LogQueue?.Enqueue(startupEntry);
 43        }
 44        else
 45        {
 046            Topic.Children.Add(startupEntry);
 47        }
 48
 049        return new StartupLogger<TCategory>(BaseLogger, startupEntry);
 50    }
 51
 52    IStartupLogger<TCategory> IStartupLogger<TCategory>.With(ILogger logger)
 53    {
 054        return new StartupLogger<TCategory>(logger, Topic);
 55    }
 56}