SDK-466 Cache DateFormatter and skip formatting for filtered log levels#1064
Open
sumeruchat wants to merge 1 commit into
Open
SDK-466 Cache DateFormatter and skip formatting for filtered log levels#1064sumeruchat wants to merge 1 commit into
sumeruchat wants to merge 1 commit into
Conversation
Eliminates 2.4-3.2s main-thread hangs (reported by Wolt via Sentry) caused by IterableLogUtil.formatDate() allocating a DateFormatter on every call and formatLogMessage() running before the delegate's log-level filter. - Cache DateFormatter as a private static let - Add optional shouldLog(level:) to IterableLogDelegate (default true) - Short-circuit IterableLogUtil.log() before formatLogMessage() when shouldLog returns false - DefaultLogDelegate routes its minLogLevel filter through shouldLog; NoneLogDelegate returns false for every level - New LoggingTests verify filtered levels never hit the date provider Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1064 +/- ##
==========================================
+ Coverage 71.11% 71.13% +0.01%
==========================================
Files 112 112
Lines 9328 9335 +7
==========================================
+ Hits 6634 6640 +6
- Misses 2694 2695 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IterableLogUtil'sDateFormatteras aprivate static letso it is created once instead of on every log call (fixes the 2.4–3.2s main-thread hang reported by Wolt via Sentry during foreground transitions).shouldLog(level:) -> BooltoIterableLogDelegate(defaulttruewhen unimplemented) and short-circuitIterableLogUtil.log()beforeformatLogMessage()when the delegate says no — so apps withDefaultLogDelegate(minLogLevel: .error)no longer pay format cost for filteredITBInfo()/ITBDebug()calls.DefaultLogDelegateroutes itsminLogLevelfilter throughshouldLog;NoneLogDelegatereturnsfalsefor every level (bonus perf win).Ticket: SDK-466
Test plan
./agent_build.shpasses./agent_test.shpasses (unit, notification-extension, and offline-events bundles all 0 failures)LoggingTestscover the short-circuit:SpyDateProviderconfirmscurrentDateis never accessed whenDefaultLogDelegatefilters the level out, and never accessed at all underNoneLogDelegateshouldLog:onIterableLogDelegate— low risk (Iterable-owned protocol, matches existinglog:message:convention) but worth eyeballing🤖 Generated with Claude Code