Repository navigation
Gate network logging on a policy and let iOS supply the log sink (RND-2355) - #3416
Draft
StylianosGakis wants to merge 6 commits into
Draft
StylianosGakis wants to merge 6 commits into
StylianosGakis wants to merge 6 commits into
Conversation
The network logging is about to read a policy so that iOS can keep response data out of the device log. Android and desktop must keep writing exactly what they write today, so the success, GraphQL error and exception lines, and the RUM error attributes, are pinned first. Adds shared test doubles (capturing loggers, a queued query and HTTP client fakes) to commonTest for the tests that follow. (cherry picked from commit 9f6e8cd)
Shared networking code runs inside iOS apps, where every Kotlin log line can leave the device through the app's logger. The Ktor client logged request and response bodies in any non-production build and LoggingInterceptor logged GraphQL response data in every build. NetworkLogPolicy now decides both. Android and desktop provide it from the build constants with exactly today's values (bodies when not production, GraphQL data always), so their output is unchanged. The native network providers take it from the graph, so the iOS app has to choose. With GraphQL data off, the emission line carries the operation name only, and the error line and RUM error keep the error messages, errors and extensions but not the data, which is what PR 3405 does for Android production. (cherry picked from commit 70206b7 with edits: the umbrella graph, claim history test and test host hunks are dropped, and data off no longer drops error messages, errors and extensions)
GraphQL error messages, the errors with their extensions, the response extensions and exception messages can quote what was sent, an email or an address, so they are not the same decision as the response data. With logsGraphqlErrors off, the error line and the RUM error carry the operation name, the error count and the error types, and the exception line the exception class. Android and desktop log both in every build, so their output is unchanged; the iOS app chooses. This keeps PR 3405's intent intact if it lands after this: it sets logsGraphqlData to !isProduction, and production keeps error messages. (after commit edee0223e5189f91e5406c6ed5afb5e75ec88b0e, which dropped the error text together with the data; rewritten as a separate switch)
…inimum priority On iOS every Kotlin log line went to NSLog, which the iOS app neither sees nor forwards. IosLogSink is a one-method interface the iOS app implements, for example by forwarding to its own logger, and IosLogcatLogger.install(sink:minimumPriority:) installs it: lines below the minimum are dropped without building their message, and a throwable is named by its class only, since its message can quote what was sent. The sink replaces a logger installed before it in one step through the new LogcatLogger.replace, so no line is lost and no warning is logged. install() keeps writing everything to NSLog for the app that calls it today. installFallback, hidden from Swift, installs NSLog at a minimum only when nothing is installed, so shared code never logs into the no-op logger, which throws. (the minimum priority and its tests are cherry-picked from commit 623dd1c with edits: install() keeps its signature and the test host hunk is dropped)
The iOS app's log sink receives a LogPriority. With @ObjCEnum Swift gets an nsEnum it can switch over by case instead of comparing Kotlin enum objects. The annotation is an optional expectation, so the JVM and Android outputs are unchanged.
…g-policy The GraphQL logging fix below now applies through NetworkLogPolicy: Android and desktop provide GraphQL data only outside production, so production keeps error text but drops response data and operation variables. Variables follow the data switch. The pinned output tests now expect that per build.
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.
🤖 AI description
Sits on #3415. Network logging is decided by a NetworkLogPolicy with three switches: HTTP bodies, GraphQL response data and GraphQL error text. Android and desktop provide (not production, not production, on), which is the GraphQL rule of 3405 below in the stack; a test pins the lines and RUM attributes per build. A production iOS build forces bodies and data off. Error text has its own switch so that production can drop data, as 3405 requires, without losing error messages. Also lets the iOS app take Kotlin's log lines through its own sink with a minimum priority; the existing install() is unchanged.