Skip to content

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

@gabbifish

Description

@gabbifish

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions