0

我有一个小应用程序,我在其中使用 chalice 来公开一些端点。出于记录目的,我想在调用任何处理程序函数时打印整个 url。

@app.route('/XYZ', methods=['GET'])
@logging_and_error_handling()
def get_XYZ_value():

例如,如果上面的函数被调用,我想使用app.log.info(). 就像是call to http://myhostname.com/api/XYZ started

我尝试使用app.current_request.to_dict(),但看起来它没有该信息。吉特参考

有没有其他方法可以实现这一目标?

4

1 回答 1

2

我使用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')
于 2020-06-11T20:04:32.810 回答