Skip to content

fix: route networkmock logging through Kermit - #123

Open
MaxMichel2 wants to merge 1 commit into
mainfrom
fix/networkmock-kermit-logging
Open

MaxMichel2 wants to merge 1 commit into
mainfrom
fix/networkmock-kermit-logging

Conversation

@MaxMichel2

Copy link
Copy Markdown
Collaborator

Summary

Closes #86.

devview-networkmock-core and devview-networkmock-ktor emitted ~35 unconditional println calls covering config loading, request matching, and response serving, with no way to turn them off. This routes all of them through Kermit — already a dependency of every DevView library module via the multiplatform convention plugin, and already used by devview-networkmock's own UI (LocalMockColorScheme.kt) — so this adds no new dependency and no new abstraction.

What changed

  • MockConfigRepository: spec-load success logs at debug, load failures at warn with the throwable attached, request-matching outcomes at verbose.
  • NetworkMockPlugin: the previous per-request trace (up to ~15 lines including 7 decorative ==== separators) collapses into one line per intercepted request, e.g.:
    GET /v1/users/42 -> MOCK 200/default
    GET /v1/users/42 -> NETWORK (no operation match)
    
  • All logs are tagged DevViewNetworkMock — the same tag devview-networkmock's UI already uses — so a host can filter every NetworkMock log line by tag regardless of which module emitted it, and devview-consolelogger, if installed, captures them automatically via its Kermit LogWriter.
  • No response body content is ever logged — status code + example name is the whole useful payload.
  • Detekt's ForbiddenMethodCall rule (flagging kotlin.io.println/print) is flipped from active: false to active: true repo-wide. Verified clean — these two files were the only main-source println call sites in the repo.
  • No new opt-out flag: a host silences/adjusts verbosity via Kermit's own Logger.setMinSeverity(...), documented in the module docs.

Not in scope

No public API change — no apiDump needed.

Verification

.\gradlew.bat detektFull -Pandroidx.baselineprofile.skipgeneration
.\gradlew.bat cleanTestAndroidHostTest testAndroidHostTest -Pandroidx.baselineprofile.skipgeneration
.\gradlew.bat :konsist:test -Pandroidx.baselineprofile.skipgeneration
.\gradlew.bat :sample:androidApp:assembleDebug -Pandroidx.baselineprofile.skipgeneration

All green.

🤖 Generated with Claude Code

Replaces ~35 unconditional println calls in MockConfigRepository and
NetworkMockPlugin with gated Kermit logging (tag DevViewNetworkMock,
shared with devview-networkmock's UI logging). The plugin's multi-line
per-request trace (including 7 decorative '====' separators) collapses
into one line per intercepted request, e.g.:

  GET /v1/users/42 -> MOCK 200/default
  GET /v1/users/42 -> NETWORK (no operation match)

No response body content is ever logged. Detekt's ForbiddenMethodCall
rule (println/print) is now enforced repo-wide - confirmed via a clean
detektFull run with no other println call sites in main source.

A host app can silence or adjust verbosity via Logger.setMinSeverity(...);
devview-consolelogger, if installed, captures these logs automatically.

Closes #86.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

fix: gate networkmock logging

1 participant