让OkHTTP日志拦截器仅记录请求的简单方法是什么?

huangapple go评论52阅读模式
英文:

Easy way to let OkHTTP logging interceptor to log only requests?

问题

我正在使用OkHTTP HTTP请求的普通日志记录到Android logcat。但是,如果我将级别配置为打印BODY,我会得到大量的响应,导致logcat缓冲区溢出,有时会崩溃。因此,为了解决这个问题,我只想记录请求。

是否有一种几乎可以立即使用的方法来实现这一点?

英文:

I am using normal logging of OkHTTP HTTP Request to Android logcat. However, if I configure the level to print BODY I get huge loads of responses which cause logcat buffer overflow and sometimes crash. Thus to workaround it I would like to log only requests.

Is there an almost out-of-the-box way of doing this?

答案1

得分: 1

查看源代码,似乎并没有这个选项。如果尚未存在,请考虑提出一个功能请求。或者,您可以分叉存储库并贡献这个更改。或者,复制源代码并进行修改以适应 — 它基于当前的 main 分支不到 1000 行 Kotlin 代码。

英文:

Looking at the source code, it does not seem like that is an option. You might consider filing a feature request for this, if there is none already. Or, fork the repo and contribute the change. Or, copy the source and modify it to suit — it is less than 1000 lines of Kotlin, based on current main.

huangapple
  • 本文由 发表于 2023年2月8日 19:42:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75385311.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定