aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/ServerSetupApp/IStartupLogger.cs
blob: e7c1939368db57e270043ff5803b4347844ab1c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using ILogger = Microsoft.Extensions.Logging.ILogger;

namespace Jellyfin.Server.ServerSetupApp;

/// <summary>
/// Defines the Startup Logger. This logger acts an an aggregate logger that will push though all log messages to both the attached logger as well as the startup UI.
/// </summary>
public interface IStartupLogger : ILogger
{
    /// <summary>
    /// Gets the topic this logger is assigned to.
    /// </summary>
    StartupLogTopic? Topic { get; }

    /// <summary>
    /// Adds another logger instance to this logger for combined logging.
    /// </summary>
    /// <param name="logger">Other logger to rely messages to.</param>
    /// <returns>A combined logger.</returns>
    IStartupLogger With(ILogger logger);

    /// <summary>
    /// Opens a new Group logger within the parent logger.
    /// </summary>
    /// <param name="logEntry">Defines the log message that introduces the new group.</param>
    /// <returns>A new logger that can write to the group.</returns>
    IStartupLogger BeginGroup(FormattableString logEntry);

    /// <summary>
    /// Adds another logger instance to this logger for combined logging.
    /// </summary>
    /// <param name="logger">Other logger to rely messages to.</param>
    /// <returns>A combined logger.</returns>
    /// <typeparam name="TCategory">The logger cateogry.</typeparam>
    IStartupLogger<TCategory> With<TCategory>(ILogger logger);

    /// <summary>
    /// Opens a new Group logger within the parent logger.
    /// </summary>
    /// <param name="logEntry">Defines the log message that introduces the new group.</param>
    /// <returns>A new logger that can write to the group.</returns>
    /// <typeparam name="TCategory">The logger cateogry.</typeparam>
    IStartupLogger<TCategory> BeginGroup<TCategory>(FormattableString logEntry);
}

/// <summary>
/// Defines a logger that can be injected via DI to get a startup logger initialised with an logger framework connected <see cref="ILogger"/>.
/// </summary>
/// <typeparam name="TCategory">The logger cateogry.</typeparam>
public interface IStartupLogger<TCategory> : IStartupLogger
{
    /// <summary>
    /// Adds another logger instance to this logger for combined logging.
    /// </summary>
    /// <param name="logger">Other logger to rely messages to.</param>
    /// <returns>A combined logger.</returns>
    new IStartupLogger<TCategory> With(ILogger logger);

    /// <summary>
    /// Opens a new Group logger within the parent logger.
    /// </summary>
    /// <param name="logEntry">Defines the log message that introduces the new group.</param>
    /// <returns>A new logger that can write to the group.</returns>
    new IStartupLogger<TCategory> BeginGroup(FormattableString logEntry);
}