我有一个小应用程序,在这里我使用 chalice 公开一些端点。为了记录日志,我想在调用任何处理程序函数时都打印整个URL。
@app.route('/XYZ', methods=['GET'])
@logging_and_error_handling()
def get_XYZ_value():
例如,如果调用了上述函数,我想使用
app.log.info()
记录整个URL。像
call to http://myhostname.com/api/XYZ started
这样的东西我尝试使用
app.current_request.to_dict()
,但似乎没有该信息。 Git reference。是否有其他方法可以实现这一目标?
最佳答案
我将app.current_request.context['resourcePath']
用作URL,并且还记录以下内容:
app.current_request.method
app.current_request.uri_params
app.current_request.query_params
app.current_request.context.get('requestId')
关于python - 如何使用 chalice 打印完整的http请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62147474/