加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 来自django runserver的特定日志输出来自何处

发布时间:2020-12-16 21:50:22 所属栏目:Python 来源:网络整理
导读:我正在学习如何登录python,所以我试图找到源代码中的哪个部分来格式化该行的特定输出:“GET / dashboard / HTTP / 1.1”200 249176?另外,249176是什么意思? 我没有问题,这个问题是为了满足我的好奇心. 我真的在寻找这个logrecord的格式化程序.我也没有看

我正在学习如何登录python,所以我试图找到源代码中的哪个部分来格式化该行的特定输出:“GET / dashboard / HTTP / 1.1”200 249176?另外,249176是什么意思?

我没有问题,这个问题是为了满足我的好奇心.

我真的在寻找这个logrecord的格式化程序.我也没有看到它来自哪个loghandler(也许这根本不是来自日志记录模块,它只是一个打印命令).我搜索了源代码,无法找到它的来源,并希望有一个链接到源代码.

以下是我运行代码时会发生的情况.

September 05,2013 - 05:38:50
Django version 1.5.1,using settings 'dapi.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Sep/2013 05:38:57] "GET /dashboard/ HTTP/1.1" 200 249176
[05/Sep/2013 05:38:58] "GET /static/plugins/uniform/css/uniform.default.css HTTP/1.1" 304 0
[05/Sep/2013 05:38:58] "GET /static/plugins/bootstrap-daterangepicker/daterangepicker.css HTTP/1.1" 304 0
最佳答案
此数字是响应内容长度,换句话说:发送的字节数.

这个输出基本上来自wsgiref的simple_server(它基于BaseHTTPServer)django内部使用(source).

log_request()函数实际上记录了引擎盖下的代码和内容大小:

log_request([code[,size]])

Logs an accepted (successful) request.
code should specify the numeric HTTP code associated with the
response. If a size of the response is available,then it should be
passed as the size parameter.

如果您有兴趣,请查看BaseHTTPServer pypy实现:https://bitbucket.org/pypy/pypy/src/9d88b4875d6e/lib-python/2.7/BaseHTTPServer.py

也可以看看:

> What’s the meaning of the default output of manage.py runserver?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读