@@ -5,87 +5,88 @@ namespace DtronixPackage.Logging;
5
5
6
6
public static class LoggerExtensions
7
7
{
8
+ private const string NoMessage = "No message from exception" ;
8
9
// Trace
9
- public static void Trace ( this ILogger logger , Exception exception ) {
10
- logger . Log ( new LogEntry ( LogEntryEventType . Trace , exception . Message , exception ) ) ;
10
+ public static void Trace ( this ILogger logger , Exception ? exception ) {
11
+ logger . Log ( new LogEntry ( LogEntryEventType . Trace , exception ? . Message ?? NoMessage , exception ) ) ;
11
12
}
12
13
13
14
public static void Trace ( this ILogger logger , string message ) {
14
15
logger . Log ( new LogEntry ( LogEntryEventType . Trace , message ) ) ;
15
16
}
16
17
17
- public static void Trace ( this ILogger logger , Exception exception , string message ) {
18
+ public static void Trace ( this ILogger logger , Exception ? exception , string message ) {
18
19
logger . Log ( new LogEntry ( LogEntryEventType . Trace , message , exception ) ) ;
19
20
}
20
21
21
22
// Debug
22
- public static void Debug ( this ILogger logger , Exception exception ) {
23
- logger . Log ( new LogEntry ( LogEntryEventType . Debug , exception . Message , exception ) ) ;
23
+ public static void Debug ( this ILogger logger , Exception ? exception ) {
24
+ logger . Log ( new LogEntry ( LogEntryEventType . Debug , exception ? . Message ?? NoMessage , exception ) ) ;
24
25
}
25
26
26
27
public static void Debug ( this ILogger logger , string message ) {
27
28
logger . Log ( new LogEntry ( LogEntryEventType . Debug , message ) ) ;
28
29
}
29
30
30
- public static void Debug ( this ILogger logger , Exception exception , string message ) {
31
+ public static void Debug ( this ILogger logger , Exception ? exception , string message ) {
31
32
logger . Log ( new LogEntry ( LogEntryEventType . Debug , message , exception ) ) ;
32
33
}
33
34
34
35
// Info
35
- public static void Info ( this ILogger logger , Exception exception ) {
36
- logger . Log ( new LogEntry ( LogEntryEventType . Info , exception . Message , exception ) ) ;
36
+ public static void Info ( this ILogger logger , Exception ? exception ) {
37
+ logger . Log ( new LogEntry ( LogEntryEventType . Info , exception ? . Message ?? NoMessage , exception ) ) ;
37
38
}
38
39
39
40
public static void Info ( this ILogger logger , string message ) {
40
41
logger . Log ( new LogEntry ( LogEntryEventType . Info , message ) ) ;
41
42
}
42
43
43
- public static void Info ( this ILogger logger , Exception exception , string message ) {
44
+ public static void Info ( this ILogger logger , Exception ? exception , string message ) {
44
45
logger . Log ( new LogEntry ( LogEntryEventType . Info , message , exception ) ) ;
45
46
}
46
47
47
48
// Warn
48
- public static void Warn ( this ILogger logger , Exception exception ) {
49
- logger . Log ( new LogEntry ( LogEntryEventType . Warn , exception . Message , exception ) ) ;
49
+ public static void Warn ( this ILogger logger , Exception ? exception ) {
50
+ logger . Log ( new LogEntry ( LogEntryEventType . Warn , exception ? . Message ?? NoMessage , exception ) ) ;
50
51
}
51
52
52
53
public static void Warn ( this ILogger logger , string message ) {
53
54
logger . Log ( new LogEntry ( LogEntryEventType . Warn , message ) ) ;
54
55
}
55
56
56
- public static void Warn ( this ILogger logger , Exception exception , string message ) {
57
+ public static void Warn ( this ILogger logger , Exception ? exception , string message ) {
57
58
logger . Log ( new LogEntry ( LogEntryEventType . Warn , message , exception ) ) ;
58
59
}
59
60
60
61
// Error
61
- public static void Error ( this ILogger logger , Exception exception ) {
62
- logger . Log ( new LogEntry ( LogEntryEventType . Error , exception . Message , exception ) ) ;
62
+ public static void Error ( this ILogger logger , Exception ? exception ) {
63
+ logger . Log ( new LogEntry ( LogEntryEventType . Error , exception ? . Message ?? NoMessage , exception ) ) ;
63
64
}
64
65
65
66
public static void Error ( this ILogger logger , string message ) {
66
67
logger . Log ( new LogEntry ( LogEntryEventType . Error , message ) ) ;
67
68
}
68
69
69
- public static void Error ( this ILogger logger , Exception exception , string message ) {
70
+ public static void Error ( this ILogger logger , Exception ? exception , string message ) {
70
71
logger . Log ( new LogEntry ( LogEntryEventType . Error , message , exception ) ) ;
71
72
}
72
73
73
74
// Fatal
74
- public static void Fatal ( this ILogger logger , Exception exception ) {
75
- logger . Log ( new LogEntry ( LogEntryEventType . Fatal , exception . Message , exception ) ) ;
75
+ public static void Fatal ( this ILogger logger , Exception ? exception ) {
76
+ logger . Log ( new LogEntry ( LogEntryEventType . Fatal , exception ? . Message ?? NoMessage , exception ) ) ;
76
77
}
77
78
78
79
public static void Fatal ( this ILogger logger , string message ) {
79
80
logger . Log ( new LogEntry ( LogEntryEventType . Fatal , message ) ) ;
80
81
}
81
82
82
- public static void Fatal ( this ILogger logger , Exception exception , string message ) {
83
+ public static void Fatal ( this ILogger logger , Exception ? exception , string message ) {
83
84
logger . Log ( new LogEntry ( LogEntryEventType . Fatal , message , exception ) ) ;
84
85
}
85
86
86
87
[ Conditional ( "DEBUG" ) ]
87
- public static void ConditionalDebug ( this ILogger logger , Exception exception ) {
88
- logger . Log ( new LogEntry ( LogEntryEventType . Debug , exception . Message , exception ) ) ;
88
+ public static void ConditionalDebug ( this ILogger logger , Exception ? exception ) {
89
+ logger . Log ( new LogEntry ( LogEntryEventType . Debug , exception ? . Message ?? NoMessage , exception ) ) ;
89
90
}
90
91
91
92
[ Conditional ( "DEBUG" ) ]
@@ -94,7 +95,7 @@ public static void ConditionalDebug(this ILogger logger, string message) {
94
95
}
95
96
96
97
[ Conditional ( "DEBUG" ) ]
97
- public static void ConditionalDebug ( this ILogger logger , string message , Exception exception ) {
98
+ public static void ConditionalDebug ( this ILogger logger , string message , Exception ? exception ) {
98
99
logger . Log ( new LogEntry ( LogEntryEventType . Debug , message , exception ) ) ;
99
100
}
100
101
@@ -104,12 +105,12 @@ public static void ConditionalTrace(this ILogger logger, string message) {
104
105
}
105
106
106
107
[ Conditional ( "DEBUG" ) ]
107
- public static void ConditionalTrace ( this ILogger logger , Exception exception ) {
108
- logger . Log ( new LogEntry ( LogEntryEventType . Trace , exception . Message , exception ) ) ;
108
+ public static void ConditionalTrace ( this ILogger logger , Exception ? exception ) {
109
+ logger . Log ( new LogEntry ( LogEntryEventType . Trace , exception ? . Message ?? NoMessage , exception ) ) ;
109
110
}
110
111
111
112
[ Conditional ( "DEBUG" ) ]
112
- public static void ConditionalTrace ( this ILogger logger , string message , Exception exception ) {
113
+ public static void ConditionalTrace ( this ILogger logger , string message , Exception ? exception ) {
113
114
logger . Log ( new LogEntry ( LogEntryEventType . Trace , message , exception ) ) ;
114
115
}
115
116
}
0 commit comments