diff --git a/graphql/execution/base.py b/graphql/execution/base.py index f088a16b..3c0d2e95 100644 --- a/graphql/execution/base.py +++ b/graphql/execution/base.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -import sys +import logging +from traceback import format_exception from ..error import GraphQLError from ..language import ast @@ -11,6 +12,8 @@ from ..utils.type_from_ast import type_from_ast from .values import get_argument_values, get_variable_values +logger = logging.getLogger(__name__) + class ExecutionContext(object): """Data that must be available at all points during query execution. @@ -87,8 +90,8 @@ def get_argument_values(self, field_def, field_ast): return result def report_error(self, error, traceback=None): - sys.excepthook(type(error), error, getattr( - error, 'stack', None) or traceback) + exception = format_exception(type(error), error, getattr(error, 'stack', None) or traceback) + logger.error(''.join(exception)) self.errors.append(error) def get_sub_fields(self, return_type, field_asts):