Skip to content

Gate network logging on a policy and let iOS supply the log sink (RND-2355) - #3416

Draft
StylianosGakis wants to merge 6 commits into
eng/ios-foundation-shared-prerequisitesfrom
eng/ios-network-log-policy
Draft

StylianosGakis wants to merge 6 commits into
eng/ios-foundation-shared-prerequisitesfrom
eng/ios-network-log-policy

Conversation

@StylianosGakis

@StylianosGakis StylianosGakis commented Nov 19, 2026 •

Copy link
Copy Markdown
Member
🤖 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.

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)
@notion-workspace

Copy link
Copy Markdown

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant