diff --git a/src/mass/adapters/inbound/event_sub.py b/src/mass/adapters/inbound/event_sub.py index fbe5d82..bd1e244 100644 --- a/src/mass/adapters/inbound/event_sub.py +++ b/src/mass/adapters/inbound/event_sub.py @@ -36,6 +36,9 @@ ) SCHEMA_VALIDATION_ERROR_LOG_MSG = "Failed to validate event schema for '%s'" +EVENT_RECEIVED_LOG_MESSAGE = "Received event of type '%s'" +UNEXPECTED_EVENT_LOG_MESSAGE = "Received unexpected event of type '%s'" + log = logging.getLogger(__name__) @@ -140,7 +143,10 @@ async def _consume_validated( topic: Ascii, # pylint: disable=unused-argument ) -> None: """Consumes an event""" + log.info(EVENT_RECEIVED_LOG_MESSAGE, type) if type_ == self._config.resource_deletion_event_type: await self._handle_deletion(payload=payload) elif type_ == self._config.resource_upsertion_event_type: await self._handle_upsertion(payload=payload) + else: + log.warning(UNEXPECTED_EVENT_LOG_MESSAGE, type) diff --git a/src/mass/adapters/inbound/fastapi_/routes.py b/src/mass/adapters/inbound/fastapi_/routes.py index bfcad29..98d296f 100644 --- a/src/mass/adapters/inbound/fastapi_/routes.py +++ b/src/mass/adapters/inbound/fastapi_/routes.py @@ -14,7 +14,9 @@ # limitations under the License. # -"""Contains API endpoints""" +"""API endpoints""" + +import logging from typing import Union from dependency_injector.wiring import Provide, inject @@ -27,6 +29,8 @@ from mass.core import models from mass.ports.inbound.query_handler import QueryHandlerPort +log = logging.getLogger(__name__) + router = APIRouter() @@ -83,10 +87,11 @@ async def search( except query_handler.ClassNotConfiguredError as err: raise HTTPException( status_code=422, - detail="The specified class name is invalid. See " - + "/rpc/search-options for a list of valid class names.", + detail="The specified class name is invalid." + + " See /rpc/search-options for a list of valid class names.", ) from err except (query_handler.SearchError, query_handler.ValidationError) as err: + log.error("Search operation error: %s", err) raise HTTPException( status_code=500, detail="An error occurred during search operation" ) from err