Skip to content

Commit

Permalink
Add some more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Oct 20, 2023
1 parent bbe5100 commit 48610fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/mass/adapters/inbound/event_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down Expand Up @@ -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)
11 changes: 8 additions & 3 deletions src/mass/adapters/inbound/fastapi_/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,6 +29,8 @@
from mass.core import models
from mass.ports.inbound.query_handler import QueryHandlerPort

log = logging.getLogger(__name__)

router = APIRouter()


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 48610fb

Please sign in to comment.