我创建了一个标准的准系统烧瓶应用程序,它输出标准请求行,如下所示:
127.0.0.1 - - [07/Sep/2013 13:23:34] "GET /static/lib/jquery.js HTTP/1.1" 304 -
127.0.0.1 - - [07/Sep/2013 13:23:34] "GET /static/lib/bootstrap/js/bootstrap.min.js HTTP/1.1" 304 -
127.0.0.1 - - [07/Sep/2013 13:23:34] "GET /static/lib/md5.js HTTP/1.1" 304 -
127.0.0.1 - - [07/Sep/2013 13:23:34] "GET /static/lib/gmaps.js HTTP/1.1" 304 -
127.0.0.1 - - [07/Sep/2013 13:23:34] "GET /static/lib/ckeditor/ckeditor.js HTTP/1.1" 304 -
但是,一旦我TwilioRestClient
从python Twilio驱动程序初始化一个实例,日志记录就开始看起来像这样
127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/jquery.js HTTP/1.1" 304 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/jquery.js HTTP/1.1" 304 -
127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/bootstrap/js/bootstrap.min.js HTTP/1.1" 304 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/bootstrap/js/bootstrap.min.js HTTP/1.1" 304 -
127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/md5.js HTTP/1.1" 304 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/md5.js HTTP/1.1" 304 -
127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/gmaps.js HTTP/1.1" 304 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/gmaps.js HTTP/1.1" 304 -
127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/ckeditor/ckeditor.js HTTP/1.1" 304 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 13:23:55] "GET /static/lib/ckeditor/ckeditor.js HTTP/1.1" 304 -
前缀让我相信 werkzeug 使用默认的INFO:werkzeug:
python 记录器,但没有“启用”它,但 Twilio 进来并打开它。我敢肯定这不是它的工作原理,但你明白了。
初始化 Twilio 后是否必须手动禁用 python 记录器?怎么会这样?我可以只为 Twilio 启用它吗?
谢谢!
更新:重现问题
twilio_test.py
from flask import Flask
from twilio.rest import TwilioRestClient
app = Flask(__name__)
twilio_sid = 'TWILIO_SID'
twilio_auth_token = 'TWILIO_TOKEN'
origin_number = 'TWILIO_PHONE_NUMBER'
recipient_number = 'YOUR_CELL_NUMBER'
@app.route('/')
def hello():
return 'Hello!'
@app.route('/twilio/')
def hello_twilio():
twilio_client = TwilioRestClient(twilio_sid, twilio_auth_token)
twilio_msg = twilio_client.sms.messages.create(to=recipient_number, from_=origin_number, body='Twilio test script')
return 'Hello Twilio!'
if __name__ == '__main__':
app.run(debug=True)
输出(注意对 /twilio/ 的唯一请求在第 4 行)
127.0.0.1 - - [07/Sep/2013 17:07:12] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2013 17:07:12] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2013 17:07:12] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2013 17:07:18] "GET /twilio/ HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 17:07:18] "GET /twilio/ HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2013 17:07:20] "GET / HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 17:07:20] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2013 17:07:21] "GET / HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 17:07:21] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2013 17:07:21] "GET / HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [07/Sep/2013 17:07:21] "GET / HTTP/1.1" 200 -