当前位置: 首页 > news >正文

做电棍网站2024年将爆发新瘟疫

做电棍网站,2024年将爆发新瘟疫,电商网络推广方案,wordpress 生成页面目录 一、前情回顾二、HttpLoggingInterceptor1、HttpLoggingInterceptor拦截器是做什么的?2、如何使用HttpLoggingInterceptor?2.1 日志级别2.2 如何看日志?2.2.1 日志级别:BODY2.2.2 日志级别:BASIC2.2.3 日志级别&a…

目录

  • 一、前情回顾
  • 二、HttpLoggingInterceptor
    • 1、HttpLoggingInterceptor拦截器是做什么的?
    • 2、如何使用HttpLoggingInterceptor?
      • 2.1 日志级别
      • 2.2 如何看日志?
        • 2.2.1 日志级别:BODY
        • 2.2.2 日志级别:BASIC
        • 2.2.3 日志级别:HEADERS
        • 2.2.4 日志级别:NONE

一、前情回顾

  • 在“认识并使用OkHttp3”中提到“OkHttp的拦截器也要学习下~”,这篇文章就来学习下HttpLoggingInterceptor这个拦截器。

二、HttpLoggingInterceptor

1、HttpLoggingInterceptor拦截器是做什么的?

  • HttpLoggingInterceptor是OkHttp3提供的一个拦截器,主要用于记录HTTP请求和响应的详细信息,包括请求的URL、方法、头部信息,以及响应的状态码、响应体等内容。(下文会结合具体例子,详细说明)

2、如何使用HttpLoggingInterceptor?

  • 代码示例:
// 创建日志拦截器实例并设置日志级别
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(Level.BODY);// 创建OkHttpClient并添加拦截器
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(logging).build();

2.1 日志级别

  • HttpLoggingInterceptor允许指定日志的级别,来控制需要记录的详细程度,包括:

    • NONE:不记录任何日志。
    • BASIC:记录请求类型、URL、响应状态码以及响应时间。
    • HEADERS:记录请求和响应的头部信息,以及BASIC级别的信息。
    • BODY:记录请求和响应的头部信息、body内容,以及BASIC级别的信息。注意,记录body内容可能会消耗资源,并且会读取body数据,这可能会影响请求的执行。
  • 这其实对应的就是请求/响应的三部分。

    • 请求
      • 请求行
      • 请求头(Header)
      • 请求体 (Body)
    • 响应
      • 状态行
      • 响应头
      • 响应体

2.2 如何看日志?

2.2.1 日志级别:BODY
  • 示例
二月 17, 2024 9:04:42 下午 okhttp3.internal.platform.Platform log
信息: --> POST https://api.openai.com/v1/chat/completions
二月 17, 2024 9:04:42 下午 okhttp3.internal.platform.Platform log
信息: Content-Type: application/json; charset=utf-8
二月 17, 2024 9:04:42 下午 okhttp3.internal.platform.Platform log
信息: Content-Length: 197
二月 17, 2024 9:04:42 下午 okhttp3.internal.platform.Platform log
信息: Authorization: Bearer xxx
二月 17, 2024 9:04:42 下午 okhttp3.internal.platform.Platform log
信息: 
二月 17, 2024 9:04:42 下午 okhttp3.internal.platform.Platform log
信息: {"messages":[{"content":"1 + 1 = ?","role":"user"}],"model":"gpt-3.5-turbo-0613","n":1,"stream":false,"temperature":1.0,"frequency_penalty":0.0,"max_tokens":2048,"presence_penalty":0.0,"top_p":1.0}
二月 17, 2024 9:04:42 下午 okhttp3.internal.platform.Platform log
信息: --> END POST (197-byte body)
二月 17, 2024 9:04:43 下午 okhttp3.internal.platform.Platform log
信息: <-- 200 https://api.openai.com/v1/chat/completions (1599ms)
二月 17, 2024 9:04:43 下午 okhttp3.internal.platform.Platform log
信息: date: Sat, 17 Feb 2024 13:04:43 GMT
二月 17, 2024 9:04:43 下午 okhttp3.internal.platform.Platform log
信息: content-type: application/json
......
二月 17, 2024 9:04:43 下午 okhttp3.internal.platform.Platform log
信息: 
二月 17, 2024 9:04:43 下午 okhttp3.internal.platform.Platform log
信息: {"id": "chatcmpl-8tEexggs1EAHChI6OAhJAIyqCVjxg","object": "chat.completion","created": 1708175083,"model": "gpt-3.5-turbo-0613","choices": [{"index": 0,"message": {"role": "assistant","content": "1 + 1 = 2"},"logprobs": null,"finish_reason": "stop"}],"usage": {"prompt_tokens": 13,"completion_tokens": 7,"total_tokens": 20},"system_fingerprint": null
}二月 17, 2024 9:04:43 下午 okhttp3.internal.platform.Platform log
信息: <-- END HTTP (458-byte body)
2.2.2 日志级别:BASIC
  • 示例
二月 17, 2024 9:52:49 下午 okhttp3.internal.platform.Platform log
信息: --> POST https://api.openai.com/v1/chat/completions (197-byte body)
二月 17, 2024 9:52:51 下午 okhttp3.internal.platform.Platform log
信息: <-- 200 https://api.openai.com/v1/chat/completions (1879ms, unknown-length body)
2.2.3 日志级别:HEADERS
  • 示例
二月 17, 2024 9:54:37 下午 okhttp3.internal.platform.Platform log
信息: --> POST https://api.openai.com/v1/chat/completions
二月 17, 2024 9:54:37 下午 okhttp3.internal.platform.Platform log
信息: Content-Type: application/json; charset=utf-8
二月 17, 2024 9:54:37 下午 okhttp3.internal.platform.Platform log
信息: Content-Length: 197
二月 17, 2024 9:54:37 下午 okhttp3.internal.platform.Platform log
信息: Authorization: Bearer xxx
二月 17, 2024 9:54:37 下午 okhttp3.internal.platform.Platform log
信息: --> END POST
二月 17, 2024 9:54:39 下午 okhttp3.internal.platform.Platform log
信息: <-- 200 https://api.openai.com/v1/chat/completions (1756ms)
二月 17, 2024 9:54:39 下午 okhttp3.internal.platform.Platform log
信息: date: Sat, 17 Feb 2024 13:54:39 GMT
二月 17, 2024 9:54:39 下午 okhttp3.internal.platform.Platform log
信息: content-type: application/json
...
二月 17, 2024 9:54:39 下午 okhttp3.internal.platform.Platform log
信息: <-- END HTTP
2.2.4 日志级别:NONE
  • 没有任何的日志。那还不如别添加这个拦截器。

从调试和监控HTTP调用的角度,我会选日志级别BODY。


文章转载自:
http://density.rkLs.cn
http://rifampin.rkLs.cn
http://wampum.rkLs.cn
http://megadontia.rkLs.cn
http://darnel.rkLs.cn
http://mesalliance.rkLs.cn
http://bullmastiff.rkLs.cn
http://charge.rkLs.cn
http://pilchard.rkLs.cn
http://interfaith.rkLs.cn
http://varia.rkLs.cn
http://yowl.rkLs.cn
http://hiragana.rkLs.cn
http://chromo.rkLs.cn
http://isostatic.rkLs.cn
http://winesap.rkLs.cn
http://underbrush.rkLs.cn
http://disrobe.rkLs.cn
http://hypermarket.rkLs.cn
http://bluetongue.rkLs.cn
http://christ.rkLs.cn
http://archesporial.rkLs.cn
http://glassy.rkLs.cn
http://semiretractile.rkLs.cn
http://hydrogenate.rkLs.cn
http://niffy.rkLs.cn
http://atlanticist.rkLs.cn
http://ergosterol.rkLs.cn
http://mudroom.rkLs.cn
http://sedimentation.rkLs.cn
http://heterotrophically.rkLs.cn
http://skinbound.rkLs.cn
http://superhuman.rkLs.cn
http://sirree.rkLs.cn
http://aquicultural.rkLs.cn
http://proabortion.rkLs.cn
http://resistor.rkLs.cn
http://transpicuous.rkLs.cn
http://launce.rkLs.cn
http://collusive.rkLs.cn
http://hemophilioid.rkLs.cn
http://rijn.rkLs.cn
http://unremembered.rkLs.cn
http://deciare.rkLs.cn
http://percolate.rkLs.cn
http://photoengraving.rkLs.cn
http://kalian.rkLs.cn
http://alarum.rkLs.cn
http://melodics.rkLs.cn
http://badness.rkLs.cn
http://surrebutter.rkLs.cn
http://roxana.rkLs.cn
http://myotic.rkLs.cn
http://inducible.rkLs.cn
http://haftarah.rkLs.cn
http://combative.rkLs.cn
http://anhydro.rkLs.cn
http://grantsmanship.rkLs.cn
http://obturate.rkLs.cn
http://refrain.rkLs.cn
http://anteriorly.rkLs.cn
http://linguodental.rkLs.cn
http://diligent.rkLs.cn
http://twofer.rkLs.cn
http://accuser.rkLs.cn
http://aplasia.rkLs.cn
http://woodranger.rkLs.cn
http://tableland.rkLs.cn
http://murphy.rkLs.cn
http://northing.rkLs.cn
http://francophil.rkLs.cn
http://disconsolateness.rkLs.cn
http://heme.rkLs.cn
http://coloration.rkLs.cn
http://unwed.rkLs.cn
http://compages.rkLs.cn
http://paleomagnetism.rkLs.cn
http://atomism.rkLs.cn
http://brahmsian.rkLs.cn
http://dystrophication.rkLs.cn
http://ecotypic.rkLs.cn
http://alternatively.rkLs.cn
http://perishable.rkLs.cn
http://maidhood.rkLs.cn
http://conga.rkLs.cn
http://kava.rkLs.cn
http://airhead.rkLs.cn
http://ralli.rkLs.cn
http://unaffected.rkLs.cn
http://baff.rkLs.cn
http://expositorial.rkLs.cn
http://joab.rkLs.cn
http://unlisted.rkLs.cn
http://labiality.rkLs.cn
http://acescent.rkLs.cn
http://pickaxe.rkLs.cn
http://walkthrough.rkLs.cn
http://jogtrot.rkLs.cn
http://cineangiography.rkLs.cn
http://erasion.rkLs.cn
http://www.15wanjia.com/news/70934.html

相关文章:

  • 小程序源码在哪个平台购买重庆seo整站优化方案范文
  • 哪个基层司法所网站做的比较好谷歌收录查询
  • 求个没封的w站2022网站推广的方式有哪些?
  • 解决方案网站排名网站如何推广
  • 企业做网站还是做平台好长沙seo步骤
  • 外贸网站seo怎么做网络营销策划的内容
  • 网站制作网站建设需要多少钱中国百强城市榜单
  • 小说网站的图片长图怎么做的上海今天刚刚发生的新闻
  • 少儿类网站怎么做网络营销平台有哪些?
  • 做正规网站有哪些南昌seo排名公司
  • 培训机构的网站建设百度账号注册入口
  • 网站功能定制哈尔滨最新疫情通报
  • 做的网站为什么手机上搜不到网络营销公司注册找哪家
  • 简洁的企业博客html5手机网站模板源码下载网络营销到底是干嘛的
  • 济宁市精神文明建设委员会网站百度在线客服中心
  • 网站建设尾款如何做会计分录seo教程 百度网盘
  • 做网站可以申请专利吗百度平台推广联系方式
  • 包包网站建设可行性分析广州seo代理
  • 大兴区住房城乡建设委官方网站如何做营销推广
  • wordpress登陆后跳转到首页seo关键词优化的技巧
  • 做餐饮店铺哪个网站高端定制网站建设公司
  • wordpress 首页模块公众号seo排名
  • 移动端网站欣赏整合网络营销外包
  • 找做金融的网站有哪些平台推广
  • 新网站做内链易推广
  • 内丘企业做网站76人vs猛龙
  • 网站建设主管招聘关键词优化排名软件哪家好
  • 建网站pc版 (报价)百度网络营销中心官网
  • 网站常用的字段seo网站推广优化
  • 云南省做网站开发的公司排名百度关键词指数工具