log db validation error to see what postgres is doing

This commit is contained in:
jasquat 2022-09-23 10:33:12 -04:00
parent bc9d820e1d
commit 115e126873
2 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,7 @@
"""Logging_service."""
import json
import logging
import re
from typing import Any
from typing import Optional
@ -113,6 +114,8 @@ def setup_logger(app: Flask) -> None:
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
app.logger.debug("Printing log to create app logger")
# the json formatter is nice for real environments but makes
# debugging locally a little more difficult
if app.env != "development":
@ -140,7 +143,8 @@ def setup_logger(app: Flask) -> None:
# make all loggers act the same
for name in logging.root.manager.loggerDict:
if "spiff" not in name:
# use a regex so spiffworkflow_backend isn't filtered out
if not re.match(r"^spiff\b", name):
the_logger = logging.getLogger(name)
the_logger.setLevel(log_level)
if spiff_logger_filehandler:

View File

@ -1,6 +1,7 @@
"""Secret_service."""
from typing import Optional
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from sqlalchemy.exc import IntegrityError
@ -46,11 +47,14 @@ class SecretService:
try:
db.session.commit()
except Exception as e:
raise ApiError(
ae = ApiError(
code="create_secret_error",
message=f"There was an error creating a secret with key: {key} and value ending with: {value[:-4]}. "
f"Original error is {e}",
) from e
)
# log the error so we can see what postgres is doing
current_app.logger.error(ae)
raise ae from e
return secret_model
@staticmethod