forked from p15670423/monkey
cc: rename DEFAULT_LOGGING_CONFIG_PATH -> DEFAULT_LOGGER_CONFIG_PATH
This commit is contained in:
parent
74e0dfddc5
commit
5b781c50a4
|
@ -7,7 +7,7 @@ import json # noqa: E402
|
||||||
from monkey_island.cc.main import main # noqa: E402
|
from monkey_island.cc.main import main # noqa: E402
|
||||||
from monkey_island.cc.consts import (
|
from monkey_island.cc.consts import (
|
||||||
DEFAULT_SERVER_CONFIG_PATH,
|
DEFAULT_SERVER_CONFIG_PATH,
|
||||||
DEFAULT_LOGGING_CONFIG_PATH,
|
DEFAULT_LOGGER_CONFIG_PATH,
|
||||||
) # noqa: E402
|
) # noqa: E402
|
||||||
from monkey_island.cc.island_logger import json_setup_logging # noqa: E402
|
from monkey_island.cc.island_logger import json_setup_logging # noqa: E402
|
||||||
|
|
||||||
|
@ -34,23 +34,23 @@ def parse_cli_args():
|
||||||
default=DEFAULT_SERVER_CONFIG_PATH,
|
default=DEFAULT_SERVER_CONFIG_PATH,
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--logging-config",
|
"--logger-config",
|
||||||
action="store",
|
action="store",
|
||||||
help="The path to the logging configuration file.",
|
help="The path to the logging configuration file.",
|
||||||
default=DEFAULT_LOGGING_CONFIG_PATH,
|
default=DEFAULT_LOGGER_CONFIG_PATH,
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
return (args.setup_only, args.server_config, args.logging_config)
|
return (args.setup_only, args.server_config, args.logger_config)
|
||||||
|
|
||||||
|
|
||||||
if "__main__" == __name__:
|
if "__main__" == __name__:
|
||||||
(is_setup_only, server_config, logging_config) = parse_cli_args()
|
(is_setup_only, server_config, logger_config) = parse_cli_args()
|
||||||
|
|
||||||
# This is here in order to catch EVERYTHING, some functions are being called on
|
# This is here in order to catch EVERYTHING, some functions are being called on
|
||||||
# imports, so the log init needs to be first.
|
# imports, so the log init needs to be first.
|
||||||
try:
|
try:
|
||||||
json_setup_logging(logging_config)
|
json_setup_logging(logger_config)
|
||||||
except (json.JSONDecodeError) as ex:
|
except (json.JSONDecodeError) as ex:
|
||||||
print(f"Error loading logging config: {ex}")
|
print(f"Error loading logging config: {ex}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -13,6 +13,6 @@ DEFAULT_DEVELOP_SERVER_CONFIG_PATH = os.path.join(
|
||||||
MONKEY_ISLAND_ABS_PATH, "cc", "server_config.json.develop"
|
MONKEY_ISLAND_ABS_PATH, "cc", "server_config.json.develop"
|
||||||
)
|
)
|
||||||
|
|
||||||
DEFAULT_LOGGING_CONFIG_PATH = os.path.join(
|
DEFAULT_LOGGER_CONFIG_PATH = os.path.join(
|
||||||
MONKEY_ISLAND_ABS_PATH, "cc", "island_logger_default_config.json"
|
MONKEY_ISLAND_ABS_PATH, "cc", "island_logger_default_config.json"
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,13 +3,13 @@ import logging.config
|
||||||
import os
|
import os
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from monkey_island.cc.consts import DEFAULT_LOGGING_CONFIG_PATH
|
from monkey_island.cc.consts import DEFAULT_LOGGER_CONFIG_PATH
|
||||||
|
|
||||||
__author__ = "Maor.Rayzin"
|
__author__ = "Maor.Rayzin"
|
||||||
|
|
||||||
|
|
||||||
def json_setup_logging(
|
def json_setup_logging(
|
||||||
default_path=DEFAULT_LOGGING_CONFIG_PATH,
|
default_path=DEFAULT_LOGGER_CONFIG_PATH,
|
||||||
default_level=logging.INFO,
|
default_level=logging.INFO,
|
||||||
env_key="LOG_CFG",
|
env_key="LOG_CFG",
|
||||||
):
|
):
|
||||||
|
|
|
@ -4,7 +4,7 @@ import os
|
||||||
from monkey_island.cc.consts import MONKEY_ISLAND_ABS_PATH
|
from monkey_island.cc.consts import MONKEY_ISLAND_ABS_PATH
|
||||||
from monkey_island.cc.island_logger import json_setup_logging
|
from monkey_island.cc.island_logger import json_setup_logging
|
||||||
|
|
||||||
TEST_LOGGING_CONFIG_PATH = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "testing",
|
TEST_LOGGER_CONFIG_PATH = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "testing",
|
||||||
"logger_config.json")
|
"logger_config.json")
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ def test_expanduser_filename(monkeypatch, tmpdir):
|
||||||
|
|
||||||
set_home_env(monkeypatch, tmpdir)
|
set_home_env(monkeypatch, tmpdir)
|
||||||
|
|
||||||
json_setup_logging(TEST_LOGGING_CONFIG_PATH)
|
json_setup_logging(TEST_LOGGER_CONFIG_PATH)
|
||||||
|
|
||||||
logger = logging.getLogger("TestLogger")
|
logger = logging.getLogger("TestLogger")
|
||||||
logger.info(TEST_STRING)
|
logger.info(TEST_STRING)
|
||||||
|
|
Loading…
Reference in New Issue