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

Add Logger.withMetadata() function to create a logger with multiple metadata values

Open gabbifish opened this issue 5 months ago • 0 comments

Expected behavior

Let’s say I have an existing Logger.Metadata struct I want to add to a Logger as metadata. It doesn’t seem like there is a simple function like Logger.withMetadata(metadata: Logger.Metadata) I can use. This means I have to iterate through every kv pair in my Logger.Metadata and add it to the logger with logger[key] = value, which is verbose.

(this withMetadata pattern is common in many logging libraries, so it would be great to have this as a convenience function in swift-log as well)

Actual behavior

N/A

Steps to reproduce

N/A

If possible, minimal yet complete reproducer code (or URL to code)

N/A

SwiftLog version/commit hash

1.6.1/9cb486020ebf03bfa5b5df985387a14a98744537

Swift & OS version (output of swift --version && uname -a)

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

gabbifish avatar Sep 13 '24 17:09 gabbifish