-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUltzLogger.cs
More file actions
38 lines (33 loc) · 1.26 KB
/
UltzLogger.cs
File metadata and controls
38 lines (33 loc) · 1.26 KB
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
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace Ultz.Extensions.Logging
{
/// <summary>
/// An implementation of <see cref="ILogger" /> but with support for extra customization. This is the heart of
/// the Ultz Logger.
/// </summary>
internal sealed class UltzLogger : ILogger
{
private readonly string _name;
private readonly UltzLoggerProvider _parent;
internal UltzLogger(string categoryName, UltzLoggerProvider parent)
{
_name = categoryName;
_parent = parent;
}
/// <inheritdoc />
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception,
Func<TState, Exception, string> formatter) =>
_parent.Log(_name, logLevel, eventId, state, exception, formatter);
/// <inheritdoc />
public bool IsEnabled(LogLevel logLevel) => _parent.LogLevels.Contains(logLevel);
/// <inheritdoc />
public IDisposable BeginScope<TState>(TState state)
=> _parent.ScopeProvider?.Push(state) ?? NopScopeProvider.NopScope.Instance;
}
}