log user agents on api call auth.

this'll be useful for trying to figure out which services are using what
This commit is contained in:
Leo Hemsted
2017-12-14 17:12:26 +00:00
parent 32a6f44d3a
commit 9297c6d430
2 changed files with 9 additions and 3 deletions

View File

@@ -1,8 +1,10 @@
import json
from flask import jsonify, current_app
from flask import jsonify, current_app, request
from jsonschema import ValidationError
from sqlalchemy.exc import DataError
from sqlalchemy.orm.exc import NoResultFound
from app.authentication.auth import AuthError
from app.errors import InvalidRequest
@@ -79,7 +81,7 @@ def register_errors(blueprint):
@blueprint.errorhandler(AuthError)
def auth_error(error):
current_app.logger.info('API AuthError: {}'.format(error))
current_app.logger.info('API AuthError, client: {} error: {}'.format(request.headers.get('User-Agent'), error))
return jsonify(error.to_dict_v2()), error.code
@blueprint.errorhandler(Exception)