Skip to content

Deja de registrar el tráfico HTTP completo por defecto - #4

Merged
mijhaels merged 1 commit into
mainfrom
feat/configurable-logging
Oct 12, 2026
Merged

mijhaels merged 1 commit into
mainfrom
feat/configurable-logging

Conversation

@mijhaels

Copy link
Copy Markdown
Contributor

Summary

TuRuc.getClient() agregaba siempre un HttpLoggingInterceptor en BODY. Así, cada consulta escribía en el log de quien usa la librería la petición y la respuesta completas, con RUC, razón social y estado, y no había forma de desactivarlo.

 TuRuc.getClient()
   OkHttpClient.Builder (timeouts)
-  addInterceptor(HttpLoggingInterceptor[BODY])        # siempre
+  if logLevel != NONE                                  # NONE por defecto
+    addInterceptor(HttpLoggingInterceptor[logLevel])
+TuRuc.withLogLevel(HttpLoggingInterceptor.Level)       # opt-in, rechaza null
 build.gradle
-  implementation("com.squareup.okhttp3:logging-interceptor")
+  api("com.squareup.okhttp3:logging-interceptor")      # Level queda en la API pública

Uso para depurar:

new TuRuc(url).withLogLevel(HttpLoggingInterceptor.Level.BODY).getClient();

Evidence

Los tests capturan el logger okhttp3.OkHttpClient de java.util.logging:

  • Before: con un withLogLevel de prueba que no cambiaba nada, doesNotLogRequestsByDefault falla (se registra el cuerpo) → 12 tests completed, 1 failed.
    After: doesNotLogRequestsByDefault, logsResponseBodyWhenRequested y rejectsNullLogLevel pasan → 12 tests, 0 failures. clean build (Spotless, PMD, -Werror) pasa.

Merge Danger

Door: two-way

Va antes de la primera publicación en Maven Central (PR #3), para que la 0.1.0 no salga registrando datos de contribuyentes.

Blast Radius: Consumidores

Quien dependía de esos logs tiene que activarlos con withLogLevel. El README y el CHANGELOG lo documentan.

🤖 Generated with Claude Code

TuRuc always added an HttpLoggingInterceptor at BODY level, so every
lookup wrote the full request and response, including taxpayer data, to
the consumer's logs with no way to turn it off.

Default to no logging and add TuRuc.withLogLevel(Level) to opt in.
logging-interceptor becomes an api dependency because Level is part of
the public API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mijhaels
mijhaels merged commit 8b202b4 into main Oct 12, 2026
6 checks passed
@mijhaels
mijhaels deleted the feat/configurable-logging branch October 27, 2026 15:15
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