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
nitrog42
11/08/2021, 3:57 PM
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
mbonnin
11/08/2021, 3:58 PM
You could define your own interceptor that doesn't log if the url matches a given pattern, it shouldn't be too complicated
✔️ 1
mbonnin
11/08/2021, 3:59 PM
The interceptors can read the request url
👍 2
n
nitrog42
11/08/2021, 4:01 PM
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
dimsuz
11/08/2021, 4:22 PM
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