news 2026/9/15 20:46:41

okhttp 输出日志

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
okhttp 输出日志
/** 可以通过 setLevel 改变日志级别 * 共包含四个级别:NONE、BASIC、HEADER、BODY 1 2 3 4 * * NONE 不记录 * * BASIC 请求/响应行 * --> POST /greeting HTTP/1.1 (3-byte body) * <-- HTTP/1.1 200 OK (22ms, 6-byte body) * * HEADER 请求/响应行 + 头 * * --> Host: example.com * Content-Type: plain/text * Content-Length: 3 * * <-- HTTP/1.1 200 OK (22ms) * Content-Type: plain/text * Content-Length: 6 * * BODY 请求/响应行 + 头 + 体 */ if (!TextUtils.isEmpty(FunctionConfig.HTTP_LOG_LEVEL)) { val logger :HttpLoggingInterceptor.Logger = HttpLoggingInterceptor.Logger { message -> AppLog.testOnly("OkHttp输出:", message) } val loggingInterceptor: HttpLoggingInterceptor = HttpLoggingInterceptor(logger) when (FunctionConfig.HTTP_LOG_LEVEL) { "1" -> loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC) "2" -> loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS) "3" -> loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY) else -> loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE) } clientBuilder.addInterceptor(loggingInterceptor) // // 自定义 } Log.i("okhttp输出级别:" + FunctionConfig.HTTP_LOG_LEVEL) } catch (e: Exception) { e.printStackTrace() }

引入:

"com.squareup.okhttp3:logging-interceptor:3.6.0"
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/8/28 1:27:13

Kernel Toolkit for MS SQL: SQL 数据库及备份文件的恢复及迁移工具

Kernel Toolkit for MS SQL 工具包是一款专为数据库管理员打造的一站式解决方案。无论是解决严重的数据库损坏、恢复遗忘的密码&#xff0c;还是应对突发情况需要将数据库迁移至云端&#xff0c;这套工具都能满足用户的需求。它集成了四款强大的工具&#xff0c;为各种规模的企…

作者头像 李华
网站建设 2026/9/14 1:17:03

【Fish】——鱼类尾鳍的参数介绍

【Fish】——鱼类尾鳍的参数介绍 一、几何术语 二、展长(Span length,bbb) 通常,指的是尾鳍最上端(顶梢)到最下端(底梢)之间的直线距离 三、弦长(Chord length, ccc) 通常,指的是从尾鳍前缘(Leading edge)到后缘(Trailing edge)之间的直线距离。 由于尾鳍的…

作者头像 李华
网站建设 2026/9/7 14:37:37

Language Models Struggle to Use Representations Learned In-Context

Language Models Struggle to Use Representations Learned In-Context Authors: Michael A. Lepori, Tal Linzen, Ann Yuan, Katja Filippova Deep-Dive Summary: 论文总结&#xff1a;大语言模型中的思维链提示&#xff08;Chain-of-Thought Prompting&#xff09; 1. 引言…

作者头像 李华
网站建设 2026/9/15 15:53:06

运维为什么需要“懂这么多”?

在IT行业流传着一句话&#xff1a;“运维的知识体系像个无底洞&#xff0c;刚填完一个坑&#xff0c;转头又发现三个新坑。”这话道出了无数运维从业者的心声——从服务器上架到集群部署&#xff0c;从日志分析到灾备演练&#xff0c;从网络调优到安全加固&#xff0c;运维工作…

作者头像 李华