diff --git a/assessment_module_manager/assessment_module_manager/__main__.py b/assessment_module_manager/assessment_module_manager/__main__.py index 4505e76e7..aef21affc 100644 --- a/assessment_module_manager/assessment_module_manager/__main__.py +++ b/assessment_module_manager/assessment_module_manager/__main__.py @@ -3,15 +3,18 @@ """ import uvicorn -from .app import app -from . import endpoints, env -from .logger import logger +from uvicorn.config import LOGGING_CONFIG +from assessment_module_manager.app import app +from assessment_module_manager import endpoints, env +from assessment_module_manager.logger import logger def main(): """ Start the assessment module manager using uvicorn. """ + LOGGING_CONFIG["formatters"]["default"]["fmt"] = "%(asctime)s %(levelname)s --- [%(name)s] : %(message)s" + LOGGING_CONFIG["formatters"]["access"]["fmt"] = "%(asctime)s %(levelname)s --- [%(name)s] : %(message)s" logger.info("Starting assessment module manager") if env.PRODUCTION: diff --git a/assessment_module_manager/assessment_module_manager/app.py b/assessment_module_manager/assessment_module_manager/app.py index 712e5eb6a..4b1439dfc 100644 --- a/assessment_module_manager/assessment_module_manager/app.py +++ b/assessment_module_manager/assessment_module_manager/app.py @@ -2,7 +2,7 @@ from fastapi.exceptions import RequestValidationError from fastapi.responses import JSONResponse -from .logger import logger +from assessment_module_manager.logger import logger description = """ This is the Athena API. You are interacting with the Assessment Module Manager, diff --git a/assessment_module_manager/assessment_module_manager/env.py b/assessment_module_manager/assessment_module_manager/env.py index 561cfb8b6..2c0327b7f 100644 --- a/assessment_module_manager/assessment_module_manager/env.py +++ b/assessment_module_manager/assessment_module_manager/env.py @@ -1,7 +1,7 @@ """Common place for environment variables with sensible defaults for local development.""" import os -from .module.list_modules import list_modules +from assessment_module_manager.module.list_modules import list_modules PRODUCTION = os.environ.get("PRODUCTION", "0") == "1" SECRET = os.getenv("SECRET") diff --git a/assessment_module_manager/assessment_module_manager/logger.py b/assessment_module_manager/assessment_module_manager/logger.py index 8f7ca67af..35aed1f9c 100644 --- a/assessment_module_manager/assessment_module_manager/logger.py +++ b/assessment_module_manager/assessment_module_manager/logger.py @@ -6,6 +6,6 @@ logger.setLevel(DEBUG) handler = StreamHandler(sys.stdout) handler.setLevel(DEBUG) -formatter = Formatter('[%(levelname)s] %(message)s') +formatter = Formatter('%(asctime)s %(levelname)s --- [assessment_module_manager] : %(message)s') handler.setFormatter(formatter) -logger.addHandler(handler) \ No newline at end of file +logger.addHandler(handler) diff --git a/athena/athena/app.py b/athena/athena/app.py index 24227a807..b73cc045d 100644 --- a/athena/athena/app.py +++ b/athena/athena/app.py @@ -4,6 +4,7 @@ The only exception is the `start` method, which is used to start the module. """ import uvicorn +from uvicorn.config import LOGGING_CONFIG from fastapi import FastAPI, Request from fastapi.exceptions import RequestValidationError from fastapi.responses import JSONResponse @@ -31,6 +32,8 @@ def __init__(self, *args, **kwargs): def start(self) -> None: """Start Athena. You have to ensure to have `app` in your module main scope so that it can be imported.""" + LOGGING_CONFIG["formatters"]["default"]["fmt"] = "%(asctime)s %(levelname)s --- [%(name)s] : %(message)s" + LOGGING_CONFIG["formatters"]["access"]["fmt"] = "%(asctime)s %(levelname)s --- [%(name)s] : %(message)s" logger.info("Starting athena module") conf = get_module_config() diff --git a/athena/athena/logger.py b/athena/athena/logger.py index 3c8e5c520..1e6a27757 100644 --- a/athena/athena/logger.py +++ b/athena/athena/logger.py @@ -7,6 +7,6 @@ logger.setLevel(DEBUG) handler = StreamHandler(sys.stdout) handler.setLevel(DEBUG) -formatter = Formatter('[%(levelname)s] %(message)s') +formatter = Formatter('%(asctime)s %(levelname)s --- [athena] : %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) diff --git a/module_programming_themisml/module_programming_themisml/__main__.py b/module_programming_themisml/module_programming_themisml/__main__.py index f8f9ef0fd..466d63bce 100644 --- a/module_programming_themisml/module_programming_themisml/__main__.py +++ b/module_programming_themisml/module_programming_themisml/__main__.py @@ -9,8 +9,8 @@ from athena.storage import store_feedback from athena.storage.feedback_storage import store_feedback_suggestions -from .extract_methods import get_feedback_method -from .feedback_suggestions import create_feedback_suggestions, filter_overlapping_suggestions, filter_suspicious +from module_programming_themisml.extract_methods import get_feedback_method +from module_programming_themisml.feedback_suggestions import create_feedback_suggestions, filter_overlapping_suggestions, filter_suspicious @submissions_consumer