Skip to content

[SLG-0006]: task-local logger implementation#459

Merged
kukushechkin merged 30 commits into
apple:mainfrom
kukushechkin:SLG-0006-task-local-logger-implementation
Jun 23, 2026
Merged

[SLG-0006]: task-local logger implementation#459
kukushechkin merged 30 commits into
apple:mainfrom
kukushechkin:SLG-0006-task-local-logger-implementation

Conversation

@kukushechkin

Copy link
Copy Markdown
Contributor

This proposal adds task-local logger storage so that metadata can accumulate across async
call stacks without threading a Logger through every function signature.

Motivation:

Metadata propagation requires threading a logger through every layer. Every function on
the path from request ingress to the bottom of the call stack has to accept, mutate, and
forward a Logger. Libraries must choose between polluting their public API with a logger: parameter and
losing all the caller's context. There is no third option today.

Modifications:

  • New API surface for reading and modifying the @TaskLocal Logger instance added.
  • Best practices on how to correctly propagate logger into libraries updated with Logger.current API.

Result:

Users can now automatically propagate accumulated metadata into libraries without explicitly passing loggers through the API boundaries.

@kukushechkin kukushechkin added the 🆕 semver/minor Adds new public API. label May 18, 2026
@kukushechkin
kukushechkin force-pushed the SLG-0006-task-local-logger-implementation branch from c5471e9 to 16bce4e Compare May 18, 2026 12:01
@kukushechkin kukushechkin changed the title [SLG-0006]: task local logger implementation [SLG-0006]: task-local logger implementation May 18, 2026
@kukushechkin
kukushechkin marked this pull request as draft May 18, 2026 12:04
@kukushechkin
kukushechkin force-pushed the SLG-0006-task-local-logger-implementation branch from 16bce4e to 80e5dfd Compare May 18, 2026 12:14
@kukushechkin
kukushechkin force-pushed the SLG-0006-task-local-logger-implementation branch from 80e5dfd to 0ed85c1 Compare May 19, 2026 13:58
Comment thread Sources/Logging/Docs.docc/Proposals/SLG-0006-task-local-logger.md Outdated
Comment thread Sources/Logging/Docs.docc/Proposals/SLG-0006-task-local-logger.md Outdated
Comment thread Sources/Logging/Docs.docc/Proposals/SLG-0006-task-local-logger.md Outdated
Comment thread Sources/Logging/Docs.docc/Proposals/SLG-0006-task-local-logger.md
Comment thread Sources/Logging/Docs.docc/Proposals/SLG-0006-task-local-logger.md Outdated
Comment thread Sources/Logging/Logger+With.swift Outdated
Comment thread Sources/Logging/Logger.swift Outdated
Comment thread Sources/Logging/Logger.swift Outdated
Comment thread Sources/Logging/Logger+With.swift Outdated
@kukushechkin
kukushechkin marked this pull request as ready for review June 11, 2026 15:12
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md Outdated
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md Outdated
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md Outdated
Comment thread Sources/Logging/Logger+With.swift Outdated
Comment thread Sources/Logging/Logger.swift
Comment thread Sources/Logging/Logger+With.swift
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md Outdated
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md Outdated
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md
Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md
Comment thread Sources/Logging/Logger+With.swift
Comment thread Sources/Logging/Logger+With.swift
Comment thread Sources/Logging/Logger.swift Outdated
Comment thread Sources/Logging/Logger.swift Outdated
Comment thread Sources/Logging/Logger.swift Outdated
Comment thread Sources/Logging/Logger.swift

@FranzBusch FranzBusch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only a small doc nits otherwise LGTM

Comment thread Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md Outdated
@kukushechkin
kukushechkin merged commit a878e7f into apple:main Jun 23, 2026
52 of 54 checks passed
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.

4 participants