forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogging.extensions.cs
153 lines (125 loc) · 6.46 KB
/
Logging.extensions.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using System;
namespace NHibernate
{
/// <summary>
/// Extensions method for logging.
/// </summary>
public static class NHibernateLoggerExtensions
{
public static bool IsDebugEnabled(this INHibernateLogger logger) => logger.IsEnabled(NHibernateLogLevel.Debug);
public static bool IsInfoEnabled(this INHibernateLogger logger) => logger.IsEnabled(NHibernateLogLevel.Info);
public static bool IsWarnEnabled(this INHibernateLogger logger) => logger.IsEnabled(NHibernateLogLevel.Warn);
public static bool IsErrorEnabled(this INHibernateLogger logger) => logger.IsEnabled(NHibernateLogLevel.Error);
public static bool IsFatalEnabled(this INHibernateLogger logger) => logger.IsEnabled(NHibernateLogLevel.Fatal);
public static void Fatal(this INHibernateLogger logger, Exception exception, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Fatal, new NHibernateLogValues(format, args), exception);
}
public static void Fatal(this INHibernateLogger logger, Exception exception, string message)
{
logger.Log(NHibernateLogLevel.Fatal, new NHibernateLogValues(message, null), exception);
}
public static void Fatal(this INHibernateLogger logger, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Fatal, new NHibernateLogValues(format, args), null);
}
public static void Fatal(this INHibernateLogger logger, string message)
{
logger.Log(NHibernateLogLevel.Fatal, new NHibernateLogValues(message, null), null);
}
public static void Error(this INHibernateLogger logger, Exception exception, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Error, new NHibernateLogValues(format, args), exception);
}
public static void Error(this INHibernateLogger logger, Exception exception, string message)
{
logger.Log(NHibernateLogLevel.Error, new NHibernateLogValues(message, null), exception);
}
public static void Error(this INHibernateLogger logger, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Error, new NHibernateLogValues(format, args), null);
}
public static void Error(this INHibernateLogger logger, string message)
{
logger.Log(NHibernateLogLevel.Error, new NHibernateLogValues(message, null), null);
}
public static void Warn(this INHibernateLogger logger, Exception exception, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Warn, new NHibernateLogValues(format, args), exception);
}
public static void Warn(this INHibernateLogger logger, Exception exception, string message)
{
logger.Log(NHibernateLogLevel.Warn, new NHibernateLogValues(message, null), exception);
}
public static void Warn(this INHibernateLogger logger, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Warn, new NHibernateLogValues(format, args), null);
}
public static void Warn(this INHibernateLogger logger, string message)
{
logger.Log(NHibernateLogLevel.Warn, new NHibernateLogValues(message, null), null);
}
public static void Info(this INHibernateLogger logger, Exception exception, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Info, new NHibernateLogValues(format, args), exception);
}
public static void Info(this INHibernateLogger logger, Exception exception, string message)
{
logger.Log(NHibernateLogLevel.Info, new NHibernateLogValues(message, null), exception);
}
public static void Info(this INHibernateLogger logger, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Info, new NHibernateLogValues(format, args), null);
}
public static void Info(this INHibernateLogger logger, string message)
{
logger.Log(NHibernateLogLevel.Info, new NHibernateLogValues(message, null), null);
}
public static void Debug(this INHibernateLogger logger, Exception exception, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Debug, new NHibernateLogValues(format, args), exception);
}
public static void Debug(this INHibernateLogger logger, Exception exception, string message)
{
logger.Log(NHibernateLogLevel.Debug, new NHibernateLogValues(message, null), exception);
}
public static void Debug(this INHibernateLogger logger, string format, params object[] args)
{
logger.Log(NHibernateLogLevel.Debug, new NHibernateLogValues(format, args), null);
}
public static void Debug(this INHibernateLogger logger, string message)
{
logger.Log(NHibernateLogLevel.Debug, new NHibernateLogValues(message, null), null);
}
// catch any method calls with an Exception argument second as they would otherwise silently be consumed by `params object[] args`.
/// <summary>
/// Throws NotImplementedException. Calling this method is an error. Please use methods taking the exception as first argument instead.
/// </summary>
[Obsolete("Use Fatal(Exception, string, params object[])", true)]
public static void Fatal(this INHibernateLogger logger, string message, Exception ex) => ThrowNotImplemented();
/// <summary>
/// Throws NotImplementedException. Calling this method is an error. Please use methods taking the exception as first argument instead.
/// </summary>
[Obsolete("Use Error(Exception, string, params object[])", true)]
public static void Error(this INHibernateLogger logger, string message, Exception ex) => ThrowNotImplemented();
/// <summary>
/// Throws NotImplementedException. Calling this method is an error. Please use methods taking the exception as first argument instead.
/// </summary>
[Obsolete("Use Warn(Exception, string, params object[])", true)]
public static void Warn(this INHibernateLogger logger, string message, Exception ex) => ThrowNotImplemented();
/// <summary>
/// Throws NotImplementedException. Calling this method is an error. Please use methods taking the exception as first argument instead.
/// </summary>
[Obsolete("Use Info(Exception, string, params object[])", true)]
public static void Info(this INHibernateLogger logger, string message, Exception ex) => ThrowNotImplemented();
/// <summary>
/// Throws NotImplementedException. Calling this method is an error. Please use methods taking the exception as first argument instead.
/// </summary>
[Obsolete("Use Debug(Exception, string, params object[])", true)]
public static void Debug(this INHibernateLogger logger, string message, Exception ex) => ThrowNotImplemented();
private static void ThrowNotImplemented()
{
throw new NotImplementedException("Should not have compiled with call to this method");
}
}
}