mirror of
https://github.com/apple/swift-log
synced 2026-11-23 03:44:22 +00:00
Fixes #498 ## Problem `MultiplexLogHandler` had inconsistent metadata priority: - `subscript(metadataKey:)` reads the value from the **first** handler that has the key (documented: "the first handler's values are more important") - `metadata` (full dictionary) merged handlers **last-wins**, so the value came from the **last** handler with that key ## Fix The `metadata` getter now merges handlers in their initialization order, keeping the already-stored value on conflicts — the **first handler wins**, matching the subscript and the docs. The multiplex handler's own `metadataProvider` still takes priority over all underlying handlers/providers, matching its documented role ("runs after all metadata providers of the multiplexed handlers"). ## Testing - Updated `multiplexLogHandlerMetadata_readingHandlerMetadata` and `multiplexMetadataProviderSet`, which encoded the last-wins behavior - Extended `multiplexMetadataProviderSet` with subscript-vs-dictionary consistency checks (both must give the first handler's value on conflicting keys, including provider-provided metadata) - Full suite: 174 tests in 17 suites, all passing --------- Co-authored-by: awaisdev <awais@airtechsolutions.pk> Co-authored-by: awaisdev5765 <awaisdev5765@users.noreply.github.com> Co-authored-by: Vladimir Kukushkin <kukushechkin@apple.com>