From e1e845ef2dde448ce91e6f85037253a3f70cd155 Mon Sep 17 00:00:00 2001 From: girst Date: Tue, 21 Jul 2020 14:55:24 +0200 Subject: [PATCH] log POST request data on internal errors --- app/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index a6da5e3..53568cc 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -17,11 +17,13 @@ for name in cf['frontend']['modules'].split(','): # TODO: should this go somewhere else? -# This error handler logs requests to external apis. this makes debugging of api responses easier, as the request can be reconstructed and replayed. -from flask import g +# This error handler logs requests to external apis, and POST data. this makes debugging of api responses easier, as the request can be reconstructed and replayed. +from flask import g, request from werkzeug.exceptions import InternalServerError @app.errorhandler(InternalServerError) def log_errors(e): + if request.method == "POST": + app.logger.error(request.data) if 'api_requests' in g: app.logger.error(g.api_requests) return e -- 2.39.3