From 3909dca4c942c6c0363797263ddc911844f05712 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 14 Jul 2022 11:12:49 -0400 Subject: [PATCH] Island: Pass special logger to WSGIServer --- monkey/monkey_island/cc/server_setup.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/server_setup.py b/monkey/monkey_island/cc/server_setup.py index e6365239f..3b08cd2f2 100644 --- a/monkey/monkey_island/cc/server_setup.py +++ b/monkey/monkey_island/cc/server_setup.py @@ -28,6 +28,7 @@ from monkey_island.cc.server_utils.consts import ( # noqa: E402 from monkey_island.cc.server_utils.island_logger import reset_logger, setup_logging # noqa: E402 from monkey_island.cc.services.initialize import initialize_services # noqa: E402 from monkey_island.cc.services.utils.network_utils import local_ip_addresses # noqa: E402 +from monkey_island.cc.setup import PyWSGILoggingFilter # noqa: E402 from monkey_island.cc.setup import island_config_options_validator # noqa: E402 from monkey_island.cc.setup.data_dir import IncompatibleDataDirectory, setup_data_dir # noqa: E402 from monkey_island.cc.setup.gevent_hub_error_handler import GeventHubErrorHandler # noqa: E402 @@ -145,13 +146,20 @@ def _start_island_server( app, certfile=config_options.crt_path, keyfile=config_options.key_path, - log=logger, + log=_get_wsgi_server_logger(), error_log=logger, ) _log_init_info() http_server.serve_forever() +def _get_wsgi_server_logger() -> logging.Logger: + wsgi_server_logger = logger.getChild("wsgi") + wsgi_server_logger.addFilter(PyWSGILoggingFilter()) + + return wsgi_server_logger + + def _log_init_info(): logger.info("Monkey Island Server is running!") logger.info(f"version: {get_version()}")