From 0c8521d1378f4955d23960d5ee1e9449cdadbaf5 Mon Sep 17 00:00:00 2001 From: CaselIT Date: Wed, 26 Sep 2018 20:42:51 +0200 Subject: [PATCH] Use exc_info keyword when logging an exception. This allows easier filtering of exception with logging filters --- graphql/execution/utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/graphql/execution/utils.py b/graphql/execution/utils.py index b1e7ff25..a19703ae 100644 --- a/graphql/execution/utils.py +++ b/graphql/execution/utils.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import logging -from traceback import format_exception from ..error import GraphQLError from ..language import ast @@ -145,10 +144,8 @@ def get_argument_values(self, field_def, field_ast): def report_error(self, error, traceback=None): # type: (Exception, Optional[TracebackType]) -> None - exception = format_exception( - type(error), error, getattr(error, "stack", None) or traceback - ) - logger.error("".join(exception)) + info = (type(error), error, getattr(error, "stack", None) or traceback) + logger.error("%s", error, exc_info=info) self.errors.append(error) def get_sub_fields(self, return_type, field_asts):