@@ -81,6 +81,29 @@ extension Logger {
81
81
}
82
82
}
83
83
84
+ /// Log a message passing the log level as a parameter.
85
+ ///
86
+ /// If the `logLevel` passed to this method is more severe than the `Logger`'s `logLevel`, it will be logged,
87
+ /// otherwise nothing will happen.
88
+ ///
89
+ /// - parameters:
90
+ /// - level: The log level to log `message` at. For the available log levels, see `Logger.Level`.
91
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
92
+ /// - metadata: One-off metadata to attach to this log message.
93
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
94
+ /// defaults to `#file`).
95
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
96
+ /// it defaults to `#function`).
97
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
98
+ /// defaults to `#line`).
99
+ @inlinable
100
+ public func log( level: Logger . Level ,
101
+ _ message: @autoclosure ( ) -> Logger . Message ,
102
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
103
+ file: String = #file, function: String = #function, line: UInt = #line) {
104
+ self . log ( level: level, message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
105
+ }
106
+
84
107
/// Add, change, or remove a logging metadata item.
85
108
///
86
109
/// - note: Logging metadata behaves as a value that means a change to the logging metadata will only affect the
@@ -137,6 +160,25 @@ extension Logger {
137
160
self . log ( level: . trace, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
138
161
}
139
162
163
+ /// If `.trace` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
164
+ /// otherwise nothing will happen.
165
+ ///
166
+ /// - parameters:
167
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
168
+ /// - metadata: One-off metadata to attach to this log message
169
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
170
+ /// defaults to `#file`).
171
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
172
+ /// it defaults to `#function`).
173
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
174
+ /// defaults to `#line`).
175
+ @inlinable
176
+ public func trace( _ message: @autoclosure ( ) -> Logger . Message ,
177
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
178
+ file: String = #file, function: String = #function, line: UInt = #line) {
179
+ self . trace ( message ( ) , metadata: metadata ( ) , source: nil , file: file, line: line)
180
+ }
181
+
140
182
/// Log a message passing with the `Logger.Level.debug` log level.
141
183
///
142
184
/// If `.debug` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -161,6 +203,27 @@ extension Logger {
161
203
self . log ( level: . debug, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
162
204
}
163
205
206
+ /// Log a message passing with the `Logger.Level.debug` log level.
207
+ ///
208
+ /// If `.debug` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
209
+ /// otherwise nothing will happen.
210
+ ///
211
+ /// - parameters:
212
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
213
+ /// - metadata: One-off metadata to attach to this log message.
214
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
215
+ /// defaults to `#file`).
216
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
217
+ /// it defaults to `#function`).
218
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
219
+ /// defaults to `#line`).
220
+ @inlinable
221
+ public func debug( _ message: @autoclosure ( ) -> Logger . Message ,
222
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
223
+ file: String = #file, function: String = #function, line: UInt = #line) {
224
+ self . debug ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
225
+ }
226
+
164
227
/// Log a message passing with the `Logger.Level.info` log level.
165
228
///
166
229
/// If `.info` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -185,6 +248,27 @@ extension Logger {
185
248
self . log ( level: . info, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
186
249
}
187
250
251
+ /// Log a message passing with the `Logger.Level.info` log level.
252
+ ///
253
+ /// If `.info` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
254
+ /// otherwise nothing will happen.
255
+ ///
256
+ /// - parameters:
257
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
258
+ /// - metadata: One-off metadata to attach to this log message.
259
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
260
+ /// defaults to `#file`).
261
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
262
+ /// it defaults to `#function`).
263
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
264
+ /// defaults to `#line`).
265
+ @inlinable
266
+ public func info( _ message: @autoclosure ( ) -> Logger . Message ,
267
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
268
+ file: String = #file, function: String = #function, line: UInt = #line) {
269
+ self . info ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
270
+ }
271
+
188
272
/// Log a message passing with the `Logger.Level.notice` log level.
189
273
///
190
274
/// If `.notice` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -209,6 +293,29 @@ extension Logger {
209
293
self . log ( level: . notice, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
210
294
}
211
295
296
+ /// Log a message passing with the `Logger.Level.notice` log level.
297
+ ///
298
+ /// If `.notice` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
299
+ /// otherwise nothing will happen.
300
+ ///
301
+ /// - parameters:
302
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
303
+ /// - metadata: One-off metadata to attach to this log message.
304
+ /// - source: The source this log messages originates to. Currently, it defaults to the folder containing the
305
+ /// file that is emitting the log message, which usually is the module.
306
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
307
+ /// defaults to `#file`).
308
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
309
+ /// it defaults to `#function`).
310
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
311
+ /// defaults to `#line`).
312
+ @inlinable
313
+ public func notice( _ message: @autoclosure ( ) -> Logger . Message ,
314
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
315
+ file: String = #file, function: String = #function, line: UInt = #line) {
316
+ self . notice ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
317
+ }
318
+
212
319
/// Log a message passing with the `Logger.Level.warning` log level.
213
320
///
214
321
/// If `.warning` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -233,6 +340,27 @@ extension Logger {
233
340
self . log ( level: . warning, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
234
341
}
235
342
343
+ /// Log a message passing with the `Logger.Level.warning` log level.
344
+ ///
345
+ /// If `.warning` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
346
+ /// otherwise nothing will happen.
347
+ ///
348
+ /// - parameters:
349
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
350
+ /// - metadata: One-off metadata to attach to this log message.
351
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
352
+ /// defaults to `#file`).
353
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
354
+ /// it defaults to `#function`).
355
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
356
+ /// defaults to `#line`).
357
+ @inlinable
358
+ public func warning( _ message: @autoclosure ( ) -> Logger . Message ,
359
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
360
+ file: String = #file, function: String = #function, line: UInt = #line) {
361
+ self . warning ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
362
+ }
363
+
236
364
/// Log a message passing with the `Logger.Level.error` log level.
237
365
///
238
366
/// If `.error` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -257,6 +385,27 @@ extension Logger {
257
385
self . log ( level: . error, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
258
386
}
259
387
388
+ /// Log a message passing with the `Logger.Level.error` log level.
389
+ ///
390
+ /// If `.error` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
391
+ /// otherwise nothing will happen.
392
+ ///
393
+ /// - parameters:
394
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
395
+ /// - metadata: One-off metadata to attach to this log message.
396
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
397
+ /// defaults to `#file`).
398
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
399
+ /// it defaults to `#function`).
400
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
401
+ /// defaults to `#line`).
402
+ @inlinable
403
+ public func error( _ message: @autoclosure ( ) -> Logger . Message ,
404
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
405
+ file: String = #file, function: String = #function, line: UInt = #line) {
406
+ self . error ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
407
+ }
408
+
260
409
/// Log a message passing with the `Logger.Level.critical` log level.
261
410
///
262
411
/// `.critical` messages will always be logged.
@@ -279,6 +428,28 @@ extension Logger {
279
428
file: String = #file, function: String = #function, line: UInt = #line) {
280
429
self . log ( level: . critical, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
281
430
}
431
+
432
+ /// Log a message passing with the `Logger.Level.critical` log level.
433
+ ///
434
+ /// `.critical` messages will always be logged.
435
+ ///
436
+ /// - parameters:
437
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
438
+ /// - metadata: One-off metadata to attach to this log message.
439
+ /// - source: The source this log messages originates to. Currently, it defaults to the folder containing the
440
+ /// file that is emitting the log message, which usually is the module.
441
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
442
+ /// defaults to `#file`).
443
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
444
+ /// it defaults to `#function`).
445
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
446
+ /// defaults to `#line`).
447
+ @inlinable
448
+ public func critical( _ message: @autoclosure ( ) -> Logger . Message ,
449
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
450
+ file: String = #file, function: String = #function, line: UInt = #line) {
451
+ self . critical ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
452
+ }
282
453
}
283
454
284
455
/// The `LoggingSystem` is a global facility where the default logging backend implementation (`LogHandler`) can be
0 commit comments