Repository navigation
Logger 3.0 reworks channel control so that an app can drive it from its own UI or command layer. It replaces the actor-based channels with lighter Sendable classes and fixes several LoggerUI and persistence bugs. It breaks source compatibility with 2.x.
Channel control
Manager.setEnabled(_:),setAllEnabled(_:)andresetToDefaults()change channels in bulk. Each one saves the settings once and returns the previous state of only the channels it changed, which is what an undo action needs.- Channels take a default state:
Channel("Name", default: .enabled). This replacesalwaysEnabled:. Only channels that differ from their default are saved, so turning a default-on channel off now persists. - The
-logsargument accepts+nameand-nameto change saved states, a barenameto turn a channel on, and=to start from defaults.
LoggerUI
ChannelWatchertakes optionalChannelActions, so toggles can go through commands with undo instead of changing channels directly.AllChannelsToggleViewshows a mixed state when only some channels are on. A click turns them all on, or all off when they're already all on.ResetChannelsButtonis new, andLoggerChannelsViewincludes it.- Built-in labels come from the package's string catalog, with English fallbacks.
- Watchers no longer retain themselves or compete for manager events, and controls update synchronously.
Concurrency and handlers
Channel,BasicHandler,OSLogHandlerandStreamHandlerareSendablefinal classes instead of actors.Channel.enabledreads and writes synchronously.Manager.eventsis aBroadcastSequence. Each subscriber gets.startedfirst, followed by up to 256 buffered events. The stream ends only whenManager.shutdown()is called.Manager.shutdown()stops every channel and waits for its output to drain.- tvOS uses
OSLogHandlerby default, like the other Apple platforms.
Breaking changes
alwaysEnabled:is replaced bydefault:.Handler.shutdown()is removed;Channel.shutdown()is synchronous.BasicHandler's closure typeLoggeris renamedOutput.YieldingSequenceis no longer public.ChannelToggleViewis removed; useIndividualChannelsToggleViewor aTogglebound towatcher[enabled: id].ManagerSettingsreads and saves channel states instead of a set of enabled channels.- Saved channel choices are stored under a new key. Choices saved by 2.x are ignored, so channels start at their defaults once after upgrading.
FatalHandlermust be@Sendable.