File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,25 @@ class LoggingTest: XCTestCase {
357
357
" nested-list " : [ " l1str " , [ " l2str1 " , " l2str2 " ] ] ] )
358
358
}
359
359
360
+ func testWithMetadata( ) {
361
+ let testLogging = TestLogging ( )
362
+ LoggingSystem . bootstrapInternal { testLogging. make ( label: $0) }
363
+
364
+ var logger = Logger ( label: " \( #function) " )
365
+ let metadata : Logger . Metadata = [
366
+ " foo " : [ " bar " , " buz " ] ,
367
+ " empty-list " : [ ] ,
368
+ " nested-list " : [ " l1str " , [ " l2str1 " , " l2str2 " ] ]
369
+ ]
370
+ logger. withMetadata ( metadata: metadata)
371
+ logger. info ( " hello world! " )
372
+ testLogging. history. assertExist ( level: . info,
373
+ message: " hello world! " ,
374
+ metadata: [ " foo " : [ " bar " , " buz " ] ,
375
+ " empty-list " : [ ] ,
376
+ " nested-list " : [ " l1str " , [ " l2str1 " , " l2str2 " ] ] ] )
377
+ }
378
+
360
379
// Example of custom "box" which may be used to implement "render at most once" semantics
361
380
// Not thread-safe, thus should not be shared across threads.
362
381
internal final class LazyMetadataBox : CustomStringConvertible {
You can’t perform that action at this time.
0 commit comments