Skip to content

Commit

Permalink
Add validator kind to error logs extra in validators (#671)
Browse files Browse the repository at this point in the history
To easily discern response and request validation errors logs
programmatically (e.g. in logging filter).
  • Loading branch information
bartekwojcicki authored and jmcs committed Sep 1, 2018
1 parent 87f7003 commit b6bb9dd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions connexion/decorators/validation.py
Expand Up @@ -141,7 +141,8 @@ def validate_schema(self, data, url):
self.validator.validate(data)
except ValidationError as exception:
logger.error("{url} validation error: {error}".format(url=url,
error=exception.message))
error=exception.message),
extra={'validator': 'body'})
return problem(400, 'Bad Request', str(exception.message))

return None
Expand All @@ -164,7 +165,8 @@ def validate_schema(self, data, url):
self.validator.validate(data)
except ValidationError as exception:
logger.error("{url} validation error: {error}".format(url=url,
error=exception))
error=exception),
extra={'validator': 'response'})
six.reraise(*sys.exc_info())

return None
Expand Down

0 comments on commit b6bb9dd

Please sign in to comment.