Skip to content

[SLG-0003]: Standardized Error Metadata via Logger Convenience#405

Merged
kukushechkin merged 6 commits intoapple:mainfrom
samuelmurray:proposal/error-parameter
Feb 2, 2026
Merged

[SLG-0003]: Standardized Error Metadata via Logger Convenience#405
kukushechkin merged 6 commits intoapple:mainfrom
samuelmurray:proposal/error-parameter

Conversation

@samuelmurray
Copy link
Copy Markdown
Contributor

Add standardized way of attaching data from Error instances to log posts.

Motivation:

Addresses #291

Modifications:

The "SLG-0003" proposal doc added.

Result:

The proposal is ready for review.

@samuelmurray
Copy link
Copy Markdown
Contributor Author

I have some thoughts:

  1. I’m not sure if it’s more appropriate to add extension methods, or modify the existing methods to take an Error? that defaults to nil, i.e. func log(…, error: Error? = nil, …)
  2. Concerning the serialization:
    1. Is there reason to add ”error.*” as part of the API (to future proof/discourage other usage) or only ”error.message" and ”error.type”
    2. Is it more sensible to serialize as [”error.message”: …, “error.type”: ...], or [”error”: [“message”: …, “type”: …]]

Copy link
Copy Markdown
Contributor

@kukushechkin kukushechkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking time to prepare the proposal! I have left a few suggestions and a few questions to discuss before starting the formal review process.

@kukushechkin
Copy link
Copy Markdown
Contributor

kukushechkin commented Jan 26, 2026

@samuelmurray

  1. I’m not sure if it’s more appropriate to add extension methods, or modify the existing methods to take an Error? that defaults to nil, i.e. func log(…, error: Error? = nil, …)

Please, keep them as separate methods. Changing the method signature is strictly speaking an API breakage, even if default value keeps code compilable.

  1. Concerning the serialization:

    1. Is there reason to add ”error.*” as part of the API (to future proof/discourage other usage) or only ”error.message" and ”error.type”
    2. Is it more sensible to serialize as [”error.message”: …, “error.type”: ...], or [”error”: [“message”: …, “type”: …]]

error.message and error.type are easier to communicate as the API surface. I am not quite sure about the performance implications of parsing extra nested json vs parsing dot-separated keys in the external systems, might be a good question for the broader audience during the review, but worst case scenario a Log Handler specific for an intake system that cares can combine construct nested dicts, while we keep the API smaller.

Add docc, link to custom implementation, fix wording feedback
@samuelmurray
Copy link
Copy Markdown
Contributor Author

Thank you for taking time to prepare the proposal! I have left a few suggestions and a few questions to discuss before starting the formal review process.

@kukushechkin thanks for all your suggestions, really appreciate the help!

Make WellKnownMetadataKey a struct
Add 'recordError', change parameter to 'any Error', text clarifications
@samuelmurray samuelmurray force-pushed the proposal/error-parameter branch from 6a9ca08 to 5698665 Compare January 29, 2026 15:21
@kukushechkin kukushechkin added the semver/none No version bump required. label Jan 30, 2026
@kukushechkin
Copy link
Copy Markdown
Contributor

@samuelmurray thank you for addressing the comments! The proposal looks good for the public review now. Let's wait until the Monday for any more suggestion, and if none arise, I will merge this and start the formal review at https://forums.swift.org.

@kukushechkin kukushechkin merged commit d5dbc04 into apple:main Feb 2, 2026
69 checks passed
@kukushechkin
Copy link
Copy Markdown
Contributor

@samuelmurray thank you for addressing the comments! The proposal looks good for the public review now. Let's wait until the Monday for any more suggestion, and if none arise, I will merge this and start the formal review at https://forums.swift.org.

The post: https://forums.swift.org/t/proposal-slg-0003-standardized-error-metadata-via-logger-convenience/84518

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver/none No version bump required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants