swift-log
swift-log copied to clipboard
[WIP] Metadata providers
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:
LoggingSystemgains a newprovideMetadatamethodLoggingSystemstores an array ofMetadataProvidersLoggergains a new initializer taking an overwritingMetadataProviderLoggerexecutes theMetadataProviderbefore 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.
@swift-server-bot test this please
This PR is now superseded by https://github.com/apple/swift-log/pull/235