/
ILogLevelConfigurator.cs
70 lines (65 loc) · 2.65 KB
/
ILogLevelConfigurator.cs
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
67
68
69
70
// Copyright (c) 2020 Sergio Aquilini
// This code is licensed under MIT license (see LICENSE file for details)
using System;
using Microsoft.Extensions.Logging;
using Silverback.Diagnostics;
namespace Silverback.Messaging.Configuration
{
/// <summary>
/// Configure and stores the <see cref="LogLevel"/> overrides.
/// </summary>
public interface ILogLevelConfigurator
{
/// <summary>
/// Configure the log level that should be applied to the specified event.
/// </summary>
/// <param name="eventId">
/// The event id.
/// </param>
/// <param name="logLevel">
/// The log level to apply.
/// </param>
/// <returns>
/// The <see cref="ILogLevelConfigurator" /> so that additional calls can be chained.
/// </returns>
ILogLevelConfigurator SetLogLevel(EventId eventId, LogLevel logLevel);
/// <summary>
/// Configure a delegate that determines the log level that should be applied to the specified event.
/// </summary>
/// <param name="eventId">
/// The event id.
/// </param>
/// <param name="logLevelFunc">
/// The function that returns the log level. It takes the logged exception and the default log level as
/// parameters.
/// </param>
/// <returns>
/// The <see cref="ILogLevelConfigurator" /> so that additional calls can be chained.
/// </returns>
ILogLevelConfigurator SetLogLevel(EventId eventId, Func<Exception?, LogLevel, LogLevel> logLevelFunc);
/// <summary>
/// Configure a delegate that determines the log level that should be applied to the specified event.
/// </summary>
/// <param name="eventId">
/// The event id.
/// </param>
/// <param name="logLevelFunc">
/// The function that returns the log level. It takes the logged exception, the message and the default
/// log level as
/// parameters.
/// </param>
/// <returns>
/// The <see cref="ILogLevelConfigurator" /> so that additional calls can be chained.
/// </returns>
ILogLevelConfigurator SetLogLevel(
EventId eventId,
Func<Exception?, LogLevel, Lazy<string>, LogLevel> logLevelFunc);
/// <summary>
/// Builds the <see cref="ILogLevelDictionary" /> based on the current state of the configurator.
/// </summary>
/// <returns>
/// The <see cref="ILogLevelDictionary" />.
/// </returns>
ILogLevelDictionary Build();
}
}