我正在学习如何登录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?