Another okhttp question: while using `HttpLoggingI...
# squarelibraries
d
Another okhttp question: while using
HttpLoggingInterceptor
sometimes I have to deal with polling `GET`s which get executed every 2 seconds, and they spam log a lot. I understand that there's no ready solution to disable logging on a per-url basis or to rate limit logs, but maybe I've missed something? Asking before I invent my own 🙂
n
I don't think there is a way for this but I would consider using two instances of okhttp/retrofit, one for the polling machine (with log disabled ?), one for the rest of the network calls (with log enabled)
m
You could define your own interceptor that doesn't log if the url matches a given pattern, it shouldn't be too complicated
✔️ 1
The interceptors can read the request url
👍 2
n
you just have to copy the HttpLoggingInterceptor class and modify it. I think the only issue is calling an endpoint outside of the polling and wanting the logs for this call
d
Yeah, that was what I had in mind: copy interceptor and adjust it, but thought maybe there's some solution already. I thought of making this more generic when using Retrofit: I could do
Copy code
interface {
  @GET
  @Header("DoNotLog: True")
  fun pollingBeast()
}
And then interceptor could see this header, remove it and ignore this request in logs
✔️ 2