Output as much human-readable text as possible to the log.#8855
Conversation
|
HttpLoggingInterceptor isn't designed to be everything to everyone. And shouldn't be doing anything magic. So the first response to PRs changing the logging interceptor is to suggest you copy and paste it and change as you need in your own project. |
|
Yeah, I think you’ll be better served by Chucker or similar. |
|
Hi, thanks again for your feedback and for maintaining OkHttp! I understand and agree that HttpLoggingInterceptor should not be doing anything "magic". However, I would argue that its current behavior can already be a bit unpredictable, which may surprise developers in real-world usage. For example:
So while trying to be helpful, the current implementation might mislead developers into thinking all logged content is safe and readable, when it’s not. If the intended role of HttpLoggingInterceptor is to serve primarily as a simple example or starting point, it might help to make that explicit in the documentation, so developers are aware of its limitations. Perhaps even a name like SimpleHttpLoggingInterceptor would clarify its scope. That said, I totally understand your preference to avoid adding complexity. My PR was an attempt to make it safer for more common debugging scenarios, without introducing heuristics or smart guessing. Would it be acceptable to:
Thanks again for the thoughtful discussion! |
|
I meant not "magic" as in, nothing in the impl requires being part of OkHttp. So everyone is free to write the one they think is ideal. |
| val count = s.codePointCount(0, s.length) | ||
| for (i in 0 until count) { | ||
| val codePoint = s.codePointAt(i) | ||
| if (codePoint.isProbablyUtf8CodePoint()) { |
There was a problem hiding this comment.
This feels like a lot of extra work for these cases. I think for clients sending/receiving possibly binary data, they should just avoid logging it, or write a custom impl.
|
Going to close as not planned.
There is a high bar, so even simple fixes like this one to LoggingEventListener often don't make the cut |
No description provided.