diff --git a/__main__.py b/__main__.py index c3078718..a6598313 100644 --- a/__main__.py +++ b/__main__.py @@ -19,13 +19,12 @@ logger = get_logger(__name__) def handle_keyboard_interrupt(signum, frame): - print("Cleaning up...") cleanup() asyncio.get_event_loop().stop() def cleanup(): # Perform any necessary cleanup here - logger.info("Performing cleanup tasks...") + logger.info("Performing cleanup tasks.") if __name__ == "__main__": # Set up signal handlers @@ -33,14 +32,14 @@ def cleanup(): #signal.signal(signal.SIGTERM, handle_keyboard_interrupt) # Create the app - logger.info("Creating the app...") + logger.info("Creating the app.") from app import create_app app = create_app() # Run the app import uvicorn - logger.info("Running the app...") + logger.info("Running the app with uvicorn.") try: uvicorn.run("app:create_app", host="localhost", port=3080, factory=True, workers=1, reload=True, reload_dirs=[backend_dir], reload_excludes=[venv_dir], log_config=logging_config) except KeyboardInterrupt: diff --git a/backend/db.py b/backend/db.py index 11260491..81e5ea21 100644 --- a/backend/db.py +++ b/backend/db.py @@ -10,7 +10,7 @@ # use alembic to create the database or migrate to the latest schema def init_db(): - logger.info("Initializing database...") + logger.info("Initializing database.") alembic_cfg = AlembicConfig() os.makedirs(db_path.parent, exist_ok=True) alembic_cfg.set_main_option("script_location", str(base_dir / "migrations")) diff --git a/common/config.py b/common/config.py index a0aea272..2b27c70c 100644 --- a/common/config.py +++ b/common/config.py @@ -6,7 +6,7 @@ "disable_existing_loggers": False, "formatters": { 'standard': { - 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s' + 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s', }, "uvicorn_default": { "()": "uvicorn.logging.DefaultFormatter", @@ -22,13 +22,22 @@ }, "handlers": { + # TODO: standardise formatting; for now use uvicorn_default + "default": { + #"formatter": "standard", + "formatter": "uvicorn_default", + "class": "logging.StreamHandler", + "stream": "ext://sys.stderr", + }, "standard": { - "formatter": "standard", + #"formatter": "standard", + "formatter": "uvicorn_default", "class": "logging.StreamHandler", "stream": "ext://sys.stderr", }, "uvicorn_default": { "formatter": "uvicorn_default", + #"formatter": "standard", "class": "logging.StreamHandler", "stream": "ext://sys.stderr", }, @@ -50,10 +59,11 @@ }, }, "loggers": { - "": {"handlers": ["standard"], "level": "INFO"}, # root logger + "": {"handlers": ["default"], "level": "INFO"}, # root logger "connexion": {"handlers": ["connexion"], "level": "DEBUG", "propagate": False}, "uvicorn": {"handlers": ["uvicorn_default"], "level": "INFO", "propagate": False}, "uvicorn.error": {"level": "INFO"}, "uvicorn.access": {"handlers": ["access"], "level": "INFO", "propagate": False}, + "watchfiles.main": {"level": "ERROR"}, # filter watchfiles noise }, }