make logs less chatty and support new localopenid convenience arg when booting backend locally

This commit is contained in:
burnettk 2023-05-06 15:17:48 -04:00
parent 950d07f306
commit b100fdc076
4 changed files with 31 additions and 5 deletions

View File

@ -7,10 +7,15 @@ function error_handler() {
trap 'error_handler ${LINENO} $?' ERR trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail set -o errtrace -o errexit -o nounset -o pipefail
port="${SPIFFWORKFLOW_BACKEND_PORT:-7000}"
arg="${1:-}" arg="${1:-}"
if [[ "$arg" == "acceptance" ]]; then if [[ "$arg" == "acceptance" ]]; then
export SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA=true export SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA=true
export SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME=acceptance_tests.yml export SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME=acceptance_tests.yml
elif [[ "$arg" == "localopenid" ]]; then
export SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL="http://localhost:$port/openid"
export SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME="example.yml"
fi fi
if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then
@ -38,5 +43,5 @@ else
fi fi
# this line blocks # this line blocks
SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER="${SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER}" FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000 SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER="${SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER}" FLASK_APP=src/spiffworkflow_backend poetry run flask run -p "$port"
fi fi

View File

@ -62,13 +62,16 @@ SPIFFWORKFLOW_BACKEND_OPEN_ID_CLIENT_SECRET_KEY = environ.get(
default="JXeQExm0JhQPLumgHtIIqf52bDalHz0q", default="JXeQExm0JhQPLumgHtIIqf52bDalHz0q",
) # noqa: S105 ) # noqa: S105
# Tenant specific fields is a comma separated list of field names that we will convert to list of strings # Tenant specific fields is a comma separated list of field names that we will be converted to list of strings
# and store in the user table's tenant_specific_field_n columns. You can have up to three items in this # and store in the user table's tenant_specific_field_n columns. You can have up to three items in this
# comma-separated list. # comma-separated list.
SPIFFWORKFLOW_BACKEND_OPEN_ID_TENANT_SPECIFIC_FIELDS = environ.get( SPIFFWORKFLOW_BACKEND_OPEN_ID_TENANT_SPECIFIC_FIELDS = environ.get(
"SPIFFWORKFLOW_BACKEND_OPEN_ID_TENANT_SPECIFIC_FIELDS" "SPIFFWORKFLOW_BACKEND_OPEN_ID_TENANT_SPECIFIC_FIELDS"
) )
# loggers to use is a comma separated list of logger prefixes that we will be converted to list of strings
SPIFFWORKFLOW_BACKEND_LOGGERS_TO_USE = environ.get("SPIFFWORKFLOW_BACKEND_LOGGERS_TO_USE")
# cryptography or simple-crypt # cryptography or simple-crypt
SPIFFWORKFLOW_BACKEND_ENCRYPTION_LIB = environ.get( SPIFFWORKFLOW_BACKEND_ENCRYPTION_LIB = environ.get(
# "SPIFFWORKFLOW_BACKEND_ENCRYPTION_LIB", default="cryptography" # "SPIFFWORKFLOW_BACKEND_ENCRYPTION_LIB", default="cryptography"

View File

@ -22,4 +22,3 @@ permissions:
users: [] users: []
allowed_permissions: [create, read, update, delete] allowed_permissions: [create, read, update, delete]
uri: /* uri: /*

View File

@ -129,8 +129,27 @@ def setup_logger(app: Flask) -> None:
spiff_logger_filehandler.setFormatter(log_formatter) spiff_logger_filehandler.setFormatter(log_formatter)
# these loggers have been deemed too verbose to be useful # these loggers have been deemed too verbose to be useful
garbage_loggers_to_exclude = ["connexion", "flask_cors.extension"] garbage_loggers_to_exclude = ["connexion", "flask_cors.extension", "flask_cors.core", "sqlalchemy"]
loggers_to_exclude_from_debug = ["sqlalchemy"]
# if you actually want one of these excluded loggers, there is a config option to turn it on
loggers_to_use = app.config.get("SPIFFWORKFLOW_BACKEND_LOGGERS_TO_USE", [])
if loggers_to_use is None or loggers_to_use == "":
loggers_to_use = []
else:
loggers_to_use = loggers_to_use.split(",")
for logger_to_use in loggers_to_use:
if logger_to_use in garbage_loggers_to_exclude:
garbage_loggers_to_exclude.remove(logger_to_use)
else:
app.logger.warning(
f"Logger '{logger_to_use}' not found in garbage_loggers_to_exclude. You do not need to add it to"
" SPIFFWORKFLOW_BACKEND_LOGGERS_TO_USE."
)
loggers_to_exclude_from_debug = []
if "sqlalchemy" not in garbage_loggers_to_exclude:
loggers_to_exclude_from_debug.append("sqlalchemy")
# make all loggers act the same # make all loggers act the same
for name in logging.root.manager.loggerDict: for name in logging.root.manager.loggerDict: