@@ -77,6 +77,29 @@ extension Logger {
77
77
}
78
78
}
79
79
80
+ /// Log a message passing the log level as a parameter.
81
+ ///
82
+ /// If the `logLevel` passed to this method is more severe than the `Logger`'s `logLevel`, it will be logged,
83
+ /// otherwise nothing will happen.
84
+ ///
85
+ /// - parameters:
86
+ /// - level: The log level to log `message` at. For the available log levels, see `Logger.Level`.
87
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
88
+ /// - metadata: One-off metadata to attach to this log message.
89
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
90
+ /// defaults to `#file`).
91
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
92
+ /// it defaults to `#function`).
93
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
94
+ /// defaults to `#line`).
95
+ @inlinable
96
+ public func log( level: Logger . Level ,
97
+ _ message: @autoclosure ( ) -> Logger . Message ,
98
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
99
+ file: String = #file, function: String = #function, line: UInt = #line) {
100
+ self . log ( level: level, message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
101
+ }
102
+
80
103
/// Add, change, or remove a logging metadata item.
81
104
///
82
105
/// - note: Logging metadata behaves as a value that means a change to the logging metadata will only affect the
@@ -133,6 +156,25 @@ extension Logger {
133
156
self . log ( level: . trace, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
134
157
}
135
158
159
+ /// If `.trace` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
160
+ /// otherwise nothing will happen.
161
+ ///
162
+ /// - parameters:
163
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
164
+ /// - metadata: One-off metadata to attach to this log message
165
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
166
+ /// defaults to `#file`).
167
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
168
+ /// it defaults to `#function`).
169
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
170
+ /// defaults to `#line`).
171
+ @inlinable
172
+ public func trace( _ message: @autoclosure ( ) -> Logger . Message ,
173
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
174
+ file: String = #file, function: String = #function, line: UInt = #line) {
175
+ self . trace ( message ( ) , metadata: metadata ( ) , source: nil , file: file, line: line)
176
+ }
177
+
136
178
/// Log a message passing with the `Logger.Level.debug` log level.
137
179
///
138
180
/// If `.debug` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -157,6 +199,27 @@ extension Logger {
157
199
self . log ( level: . debug, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
158
200
}
159
201
202
+ /// Log a message passing with the `Logger.Level.debug` log level.
203
+ ///
204
+ /// If `.debug` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
205
+ /// otherwise nothing will happen.
206
+ ///
207
+ /// - parameters:
208
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
209
+ /// - metadata: One-off metadata to attach to this log message.
210
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
211
+ /// defaults to `#file`).
212
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
213
+ /// it defaults to `#function`).
214
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
215
+ /// defaults to `#line`).
216
+ @inlinable
217
+ public func debug( _ message: @autoclosure ( ) -> Logger . Message ,
218
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
219
+ file: String = #file, function: String = #function, line: UInt = #line) {
220
+ self . debug ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
221
+ }
222
+
160
223
/// Log a message passing with the `Logger.Level.info` log level.
161
224
///
162
225
/// If `.info` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -181,6 +244,27 @@ extension Logger {
181
244
self . log ( level: . info, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
182
245
}
183
246
247
+ /// Log a message passing with the `Logger.Level.info` log level.
248
+ ///
249
+ /// If `.info` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
250
+ /// otherwise nothing will happen.
251
+ ///
252
+ /// - parameters:
253
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
254
+ /// - metadata: One-off metadata to attach to this log message.
255
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
256
+ /// defaults to `#file`).
257
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
258
+ /// it defaults to `#function`).
259
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
260
+ /// defaults to `#line`).
261
+ @inlinable
262
+ public func info( _ message: @autoclosure ( ) -> Logger . Message ,
263
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
264
+ file: String = #file, function: String = #function, line: UInt = #line) {
265
+ self . info ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
266
+ }
267
+
184
268
/// Log a message passing with the `Logger.Level.notice` log level.
185
269
///
186
270
/// If `.notice` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -205,6 +289,29 @@ extension Logger {
205
289
self . log ( level: . notice, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
206
290
}
207
291
292
+ /// Log a message passing with the `Logger.Level.notice` log level.
293
+ ///
294
+ /// If `.notice` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
295
+ /// otherwise nothing will happen.
296
+ ///
297
+ /// - parameters:
298
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
299
+ /// - metadata: One-off metadata to attach to this log message.
300
+ /// - source: The source this log messages originates to. Currently, it defaults to the folder containing the
301
+ /// file that is emitting the log message, which usually is the module.
302
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
303
+ /// defaults to `#file`).
304
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
305
+ /// it defaults to `#function`).
306
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
307
+ /// defaults to `#line`).
308
+ @inlinable
309
+ public func notice( _ message: @autoclosure ( ) -> Logger . Message ,
310
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
311
+ file: String = #file, function: String = #function, line: UInt = #line) {
312
+ self . notice ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
313
+ }
314
+
208
315
/// Log a message passing with the `Logger.Level.warning` log level.
209
316
///
210
317
/// If `.warning` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -229,6 +336,27 @@ extension Logger {
229
336
self . log ( level: . warning, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
230
337
}
231
338
339
+ /// Log a message passing with the `Logger.Level.warning` log level.
340
+ ///
341
+ /// If `.warning` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
342
+ /// otherwise nothing will happen.
343
+ ///
344
+ /// - parameters:
345
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
346
+ /// - metadata: One-off metadata to attach to this log message.
347
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
348
+ /// defaults to `#file`).
349
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
350
+ /// it defaults to `#function`).
351
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
352
+ /// defaults to `#line`).
353
+ @inlinable
354
+ public func warning( _ message: @autoclosure ( ) -> Logger . Message ,
355
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
356
+ file: String = #file, function: String = #function, line: UInt = #line) {
357
+ self . warning ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
358
+ }
359
+
232
360
/// Log a message passing with the `Logger.Level.error` log level.
233
361
///
234
362
/// If `.error` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
@@ -253,6 +381,27 @@ extension Logger {
253
381
self . log ( level: . error, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
254
382
}
255
383
384
+ /// Log a message passing with the `Logger.Level.error` log level.
385
+ ///
386
+ /// If `.error` is at least as severe as the `Logger`'s `logLevel`, it will be logged,
387
+ /// otherwise nothing will happen.
388
+ ///
389
+ /// - parameters:
390
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
391
+ /// - metadata: One-off metadata to attach to this log message.
392
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
393
+ /// defaults to `#file`).
394
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
395
+ /// it defaults to `#function`).
396
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
397
+ /// defaults to `#line`).
398
+ @inlinable
399
+ public func error( _ message: @autoclosure ( ) -> Logger . Message ,
400
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
401
+ file: String = #file, function: String = #function, line: UInt = #line) {
402
+ self . error ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
403
+ }
404
+
256
405
/// Log a message passing with the `Logger.Level.critical` log level.
257
406
///
258
407
/// `.critical` messages will always be logged.
@@ -275,6 +424,28 @@ extension Logger {
275
424
file: String = #file, function: String = #function, line: UInt = #line) {
276
425
self . log ( level: . critical, message ( ) , metadata: metadata ( ) , source: source ( ) , file: file, function: function, line: line)
277
426
}
427
+
428
+ /// Log a message passing with the `Logger.Level.critical` log level.
429
+ ///
430
+ /// `.critical` messages will always be logged.
431
+ ///
432
+ /// - parameters:
433
+ /// - message: The message to be logged. `message` can be used with any string interpolation literal.
434
+ /// - metadata: One-off metadata to attach to this log message.
435
+ /// - source: The source this log messages originates to. Currently, it defaults to the folder containing the
436
+ /// file that is emitting the log message, which usually is the module.
437
+ /// - file: The file this log message originates from (there's usually no need to pass it explicitly as it
438
+ /// defaults to `#file`).
439
+ /// - function: The function this log message originates from (there's usually no need to pass it explicitly as
440
+ /// it defaults to `#function`).
441
+ /// - line: The line this log message originates from (there's usually no need to pass it explicitly as it
442
+ /// defaults to `#line`).
443
+ @inlinable
444
+ public func critical( _ message: @autoclosure ( ) -> Logger . Message ,
445
+ metadata: @autoclosure ( ) -> Logger . Metadata ? = nil ,
446
+ file: String = #file, function: String = #function, line: UInt = #line) {
447
+ self . critical ( message ( ) , metadata: metadata ( ) , source: nil , file: file, function: function, line: line)
448
+ }
278
449
}
279
450
280
451
/// The `LoggingSystem` is a global facility where the default logging backend implementation (`LogHandler`) can be
0 commit comments