Skip to content

Commit e73a862

Browse files
authored
Merge pull request #5 from mitchtreece/dev
1.4.0 Release
2 parents 0853a40 + 2a45173 commit e73a862

File tree

3 files changed

+123
-29
lines changed

3 files changed

+123
-29
lines changed

Sources/Lumberjack/Logger/Logger.swift

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class Logger: Equatable {
6969
/// - level: The log-level for the message.
7070
/// - symbol: An override symbol to use for the message.
7171
/// - category: An override category to use for the message.
72+
/// - metadata: Additional data to attach to the message.
7273
/// - file: The calling function.
7374
/// - function: The calling function.
7475
/// - line: The calling line number.
@@ -79,6 +80,7 @@ public class Logger: Equatable {
7980
level: LogLevel,
8081
symbol: String? = nil,
8182
category: String? = nil,
83+
metadata: Message.Metadata? = nil,
8284
file: String = #fileID,
8385
function: String = #function,
8486
line: UInt = #line) -> Message {
@@ -96,6 +98,7 @@ public class Logger: Equatable {
9698
level: level,
9799
symbol: symbol ?? self.configuration.symbol.asString(for: level),
98100
category: category,
101+
metadata: metadata,
99102
file: file,
100103
function: function,
101104
line: line,
@@ -162,8 +165,9 @@ public class Logger: Equatable {
162165
level: message.level,
163166
symbol: message.symbol,
164167
category: message.category,
165-
file: message.file,
166-
function: message.function,
168+
metadata: message.metadata,
169+
file: message.file(format: .raw),
170+
function: message.function(format: .raw),
167171
line: message.line
168172
)
169173

@@ -175,6 +179,7 @@ public class Logger: Equatable {
175179
/// - message: The message to log.
176180
/// - symbol: An override symbol to use for the message.
177181
/// - category: An override category to use for the message.
182+
/// - metadata: Additional data to attach to the message.
178183
/// - file: The calling function.
179184
/// - function: The calling function.
180185
/// - line: The calling line number.
@@ -184,6 +189,7 @@ public class Logger: Equatable {
184189
public func trace(_ message: String,
185190
symbol: String? = nil,
186191
category: String? = nil,
192+
metadata: Message.Metadata? = nil,
187193
file: String = #fileID,
188194
function: String = #function,
189195
line: UInt = #line) -> Message {
@@ -193,6 +199,7 @@ public class Logger: Equatable {
193199
level: .trace,
194200
symbol: symbol,
195201
category: category,
202+
metadata: metadata,
196203
file: file,
197204
function: function,
198205
line: line
@@ -206,6 +213,7 @@ public class Logger: Equatable {
206213
/// - message: The message to log.
207214
/// - symbol: An override symbol to use for the message.
208215
/// - category: An override category to use for the message.
216+
/// - metadata: Additional data to attach to the message.
209217
/// - file: The calling function.
210218
/// - function: The calling function.
211219
/// - line: The calling line number.
@@ -215,6 +223,7 @@ public class Logger: Equatable {
215223
public func debug(_ message: String,
216224
symbol: String? = nil,
217225
category: String? = nil,
226+
metadata: Message.Metadata? = nil,
218227
file: String = #fileID,
219228
function: String = #function,
220229
line: UInt = #line) -> Message {
@@ -224,6 +233,7 @@ public class Logger: Equatable {
224233
level: .debug,
225234
symbol: symbol,
226235
category: category,
236+
metadata: metadata,
227237
file: file,
228238
function: function,
229239
line: line
@@ -237,6 +247,7 @@ public class Logger: Equatable {
237247
/// - message: The message to log.
238248
/// - symbol: An override symbol to use for the message.
239249
/// - category: An override category to use for the message.
250+
/// - metadata: Additional data to attach to the message.
240251
/// - file: The calling function.
241252
/// - function: The calling function.
242253
/// - line: The calling line number.
@@ -246,6 +257,7 @@ public class Logger: Equatable {
246257
public func info(_ message: String,
247258
symbol: String? = nil,
248259
category: String? = nil,
260+
metadata: Message.Metadata? = nil,
249261
file: String = #fileID,
250262
function: String = #function,
251263
line: UInt = #line) -> Message {
@@ -255,6 +267,7 @@ public class Logger: Equatable {
255267
level: .info,
256268
symbol: symbol,
257269
category: category,
270+
metadata: metadata,
258271
file: file,
259272
function: function,
260273
line: line
@@ -268,6 +281,7 @@ public class Logger: Equatable {
268281
/// - message: The message to log.
269282
/// - symbol: An override symbol to use for the message.
270283
/// - category: An override category to use for the message.
284+
/// - metadata: Additional data to attach to the message.
271285
/// - file: The calling function.
272286
/// - function: The calling function.
273287
/// - line: The calling line number.
@@ -277,6 +291,7 @@ public class Logger: Equatable {
277291
public func notice(_ message: String,
278292
symbol: String? = nil,
279293
category: String? = nil,
294+
metadata: Message.Metadata? = nil,
280295
file: String = #fileID,
281296
function: String = #function,
282297
line: UInt = #line) -> Message {
@@ -286,6 +301,7 @@ public class Logger: Equatable {
286301
level: .notice,
287302
symbol: symbol,
288303
category: category,
304+
metadata: metadata,
289305
file: file,
290306
function: function,
291307
line: line
@@ -299,6 +315,7 @@ public class Logger: Equatable {
299315
/// - message: The message to log.
300316
/// - symbol: An override symbol to use for the message.
301317
/// - category: An override category to use for the message.
318+
/// - metadata: Additional data to attach to the message.
302319
/// - file: The calling function.
303320
/// - function: The calling function.
304321
/// - line: The calling line number.
@@ -308,6 +325,7 @@ public class Logger: Equatable {
308325
public func warning(_ message: String,
309326
symbol: String? = nil,
310327
category: String? = nil,
328+
metadata: Message.Metadata? = nil,
311329
file: String = #fileID,
312330
function: String = #function,
313331
line: UInt = #line) -> Message {
@@ -317,6 +335,7 @@ public class Logger: Equatable {
317335
level: .warning,
318336
symbol: symbol,
319337
category: category,
338+
metadata: metadata,
320339
file: file,
321340
function: function,
322341
line: line
@@ -330,6 +349,7 @@ public class Logger: Equatable {
330349
/// - message: The message to log.
331350
/// - symbol: An override symbol to use for the message.
332351
/// - category: An override category to use for the message.
352+
/// - metadata: Additional data to attach to the message.
333353
/// - file: The calling function.
334354
/// - function: The calling function.
335355
/// - line: The calling line number.
@@ -339,6 +359,7 @@ public class Logger: Equatable {
339359
public func error(_ message: String,
340360
symbol: String? = nil,
341361
category: String? = nil,
362+
metadata: Message.Metadata? = nil,
342363
file: String = #fileID,
343364
function: String = #function,
344365
line: UInt = #line) -> Message {
@@ -348,6 +369,7 @@ public class Logger: Equatable {
348369
level: .error,
349370
symbol: symbol,
350371
category: category,
372+
metadata: metadata,
351373
file: file,
352374
function: function,
353375
line: line
@@ -361,12 +383,14 @@ public class Logger: Equatable {
361383
/// - message: The message to log.
362384
/// - symbol: An override symbol to use for the message.
363385
/// - category: An override category to use for the message.
386+
/// - metadata: Additional data to attach to the message.
364387
/// - file: The calling function.
365388
/// - function: The calling function.
366389
/// - line: The calling line number.
367390
public func fatal(_ message: String,
368391
symbol: String? = nil,
369392
category: String? = nil,
393+
metadata: Message.Metadata? = nil,
370394
file: String = #fileID,
371395
function: String = #function,
372396
line: UInt = #line,
@@ -377,6 +401,7 @@ public class Logger: Equatable {
377401
level: .fatal,
378402
symbol: symbol,
379403
category: category,
404+
metadata: metadata,
380405
file: file,
381406
function: function,
382407
line: line

Sources/Lumberjack/Lumberjack.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ public struct Lumberjack {
218218
/// - level: The log-level for the message.
219219
/// - symbol: An override symbol to use for the message.
220220
/// - category: An override category to use for the message.
221+
/// - metadata: Additional data to attach to the message.
221222
/// - file: The calling function.
222223
/// - function: The calling function.
223224
/// - line: The calling line number.
@@ -229,6 +230,7 @@ public func LOG(_ message: String,
229230
level: LogLevel,
230231
symbol: String? = nil,
231232
category: String? = nil,
233+
metadata: Message.Metadata? = nil,
232234
file: String = #fileID,
233235
function: String = #function,
234236
line: UInt = #line) -> Message? {
@@ -253,6 +255,7 @@ public func LOG(_ message: String,
253255
level: level,
254256
symbol: symbol,
255257
category: category,
258+
metadata: metadata,
256259
file: file,
257260
function: function,
258261
line: line
@@ -298,6 +301,7 @@ public func PROXY(_ message: Message,
298301
/// - target: The target to send the message to.
299302
/// - symbol: An override symbol to use for the message.
300303
/// - category: An override category to use for the message.
304+
/// - metadata: Additional data to attach to the message.
301305
/// - file: The calling function.
302306
/// - function: The calling function.
303307
/// - line: The calling line number.
@@ -308,6 +312,7 @@ public func TRACE(_ message: String,
308312
target: LogTarget = .default,
309313
symbol: String? = nil,
310314
category: String? = nil,
315+
metadata: Message.Metadata? = nil,
311316
file: String = #fileID,
312317
function: String = #function,
313318
line: UInt = #line) -> Message? {
@@ -318,6 +323,7 @@ public func TRACE(_ message: String,
318323
level: .trace,
319324
symbol: symbol,
320325
category: category,
326+
metadata: metadata,
321327
file: file,
322328
function: function,
323329
line: line
@@ -332,6 +338,7 @@ public func TRACE(_ message: String,
332338
/// - target: The target to send the message to.
333339
/// - symbol: An override symbol to use for the message.
334340
/// - category: An override category to use for the message.
341+
/// - metadata: Additional data to attach to the message.
335342
/// - file: The calling function.
336343
/// - function: The calling function.
337344
/// - line: The calling line number.
@@ -342,6 +349,7 @@ public func DEBUG(_ message: String,
342349
target: LogTarget = .default,
343350
symbol: String? = nil,
344351
category: String? = nil,
352+
metadata: Message.Metadata? = nil,
345353
file: String = #fileID,
346354
function: String = #function,
347355
line: UInt = #line) -> Message? {
@@ -352,6 +360,7 @@ public func DEBUG(_ message: String,
352360
level: .debug,
353361
symbol: symbol,
354362
category: category,
363+
metadata: metadata,
355364
file: file,
356365
function: function,
357366
line: line
@@ -366,6 +375,7 @@ public func DEBUG(_ message: String,
366375
/// - target: The target to send the message to.
367376
/// - symbol: An override symbol to use for the message.
368377
/// - category: An override category to use for the message.
378+
/// - metadata: Additional data to attach to the message.
369379
/// - file: The calling function.
370380
/// - function: The calling function.
371381
/// - line: The calling line number.
@@ -376,6 +386,7 @@ public func INFO(_ message: String,
376386
target: LogTarget = .default,
377387
symbol: String? = nil,
378388
category: String? = nil,
389+
metadata: Message.Metadata? = nil,
379390
file: String = #fileID,
380391
function: String = #function,
381392
line: UInt = #line) -> Message? {
@@ -386,6 +397,7 @@ public func INFO(_ message: String,
386397
level: .info,
387398
symbol: symbol,
388399
category: category,
400+
metadata: metadata,
389401
file: file,
390402
function: function,
391403
line: line
@@ -400,6 +412,7 @@ public func INFO(_ message: String,
400412
/// - target: The target to send the message to.
401413
/// - symbol: An override symbol to use for the message.
402414
/// - category: An override category to use for the message.
415+
/// - metadata: Additional data to attach to the message.
403416
/// - file: The calling function.
404417
/// - function: The calling function.
405418
/// - line: The calling line number.
@@ -410,6 +423,7 @@ public func NOTICE(_ message: String,
410423
target: LogTarget = .default,
411424
symbol: String? = nil,
412425
category: String? = nil,
426+
metadata: Message.Metadata? = nil,
413427
file: String = #fileID,
414428
function: String = #function,
415429
line: UInt = #line) -> Message? {
@@ -420,6 +434,7 @@ public func NOTICE(_ message: String,
420434
level: .notice,
421435
symbol: symbol,
422436
category: category,
437+
metadata: metadata,
423438
file: file,
424439
function: function,
425440
line: line
@@ -434,6 +449,7 @@ public func NOTICE(_ message: String,
434449
/// - target: The target to send the message to.
435450
/// - symbol: An override symbol to use for the message.
436451
/// - category: An override category to use for the message.
452+
/// - metadata: Additional data to attach to the message.
437453
/// - file: The calling function.
438454
/// - function: The calling function.
439455
/// - line: The calling line number.
@@ -444,6 +460,7 @@ public func WARN(_ message: String,
444460
target: LogTarget = .default,
445461
symbol: String? = nil,
446462
category: String? = nil,
463+
metadata: Message.Metadata? = nil,
447464
file: String = #fileID,
448465
function: String = #function,
449466
line: UInt = #line) -> Message? {
@@ -454,6 +471,7 @@ public func WARN(_ message: String,
454471
level: .warning,
455472
symbol: symbol,
456473
category: category,
474+
metadata: metadata,
457475
file: file,
458476
function: function,
459477
line: line
@@ -468,6 +486,7 @@ public func WARN(_ message: String,
468486
/// - target: The target to send the message to.
469487
/// - symbol: An override symbol to use for the message.
470488
/// - category: An override category to use for the message.
489+
/// - metadata: Additional data to attach to the message.
471490
/// - file: The calling function.
472491
/// - function: The calling function.
473492
/// - line: The calling line number.
@@ -478,6 +497,7 @@ public func ERROR(_ message: String,
478497
target: LogTarget = .default,
479498
symbol: String? = nil,
480499
category: String? = nil,
500+
metadata: Message.Metadata? = nil,
481501
file: String = #fileID,
482502
function: String = #function,
483503
line: UInt = #line) -> Message? {
@@ -488,6 +508,7 @@ public func ERROR(_ message: String,
488508
level: .error,
489509
symbol: symbol,
490510
category: category,
511+
metadata: metadata,
491512
file: file,
492513
function: function,
493514
line: line
@@ -502,13 +523,15 @@ public func ERROR(_ message: String,
502523
/// - target: The target to send the message to.
503524
/// - symbol: An override symbol to use for the message.
504525
/// - category: An override category to use for the message.
526+
/// - metadata: Additional data to attach to the message.
505527
/// - file: The calling function.
506528
/// - function: The calling function.
507529
/// - line: The calling line number.
508530
public func FATAL(_ message: String,
509531
target: LogTarget = .default,
510532
symbol: String? = nil,
511533
category: String? = nil,
534+
metadata: Message.Metadata? = nil,
512535
file: String = #fileID,
513536
function: String = #function,
514537
line: UInt = #line,
@@ -520,6 +543,7 @@ public func FATAL(_ message: String,
520543
level: .fatal,
521544
symbol: symbol,
522545
category: category,
546+
metadata: metadata,
523547
file: file,
524548
function: function,
525549
line: line

0 commit comments

Comments
 (0)