Skip to content

[SLG-0004]: Revised Metadata value attributes as CustomStringConvertible#453

Draft
kukushechkin wants to merge 7 commits intoapple:mainfrom
kukushechkin:attributed-metadata-as-stringConvertible
Draft

[SLG-0004]: Revised Metadata value attributes as CustomStringConvertible#453
kukushechkin wants to merge 7 commits intoapple:mainfrom
kukushechkin:attributed-metadata-as-stringConvertible

Conversation

@kukushechkin
Copy link
Copy Markdown
Contributor

Important

This is a revision of SLG-0004 previously discussed here. Note this is a draft, including more than just the proposal implementation.

Add an extensible per-value attribute mechanism for metadata.

This PR also includes examples:

  • Sensitivity attribute.
  • OSLogHandler using Sensitivity attribute with os_log.

Motivation:

Metadata values in swift-log are opaque strings by the time the LogHandler receives them. The call site often
knows things about a value that the handler cannot infer — for example, whether the value should be redacted in
different environments.

Modifications:

  • SLG-0004 proposal is updated based on the feedback.
  • Added AttributedStringCarrier: CustomStringConvertible-based mechanism to Logging.
  • Added Sensitivity as an example attribute to the new LoggingAttributes target.
  • Added OSLogHandler as an example of a concrete log handler taking advantage of the Sensitivity attribute.
  • Added benchmarks and benchmark thresholds for the new attributed metadata.

Result:

swift-log provides an optional extensible mechanism for attaching attributes to metadata values.

@kukushechkin kukushechkin added the 🆕 semver/minor Adds new public API. label Apr 29, 2026
@kukushechkin kukushechkin force-pushed the attributed-metadata-as-stringConvertible branch from 2a25dbc to aa366c5 Compare April 29, 2026 13:25
@kukushechkin kukushechkin force-pushed the attributed-metadata-as-stringConvertible branch 3 times, most recently from f294301 to 9e7b525 Compare April 29, 2026 14:07
@kukushechkin kukushechkin requested review from FranzBusch and weissi and removed request for FranzBusch April 30, 2026 09:53
Comment thread Sources/Logging/Logger.swift Outdated
@kukushechkin kukushechkin force-pushed the attributed-metadata-as-stringConvertible branch from 5500ff2 to d87e798 Compare April 30, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants