Skip to content

[SLG-0005]: LogEvent LogHandler API implementation#423

Merged
kukushechkin merged 12 commits intomainfrom
SLG-0005-log-event-LogHandler-API-implementation
Mar 27, 2026
Merged

[SLG-0005]: LogEvent LogHandler API implementation#423
kukushechkin merged 12 commits intomainfrom
SLG-0005-log-event-LogHandler-API-implementation

Conversation

@kukushechkin
Copy link
Copy Markdown
Contributor

Replace the flat-parameter log(level:message:metadata:source:file:function:line:) method on LogHandler with
log(event: LogEvent), enabling forward-compatible evolution of the LogHandler interface without breaking existing
handler implementations.

Motivation:

Changes to the LogHandler API require dance around creating new overloads, deprecating old overloads, which unnecessary bloats LogHandler protocol surface (like happened with the source: parameter). We have upcoming changes that would introduce new capabilities to the LogHandler protocol, for example https://forums.swift.org/t/proposal-slg-0003-standardized-error-metadata-via-logger-convenience/84518/35. It makes sense to introduce a single container structure for all the data associated with a log event before introducing any new overloads in LogHandler protocol.

Modifications:

  • New struct LogEvent is added.
  • LogHandler protocol now has an additional log(event: LogEvent) method.
  • Logger is calling handler's log(event: LogEvent) method.

Result:

Further changes to the LogEvent with new information passed from the Logger to a LogHandler does not require changes in the LogHandler API. As a bonus, LogEvent makes source a computable variable, improving performance for log handlers who do not need the default source created based on the log file location.

@kukushechkin kukushechkin added the 🆕 semver/minor Adds new public API. label Mar 9, 2026
@kukushechkin kukushechkin force-pushed the SLG-0005-log-event-LogHandler-API-implementation branch from 7ba9aed to 5409b18 Compare March 9, 2026 12:06
@kukushechkin kukushechkin force-pushed the SLG-0005-log-event-LogHandler-API-implementation branch from 5c6c628 to 0ea389f Compare March 19, 2026 14:37
@kukushechkin kukushechkin marked this pull request as ready for review March 19, 2026 15:18
Copy link
Copy Markdown
Contributor

@samuelmurray samuelmurray left a comment

Choose a reason for hiding this comment

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

Looks good!

@kukushechkin kukushechkin merged commit 1f38a59 into main Mar 27, 2026
56 of 57 checks passed
@kukushechkin kukushechkin deleted the SLG-0005-log-event-LogHandler-API-implementation branch March 27, 2026 13:13
@kukushechkin
Copy link
Copy Markdown
Contributor Author

Closes #421

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.

3 participants