From ce4ff0b92ea95a76b651d2bbe95d2cedc5e4d815 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 18 Jul 2018 00:20:32 +0200 Subject: [PATCH] Fix exception logging --- app.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 5317143..41605dc 100644 --- a/app.py +++ b/app.py @@ -3,6 +3,7 @@ import json import logging import mimetypes import os +import traceback import urllib from datetime import datetime from datetime import timezone @@ -404,7 +405,9 @@ def is_api_request(): @app.errorhandler(ValueError) def handle_value_error(error): - logger.error(f"caught value error: {error!r}, {error.__traceback__!r}") + logger.error( + f"caught value error: {error!r}, {traceback.format_tb(error.__traceback__)}" + ) response = flask_jsonify(message=error.args[0]) response.status_code = 400 return response @@ -412,7 +415,9 @@ def handle_value_error(error): @app.errorhandler(Error) def handle_activitypub_error(error): - logger.error(f"caught activitypub error {error!r}, {error.__traceback__!r}") + logger.error( + f"caught activitypub error {error!r}, {traceback.format_tb(error.__traceback__)}" + ) response = flask_jsonify(error.to_dict()) response.status_code = error.status_code return response