apple / apple/container

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

Open
#1,754 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
49.9k
Forks
1.8k
Avg merge
1d 20h
Merged PRs (30d)
22

Description

### I have done the following

- [x] I have searched the existing issues
- [x] If possible, I've reproduced the issue using the 'main' branch of this project

### Steps to reproduce

1. Build a Swift package that depends on `apple/container` and imports `ContainerLog`.

2. A public reproduction is available in `stephenlclarke/container-compose`, where the CodeQL workflow checks out `apple/container` as a sibling dependency and runs:

`swift build --disable-automatic-resolution --product compose`

3. In that workflow, `container-compose/APPLE_CONTAINER_REF` points at `apple/container` commit `888582b4c82dbd95832c0d8428ebbe8ef209a3e0`.

4. Observe SwiftLog deprecation warnings from `Sources/ContainerLog/*LogHandler.swift` during the Swift build.

CodeQL log evidence:

- Warning span starts at: https://github.com/stephenlclarke/container-compose/actions/runs/27818641602/job/82333630141#step:7:917
- Warning span continues through: https://github.com/stephenlclarke/container-compose/actions/runs/27818641602/job/82333630141#step:7:1105

### Problem description

Building `container` currently produces SwiftLog deprecation warnings from the custom `ContainerLog` handlers.

**The diagnostic is**:

> deprecated default implementation is used to satisfy instance method `log(event:)` required by protocol `LogHandler`: You should implement this method instead of using the default implementation

Within the linked CodeQL log span, the warning appears for:

- `[923/1747] Compiling Configuration AccessReporter.swift`
- `Sources/ContainerLog/FileLogHandler.swift:23:15`
- `Sources/ContainerLog/OSLogHandler.swift:23:15`
- `[924/1747] Compiling Configuration AccessLogger.swift`
- `Sources/ContainerLog/FileLogHandler.swift:23:15`
- `Sources/ContainerLog/OSLogHandler.swift:23:15`
- `[925/1747] Emitting module ContainerLog`
- `Sources/ContainerLog/FileLogHandler.swift:23:15`
- `Sources/ContainerLog/OSLogHandler.swift:23:15`
- `Sources/ContainerLog/StderrLogHandler.swift:22:15`
- `[926/1748] Compiling ContainerLog StderrLogHandler.swift`
- `Sources/ContainerLog/StderrLogHandler.swift:22:15`

The affected handlers are `FileLogHandler`, `OSLogHandler`, and `StderrLogHandler`. Each currently implements the older flat-parameter `LogHandler.log(level:message:metadata:source:file:function:line:)` form. Newer `swift-log` expects custom handlers to implement `log(event:)` directly.

**Expected behavior**: `container` should build without SwiftLog deprecation warnings from its own maintained source.

**Suggested fix**: add explicit `public func log(event: LogEvent)` implementations to the three handlers, move the existing formatting/write behaviour into private helpers, and have both `log(event:)` and the older flat-parameter method delegate to those helpers if source compatibility with the older method is still useful. This preserves current output behavior while avoiding SwiftLog's deprecated default bridge.

**Related PR investigation**:

- https://github.com/apple/container/pull/717 only touches those handler files for copyright/header churn, not the warning.
- https://github.com/apple/container/pull/1592 is related log-options API work, but does not touch the handlers.
- https://github.com/apple/container/pull/1726 is concurrency/code-quality work and uses `StderrLogHandler`, but does not fix `log(event:)`.

I also searched for `LogHandler`, `LogEvent`, `FileLogHandler`, `StderrLogHandler`, `OSLogHandler`, and the deprecation text, and did not find an existing PR/code changes that fix these warning.

I intend to raise a focused PR to address these warnings, keeping the change limited to `ContainerLog` handler API conformance and preserving current logging output behaviour.

### Environment

```markdown
- OS: GitHub Actions `macos-26` runner
- Xcode: GitHub-hosted `macos-26` default Swift/Xcode toolchain; not explicitly pinned by the workflow
- Container: `apple/container` commit `888582b4c82dbd95832c0d8428ebbe8ef209a3e0` (`Propagate permissions for all host-to-container socket mounts. (#1751)`)
- Reproduction workflow: `stephenlclarke/container-compose` CodeQL workflow, run `27818641602`, job `82333630141`
- Build command: `swift build --disable-automatic-resolution --product compose`
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Read Sources/ContainerLog/FileLogHandler.swift, OSLogHandler.swift, and StderrLogHandler.swift, focusing on their existing flat-parameter log methods and formatting behavior. Run swift build --disable-automatic-resolution --product compose to reproduce the warnings. Done means the three handlers implement log(event:) without SwiftLog deprecation warnings while preserving current logging output.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.