-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathDelegateLogEntryFilter.cs
More file actions
35 lines (30 loc) · 992 Bytes
/
DelegateLogEntryFilter.cs
File metadata and controls
35 lines (30 loc) · 992 Bytes
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
using Microsoft.Extensions.Logging;
namespace Sentry.Extensions.Logging;
/// <summary>
/// An implementation of <see cref="T:Sentry.Extensions.Logging.ILogEntryFilter" /> that invokes a <see cref="T:System.Func`1" />
/// </summary>
/// <inheritdoc />
public class DelegateLogEntryFilter : ILogEntryFilter
{
private readonly Func<string, LogLevel, EventId, Exception?, bool> _filter;
/// <summary>
/// Creates a new instance of <see cref="DelegateLogEntryFilter"/>
/// </summary>
/// <param name="filter"></param>
public DelegateLogEntryFilter(Func<string, LogLevel, EventId, Exception?, bool> filter)
{
ArgumentNullException.ThrowIfNull(filter);
_filter = filter;
}
/// <inheritdoc />
public bool Filter(
string categoryName,
LogLevel logLevel,
EventId eventId,
Exception? exception)
=> _filter(
categoryName,
logLevel,
eventId,
exception);
}