diff --git a/apps/authentication/Dockerfile b/apps/authentication/Dockerfile index 1439b4b..0b97a04 100644 --- a/apps/authentication/Dockerfile +++ b/apps/authentication/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10-slim-bullseye +FROM python:3.12-slim # docker settings ARG CONTAINER_APP_ROOT="/app" diff --git a/apps/central_storage/Dockerfile b/apps/central_storage/Dockerfile index fbf07c1..f8f2596 100644 --- a/apps/central_storage/Dockerfile +++ b/apps/central_storage/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10-slim-buster +FROM python:3.12-slim # docker settings ARG CONTAINER_APP_ROOT="/app" diff --git a/apps/central_storage/backend/application/document_hub.py b/apps/central_storage/backend/application/document_hub.py index d50ac39..c2e746e 100644 --- a/apps/central_storage/backend/application/document_hub.py +++ b/apps/central_storage/backend/application/document_hub.py @@ -1,6 +1,7 @@ from backend.business.document_manager import ( DocumentManager, ) +from common.log.module_logger import ModuleLogger class DocumentHub: @@ -8,15 +9,22 @@ class DocumentHub: self, ): self.document_manager = DocumentManager() + self.module_logger = ModuleLogger(sender_id="DocumentHub") return async def retrieve_document_info(self, document_id: str): - return await self.document_manager.retrieve_document_info(document_id) + await self.module_logger.log_info(f"Retrieving document info for ID: {document_id}") + result = await self.document_manager.retrieve_document_info(document_id) + await self.module_logger.log_info(f"Document info retrieved successfully for ID: {document_id}") + return result async def read_document_file_as_http_media_data(self, document_id: str): - return await self.document_manager.read_document_file_as_http_media_data( + await self.module_logger.log_info(f"Reading document as HTTP media for ID: {document_id}") + result = await self.document_manager.read_document_file_as_http_media_data( document_id ) + await self.module_logger.log_info(f"Document media data read successfully for ID: {document_id}") + return result async def upload_document( self, associated_with: str, file_name: str, file_data: bytes @@ -26,11 +34,16 @@ class DocumentHub: file_name: the name of the file file (bytes): the file to be uploaded """ - return await self.document_manager.upload_file( + await self.module_logger.log_info(f"Uploading document {file_name} for user {associated_with}") + result = await self.document_manager.upload_file( associated_with, file_name, file_data ) + await self.module_logger.log_info(f"Document upload completed for {file_name}, result: {result}") + return result async def delete_documents(self, document_ids: list): + await self.module_logger.log_info(f"Deleting documents: {document_ids}") for document_id in document_ids: await self.document_manager.delete_document(document_id) + await self.module_logger.log_info(f"Documents deleted successfully: {document_ids}") return diff --git a/apps/central_storage/backend/business/document_manager.py b/apps/central_storage/backend/business/document_manager.py index 08b212e..7e46819 100644 --- a/apps/central_storage/backend/business/document_manager.py +++ b/apps/central_storage/backend/business/document_manager.py @@ -1,10 +1,12 @@ from backend.services.document_service import DocumentService from backend.models.models import MediaType, DataFormat +from common.log.module_logger import ModuleLogger class DocumentManager: def __init__(self) -> None: self.document_service = DocumentService() + self.module_logger = ModuleLogger(sender_id="DocumentManager") async def retrieve_document_info(self, document_id: str): await self.document_service.load_document(document_id=document_id) diff --git a/apps/central_storage/webapi/bootstrap/application.py b/apps/central_storage/webapi/bootstrap/application.py index aae7a72..575d41d 100644 --- a/apps/central_storage/webapi/bootstrap/application.py +++ b/apps/central_storage/webapi/bootstrap/application.py @@ -12,6 +12,7 @@ from webapi.providers import probes from webapi.providers import metrics from .freeleaps_app import FreeleapsApp from common.config.app_settings import app_settings +from common.log.module_logger import ModuleLogger def create_app() -> FastAPI: @@ -20,6 +21,10 @@ def create_app() -> FastAPI: app = FreeleapsApp() register_logger() + + # Create application logger for startup logging + app_logger = ModuleLogger(sender_id="ApplicationBootstrap") + register(app, exception_handler) register(app, database) register(app, router) @@ -37,6 +42,14 @@ def create_app() -> FastAPI: if app_settings.METRICS_ENABLED: register(app, metrics) + # Log application startup completion + import asyncio + async def log_startup(): + await app_logger.log_info("Central Storage application initialized successfully") + + # Run the async logging + asyncio.create_task(log_startup()) + return app