forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpgsqlLogManager.cs
More file actions
42 lines (36 loc) · 1.32 KB
/
NpgsqlLogManager.cs
File metadata and controls
42 lines (36 loc) · 1.32 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
39
40
41
42
using System;
namespace Npgsql.Logging
{
/// <summary>
/// Manages logging for Npgsql, used to set the logging provider.
/// </summary>
public static class NpgsqlLogManager
{
/// <summary>
/// The logging provider used for logging in Npgsql.
/// </summary>
public static INpgsqlLoggingProvider Provider
{
get
{
_providerRetrieved = true;
return _provider!;
}
set
{
if (_providerRetrieved)
throw new InvalidOperationException("The logging provider must be set before any Npgsql action is taken");
_provider = value ?? throw new ArgumentNullException(nameof(value));
}
}
/// <summary>
/// Determines whether parameter contents will be logged alongside SQL statements - this may reveal sensitive information.
/// Defaults to false.
/// </summary>
public static bool IsParameterLoggingEnabled { get; set; }
static INpgsqlLoggingProvider? _provider;
static bool _providerRetrieved;
internal static NpgsqlLogger CreateLogger(string name) => Provider.CreateLogger("Npgsql." + name);
static NpgsqlLogManager() => Provider = new NoOpLoggingProvider();
}
}