@@ -28,12 +28,7 @@ public static class LoggerExtensions
28
28
/// <example>logger.LogDebug(0, exception, "Error while processing request from {Address}", address)</example>
29
29
public static void LogDebug ( this ILogger logger , EventId eventId , Exception exception , string message , params object [ ] args )
30
30
{
31
- if ( logger == null )
32
- {
33
- throw new ArgumentNullException ( nameof ( logger ) ) ;
34
- }
35
-
36
- logger . Log ( LogLevel . Debug , eventId , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
31
+ logger . Log ( LogLevel . Debug , eventId , exception , message , args ) ;
37
32
}
38
33
39
34
/// <summary>
@@ -46,12 +41,7 @@ public static void LogDebug(this ILogger logger, EventId eventId, Exception exce
46
41
/// <example>logger.LogDebug(0, "Processing request from {Address}", address)</example>
47
42
public static void LogDebug ( this ILogger logger , EventId eventId , string message , params object [ ] args )
48
43
{
49
- if ( logger == null )
50
- {
51
- throw new ArgumentNullException ( nameof ( logger ) ) ;
52
- }
53
-
54
- logger . Log ( LogLevel . Debug , eventId , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
44
+ logger . Log ( LogLevel . Debug , eventId , message , args ) ;
55
45
}
56
46
57
47
/// <summary>
@@ -64,12 +54,7 @@ public static void LogDebug(this ILogger logger, EventId eventId, string message
64
54
/// <example>logger.LogDebug(exception, "Error while processing request from {Address}", address)</example>
65
55
public static void LogDebug ( this ILogger logger , Exception exception , string message , params object [ ] args )
66
56
{
67
- if ( logger == null )
68
- {
69
- throw new ArgumentNullException ( nameof ( logger ) ) ;
70
- }
71
-
72
- logger . Log ( LogLevel . Debug , 0 , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
57
+ logger . Log ( LogLevel . Debug , exception , message , args ) ;
73
58
}
74
59
75
60
/// <summary>
@@ -81,12 +66,7 @@ public static void LogDebug(this ILogger logger, Exception exception, string mes
81
66
/// <example>logger.LogDebug("Processing request from {Address}", address)</example>
82
67
public static void LogDebug ( this ILogger logger , string message , params object [ ] args )
83
68
{
84
- if ( logger == null )
85
- {
86
- throw new ArgumentNullException ( nameof ( logger ) ) ;
87
- }
88
-
89
- logger . Log ( LogLevel . Debug , 0 , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
69
+ logger . Log ( LogLevel . Debug , message , args ) ;
90
70
}
91
71
92
72
//------------------------------------------TRACE------------------------------------------//
@@ -102,12 +82,7 @@ public static void LogDebug(this ILogger logger, string message, params object[]
102
82
/// <example>logger.LogTrace(0, exception, "Error while processing request from {Address}", address)</example>
103
83
public static void LogTrace ( this ILogger logger , EventId eventId , Exception exception , string message , params object [ ] args )
104
84
{
105
- if ( logger == null )
106
- {
107
- throw new ArgumentNullException ( nameof ( logger ) ) ;
108
- }
109
-
110
- logger . Log ( LogLevel . Trace , eventId , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
85
+ logger . Log ( LogLevel . Trace , eventId , exception , message , args ) ;
111
86
}
112
87
113
88
/// <summary>
@@ -120,12 +95,7 @@ public static void LogTrace(this ILogger logger, EventId eventId, Exception exce
120
95
/// <example>logger.LogTrace(0, "Processing request from {Address}", address)</example>
121
96
public static void LogTrace ( this ILogger logger , EventId eventId , string message , params object [ ] args )
122
97
{
123
- if ( logger == null )
124
- {
125
- throw new ArgumentNullException ( nameof ( logger ) ) ;
126
- }
127
-
128
- logger . Log ( LogLevel . Trace , eventId , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
98
+ logger . Log ( LogLevel . Trace , eventId , message , args ) ;
129
99
}
130
100
131
101
/// <summary>
@@ -138,12 +108,7 @@ public static void LogTrace(this ILogger logger, EventId eventId, string message
138
108
/// <example>logger.LogTrace(exception, "Error while processing request from {Address}", address)</example>
139
109
public static void LogTrace ( this ILogger logger , Exception exception , string message , params object [ ] args )
140
110
{
141
- if ( logger == null )
142
- {
143
- throw new ArgumentNullException ( nameof ( logger ) ) ;
144
- }
145
-
146
- logger . Log ( LogLevel . Trace , 0 , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
111
+ logger . Log ( LogLevel . Trace , exception , message , args ) ;
147
112
}
148
113
149
114
/// <summary>
@@ -155,12 +120,7 @@ public static void LogTrace(this ILogger logger, Exception exception, string mes
155
120
/// <example>logger.LogTrace("Processing request from {Address}", address)</example>
156
121
public static void LogTrace ( this ILogger logger , string message , params object [ ] args )
157
122
{
158
- if ( logger == null )
159
- {
160
- throw new ArgumentNullException ( nameof ( logger ) ) ;
161
- }
162
-
163
- logger . Log ( LogLevel . Trace , 0 , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
123
+ logger . Log ( LogLevel . Trace , message , args ) ;
164
124
}
165
125
166
126
//------------------------------------------INFORMATION------------------------------------------//
@@ -176,12 +136,7 @@ public static void LogTrace(this ILogger logger, string message, params object[]
176
136
/// <example>logger.LogInformation(0, exception, "Error while processing request from {Address}", address)</example>
177
137
public static void LogInformation ( this ILogger logger , EventId eventId , Exception exception , string message , params object [ ] args )
178
138
{
179
- if ( logger == null )
180
- {
181
- throw new ArgumentNullException ( nameof ( logger ) ) ;
182
- }
183
-
184
- logger . Log ( LogLevel . Information , eventId , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
139
+ logger . Log ( LogLevel . Information , eventId , exception , message , args ) ;
185
140
}
186
141
187
142
/// <summary>
@@ -194,12 +149,7 @@ public static void LogInformation(this ILogger logger, EventId eventId, Exceptio
194
149
/// <example>logger.LogInformation(0, "Processing request from {Address}", address)</example>
195
150
public static void LogInformation ( this ILogger logger , EventId eventId , string message , params object [ ] args )
196
151
{
197
- if ( logger == null )
198
- {
199
- throw new ArgumentNullException ( nameof ( logger ) ) ;
200
- }
201
-
202
- logger . Log ( LogLevel . Information , eventId , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
152
+ logger . Log ( LogLevel . Information , eventId , message , args ) ;
203
153
}
204
154
205
155
/// <summary>
@@ -212,12 +162,7 @@ public static void LogInformation(this ILogger logger, EventId eventId, string m
212
162
/// <example>logger.LogInformation(exception, "Error while processing request from {Address}", address)</example>
213
163
public static void LogInformation ( this ILogger logger , Exception exception , string message , params object [ ] args )
214
164
{
215
- if ( logger == null )
216
- {
217
- throw new ArgumentNullException ( nameof ( logger ) ) ;
218
- }
219
-
220
- logger . Log ( LogLevel . Information , 0 , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
165
+ logger . Log ( LogLevel . Information , exception , message , args ) ;
221
166
}
222
167
223
168
/// <summary>
@@ -229,12 +174,7 @@ public static void LogInformation(this ILogger logger, Exception exception, stri
229
174
/// <example>logger.LogInformation("Processing request from {Address}", address)</example>
230
175
public static void LogInformation ( this ILogger logger , string message , params object [ ] args )
231
176
{
232
- if ( logger == null )
233
- {
234
- throw new ArgumentNullException ( nameof ( logger ) ) ;
235
- }
236
-
237
- logger . Log ( LogLevel . Information , 0 , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
177
+ logger . Log ( LogLevel . Information , message , args ) ;
238
178
}
239
179
240
180
//------------------------------------------WARNING------------------------------------------//
@@ -250,12 +190,7 @@ public static void LogInformation(this ILogger logger, string message, params ob
250
190
/// <example>logger.LogWarning(0, exception, "Error while processing request from {Address}", address)</example>
251
191
public static void LogWarning ( this ILogger logger , EventId eventId , Exception exception , string message , params object [ ] args )
252
192
{
253
- if ( logger == null )
254
- {
255
- throw new ArgumentNullException ( nameof ( logger ) ) ;
256
- }
257
-
258
- logger . Log ( LogLevel . Warning , eventId , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
193
+ logger . Log ( LogLevel . Warning , eventId , exception , message , args ) ;
259
194
}
260
195
261
196
/// <summary>
@@ -268,12 +203,7 @@ public static void LogWarning(this ILogger logger, EventId eventId, Exception ex
268
203
/// <example>logger.LogWarning(0, "Processing request from {Address}", address)</example>
269
204
public static void LogWarning ( this ILogger logger , EventId eventId , string message , params object [ ] args )
270
205
{
271
- if ( logger == null )
272
- {
273
- throw new ArgumentNullException ( nameof ( logger ) ) ;
274
- }
275
-
276
- logger . Log ( LogLevel . Warning , eventId , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
206
+ logger . Log ( LogLevel . Warning , eventId , message , args ) ;
277
207
}
278
208
279
209
/// <summary>
@@ -286,12 +216,7 @@ public static void LogWarning(this ILogger logger, EventId eventId, string messa
286
216
/// <example>logger.LogWarning(exception, "Error while processing request from {Address}", address)</example>
287
217
public static void LogWarning ( this ILogger logger , Exception exception , string message , params object [ ] args )
288
218
{
289
- if ( logger == null )
290
- {
291
- throw new ArgumentNullException ( nameof ( logger ) ) ;
292
- }
293
-
294
- logger . Log ( LogLevel . Warning , 0 , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
219
+ logger . Log ( LogLevel . Warning , exception , message , args ) ;
295
220
}
296
221
297
222
/// <summary>
@@ -303,12 +228,7 @@ public static void LogWarning(this ILogger logger, Exception exception, string m
303
228
/// <example>logger.LogWarning("Processing request from {Address}", address)</example>
304
229
public static void LogWarning ( this ILogger logger , string message , params object [ ] args )
305
230
{
306
- if ( logger == null )
307
- {
308
- throw new ArgumentNullException ( nameof ( logger ) ) ;
309
- }
310
-
311
- logger . Log ( LogLevel . Warning , 0 , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
231
+ logger . Log ( LogLevel . Warning , message , args ) ;
312
232
}
313
233
314
234
//------------------------------------------ERROR------------------------------------------//
@@ -324,12 +244,7 @@ public static void LogWarning(this ILogger logger, string message, params object
324
244
/// <example>logger.LogError(0, exception, "Error while processing request from {Address}", address)</example>
325
245
public static void LogError ( this ILogger logger , EventId eventId , Exception exception , string message , params object [ ] args )
326
246
{
327
- if ( logger == null )
328
- {
329
- throw new ArgumentNullException ( nameof ( logger ) ) ;
330
- }
331
-
332
- logger . Log ( LogLevel . Error , eventId , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
247
+ logger . Log ( LogLevel . Error , eventId , exception , message , args ) ;
333
248
}
334
249
335
250
/// <summary>
@@ -342,12 +257,7 @@ public static void LogError(this ILogger logger, EventId eventId, Exception exce
342
257
/// <example>logger.LogError(0, "Processing request from {Address}", address)</example>
343
258
public static void LogError ( this ILogger logger , EventId eventId , string message , params object [ ] args )
344
259
{
345
- if ( logger == null )
346
- {
347
- throw new ArgumentNullException ( nameof ( logger ) ) ;
348
- }
349
-
350
- logger . Log ( LogLevel . Error , eventId , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
260
+ logger . Log ( LogLevel . Error , eventId , message , args ) ;
351
261
}
352
262
353
263
/// <summary>
@@ -360,12 +270,7 @@ public static void LogError(this ILogger logger, EventId eventId, string message
360
270
/// <example>logger.LogError(exception, "Error while processing request from {Address}", address)</example>
361
271
public static void LogError ( this ILogger logger , Exception exception , string message , params object [ ] args )
362
272
{
363
- if ( logger == null )
364
- {
365
- throw new ArgumentNullException ( nameof ( logger ) ) ;
366
- }
367
-
368
- logger . Log ( LogLevel . Error , 0 , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
273
+ logger . Log ( LogLevel . Error , exception , message , args ) ;
369
274
}
370
275
371
276
/// <summary>
@@ -377,12 +282,7 @@ public static void LogError(this ILogger logger, Exception exception, string mes
377
282
/// <example>logger.LogError("Processing request from {Address}", address)</example>
378
283
public static void LogError ( this ILogger logger , string message , params object [ ] args )
379
284
{
380
- if ( logger == null )
381
- {
382
- throw new ArgumentNullException ( nameof ( logger ) ) ;
383
- }
384
-
385
- logger . Log ( LogLevel . Error , 0 , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
285
+ logger . Log ( LogLevel . Error , message , args ) ;
386
286
}
387
287
388
288
//------------------------------------------CRITICAL------------------------------------------//
@@ -398,12 +298,7 @@ public static void LogError(this ILogger logger, string message, params object[]
398
298
/// <example>logger.LogCritical(0, exception, "Error while processing request from {Address}", address)</example>
399
299
public static void LogCritical ( this ILogger logger , EventId eventId , Exception exception , string message , params object [ ] args )
400
300
{
401
- if ( logger == null )
402
- {
403
- throw new ArgumentNullException ( nameof ( logger ) ) ;
404
- }
405
-
406
- logger . Log ( LogLevel . Critical , eventId , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
301
+ logger . Log ( LogLevel . Critical , eventId , exception , message , args ) ;
407
302
}
408
303
409
304
/// <summary>
@@ -416,12 +311,7 @@ public static void LogCritical(this ILogger logger, EventId eventId, Exception e
416
311
/// <example>logger.LogCritical(0, "Processing request from {Address}", address)</example>
417
312
public static void LogCritical ( this ILogger logger , EventId eventId , string message , params object [ ] args )
418
313
{
419
- if ( logger == null )
420
- {
421
- throw new ArgumentNullException ( nameof ( logger ) ) ;
422
- }
423
-
424
- logger . Log ( LogLevel . Critical , eventId , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
314
+ logger . Log ( LogLevel . Critical , eventId , message , args ) ;
425
315
}
426
316
427
317
/// <summary>
@@ -434,12 +324,7 @@ public static void LogCritical(this ILogger logger, EventId eventId, string mess
434
324
/// <example>logger.LogCritical(exception, "Error while processing request from {Address}", address)</example>
435
325
public static void LogCritical ( this ILogger logger , Exception exception , string message , params object [ ] args )
436
326
{
437
- if ( logger == null )
438
- {
439
- throw new ArgumentNullException ( nameof ( logger ) ) ;
440
- }
441
-
442
- logger . Log ( LogLevel . Critical , 0 , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
327
+ logger . Log ( LogLevel . Critical , exception , message , args ) ;
443
328
}
444
329
445
330
/// <summary>
@@ -451,30 +336,64 @@ public static void LogCritical(this ILogger logger, Exception exception, string
451
336
/// <example>logger.LogCritical("Processing request from {Address}", address)</example>
452
337
public static void LogCritical ( this ILogger logger , string message , params object [ ] args )
453
338
{
454
- if ( logger == null )
455
- {
456
- throw new ArgumentNullException ( nameof ( logger ) ) ;
457
- }
339
+ logger . Log ( LogLevel . Critical , message , args ) ;
340
+ }
458
341
459
- logger . Log ( LogLevel . Critical , 0 , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
342
+ /// <summary>
343
+ /// Formats and writes a log message at the specified log level.
344
+ /// </summary>
345
+ /// <param name="logger">The <see cref="ILogger"/> to write to.</param>
346
+ /// <param name="logLevel">Entry will be written on this level.</param>
347
+ /// <param name="message">Format string of the log message.</param>
348
+ /// <param name="args">An object array that contains zero or more objects to format.</param>
349
+ public static void Log ( this ILogger logger , LogLevel logLevel , string message , params object [ ] args )
350
+ {
351
+ logger . Log ( logLevel , 0 , null , message , args ) ;
460
352
}
461
353
354
+ /// <summary>
355
+ /// Formats and writes a log message at the specified log level.
356
+ /// </summary>
357
+ /// <param name="logger">The <see cref="ILogger"/> to write to.</param>
358
+ /// <param name="logLevel">Entry will be written on this level.</param>
359
+ /// <param name="eventId">The event id associated with the log.</param>
360
+ /// <param name="message">Format string of the log message.</param>
361
+ /// <param name="args">An object array that contains zero or more objects to format.</param>
362
+ public static void Log ( this ILogger logger , LogLevel logLevel , EventId eventId , string message , params object [ ] args )
363
+ {
364
+ logger . Log ( logLevel , eventId , null , message , args ) ;
365
+ }
462
366
463
367
/// <summary>
464
- /// Formats and writes a log message on specified log level.
368
+ /// Formats and writes a log message at the specified log level.
465
369
/// </summary>
466
370
/// <param name="logger">The <see cref="ILogger"/> to write to.</param>
467
371
/// <param name="logLevel">Entry will be written on this level.</param>
372
+ /// <param name="exception">The exception to log.</param>
468
373
/// <param name="message">Format string of the log message.</param>
469
374
/// <param name="args">An object array that contains zero or more objects to format.</param>
470
- public static void Log ( this ILogger logger , LogLevel logLevel , string message , params object [ ] args )
375
+ public static void Log ( this ILogger logger , LogLevel logLevel , Exception exception , string message , params object [ ] args )
376
+ {
377
+ logger . Log ( logLevel , 0 , exception , message , args ) ;
378
+ }
379
+
380
+ /// <summary>
381
+ /// Formats and writes a log message at the specified log level.
382
+ /// </summary>
383
+ /// <param name="logger">The <see cref="ILogger"/> to write to.</param>
384
+ /// <param name="logLevel">Entry will be written on this level.</param>
385
+ /// <param name="eventId">The event id associated with the log.</param>
386
+ /// <param name="exception">The exception to log.</param>
387
+ /// <param name="message">Format string of the log message.</param>
388
+ /// <param name="args">An object array that contains zero or more objects to format.</param>
389
+ public static void Log ( this ILogger logger , LogLevel logLevel , EventId eventId , Exception exception , string message , params object [ ] args )
471
390
{
472
391
if ( logger == null )
473
392
{
474
393
throw new ArgumentNullException ( nameof ( logger ) ) ;
475
394
}
476
395
477
- logger . Log ( logLevel , 0 , new FormattedLogValues ( message , args ) , null , _messageFormatter ) ;
396
+ logger . Log ( logLevel , eventId , new FormattedLogValues ( message , args ) , exception , _messageFormatter ) ;
478
397
}
479
398
480
399
//------------------------------------------Scope------------------------------------------//
0 commit comments