swift-log icon indicating copy to clipboard operation
swift-log copied to clipboard

[WIP] Metadata providers

Open slashmo opened this issue 4 years ago • 1 comments

Add MetadataProvider closure to be run on each log statement to attach the current value of something (e.g. a task-local) to the statement's metadata values (#205).

Motivation:

Closes #205

Modifications:

  • LoggingSystem gains a new provideMetadata method
  • LoggingSystem stores an array of MetadataProviders
  • Logger gains a new initializer taking an overwriting MetadataProvider
  • Logger executes the MetadataProvider before logging a statement, attaching the resulting values to the statement's metadata

Result:

It becomes easier to attach metadata to each log statement where the value can be derived without a method argument such as retrieving from the current task local storage. Instead of writing the code to retrieve such values per log statement it can instead be set up once.

slashmo avatar Aug 13 '21 12:08 slashmo

@swift-server-bot test this please

ktoso avatar Oct 19 '21 11:10 ktoso

This PR is now superseded by https://github.com/apple/swift-log/pull/235

slashmo avatar Sep 30 '22 10:09 slashmo