Skip to content

fix(logs): implement SwiftLog event handlers#1933

Closed
stephenlclarke wants to merge 3 commits into
apple:mainfrom
stephenlclarke:fix-loghandler-deprecation-warnings
Closed

fix(logs): implement SwiftLog event handlers#1933
stephenlclarke wants to merge 3 commits into
apple:mainfrom
stephenlclarke:fix-loghandler-deprecation-warnings

Conversation

@stephenlclarke

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Fixes #1754.

Supersedes #1758, whose deleted fork head cannot be reattached to the closed review.

Downstream packages can resolve a newer SwiftLog than this repository's current lockfile. SwiftLog 1.13.2 makes log(event:) the primary LogHandler entry point, so relying on the compatibility bridge emits deprecation warnings for all three ContainerLog handlers.

This change updates the lockfile to SwiftLog 1.13.2 and implements the primary event entry point without changing the existing output format. Both SwiftLog entry points share the same private emission path, including handler metadata and per-event metadata merging.

What Changed

  • Updates SwiftLog from 1.10.1 to 1.13.2.
  • Implements log(event:) for FileLogHandler, OSLogHandler, and StderrLogHandler.
  • Preserves the existing log(level:message:metadata:source:file:function:line:) compatibility entry point.
  • Adds ContainerLogTests and exercises all three primary event paths.
  • Verifies that file output preserves the level and message and that event metadata overrides handler metadata.

The branch keeps dependency, implementation, and test changes in separate commits.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

Validation:

  • make swift-fmt-check
  • make test: 94 XCTest cases and 559 Swift Testing cases passed
  • swift test --disable-automatic-resolution --enable-code-coverage --filter ContainerLogHandlerTests
  • swift build --disable-automatic-resolution --target ContainerLog
  • git diff --check origin/main..HEAD

The coverage run executes each new log(event:) entry point and asserts the observable file-handler behavior.

@stephenlclarke
stephenlclarke force-pushed the fix-loghandler-deprecation-warnings branch from 3f8d6f3 to 6355f13 Compare July 15, 2026 11:13
@jglogan

jglogan commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@stephenlclarke Sorry that I didn't see your work sooner on this! We've had to focus on other items lately and haven't been able work on the issue and PR backlog.

I stumbled across the default implementation deprecation when updating our Package.resolved files, and changed the loggers to use Event in #1981. I did the same for the vminitd logger in containerization in apple/containerization#808.

Do those look sufficient to close #1754?

Separately, I'll look over your apple/containerization#799 PR today.

@stephenlclarke

Copy link
Copy Markdown
Author

Yes—#1981 and apple/containerization#808 cover the production and vminitd handlers that motivated this change. I have also reconciled both merged commits into the downstream fork and the logging tests remain green. I am closing this PR as superseded. Thank you for following up.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Resolve SwiftLog LogHandler deprecation warnings in ContainerLog handlers

2 participants