Skip to content

Commit

Permalink
fix logger
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus committed Oct 1, 2022
1 parent d759fc6 commit b2f2ebb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions bumper/web/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def filter(self, record: logging.LogRecord) -> bool:
_LOGGER = get_logger("webserver")
# Add logging filter above to aiohttp.access
logging.getLogger("aiohttp.access").addFilter(_AiohttpFilter())
_LOGGER_PROXY = logging.getLogger("web_proxy")
_LOGGER_WEB_LOG = logging.getLogger("web_log")
_LOGGER_PROXY = get_logger("web_proxy")
_LOGGER_WEB_LOG = get_logger("web_log")


@dataclasses.dataclass(frozen=True)
Expand Down Expand Up @@ -381,17 +381,19 @@ async def _handle_proxy(self, request: Request) -> Response:
async def _handle_log(self, request: Request) -> Response:
to_log = {}
try:
to_log = {
"query_string": request.query_string,
"headers": set(request.headers.items()),
}
to_log.update(
{
"query_string": request.query_string,
"headers": set(request.headers.items()),
}
)
if request.content_length:
to_log["body"] = set(await request.post())
except Exception: # pylint: disable=broad-except
_LOGGER_WEB_LOG.exception(
"An exception occurred during logging the request.", exc_info=True
)
finally:
_LOGGER_WEB_LOG.debug(json.dumps(to_log, cls=CustomEncoder))
_LOGGER_WEB_LOG.info(json.dumps(to_log, cls=CustomEncoder))

return web.Response()

0 comments on commit b2f2ebb

Please sign in to comment.