Skip to content

Commit

Permalink
Add in http_logger, we can use this in DEV/TEST, but not PROD. (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Dec 5, 2023
1 parent 1aa7dc8 commit d5053bd
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from werkzeug.exceptions import HTTPException, default_exceptions
import logging
logger = logging.getLogger('api-exceptions')
http_logger = logging.getLogger('api-exceptions-http')

RESPONSE_HEADERS = {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}

Expand All @@ -31,7 +32,7 @@ def __init__(self, app=None):

def auth_handler(self, error): # pylint: disable=no-self-use
"""Handle AuthError."""
logger.error(error.error)
http_logger.error(error.error)
return error.error, error.status_code, RESPONSE_HEADERS

def db_handler(self, error): # pylint: disable=no-self-use
Expand All @@ -46,7 +47,7 @@ def db_handler(self, error): # pylint: disable=no-self-use
def std_handler(self, error): # pylint: disable=no-self-use
"""Handle standard exception."""
if isinstance(error, HTTPException):
logger.error(error)
http_logger.error(error)
message = dict(message=error.message if hasattr(error, 'message') else error.description)
else:
logger.exception(error)
Expand Down

0 comments on commit d5053bd

Please sign in to comment.