-
-
Notifications
You must be signed in to change notification settings - Fork 210
/
SentryLoggingOptionsSetup.cs
42 lines (36 loc) · 1.31 KB
/
SentryLoggingOptionsSetup.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
#if NET6_0_OR_GREATER
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.Configuration;
using Microsoft.Extensions.Options;
namespace Sentry.Extensions.Logging;
// TODO: Re-enable these if we find a solution to https://github.com/dotnet/runtime/discussions/94651
#pragma warning disable SYSLIB1100
#pragma warning disable SYSLIB1101
internal class SentryLoggingOptionsSetup : IConfigureOptions<SentryLoggingOptions>
{
private readonly IConfiguration _config;
public SentryLoggingOptionsSetup(ILoggerProviderConfiguration<SentryLoggerProvider> config)
{
ArgumentNullException.ThrowIfNull(config);
_config = config.Configuration;
}
public virtual void Configure(SentryLoggingOptions options)
{
ArgumentNullException.ThrowIfNull(options);
_config.Bind(options);
}
}
#pragma warning restore SYSLIB1100
#pragma warning restore SYSLIB1101
#else
using Microsoft.Extensions.Logging.Configuration;
using Microsoft.Extensions.Options;
namespace Sentry.Extensions.Logging;
internal class SentryLoggingOptionsSetup : ConfigureFromConfigurationOptions<SentryLoggingOptions>
{
public SentryLoggingOptionsSetup(
ILoggerProviderConfiguration<SentryLoggerProvider> providerConfiguration)
: base(providerConfiguration.Configuration)
{ }
}
#endif