allow passing in the log level into the app w/ burnettk
This commit is contained in:
parent
92d204e696
commit
71c803aa93
|
@ -38,7 +38,9 @@ if [[ "${SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA:-}" == "true" ]]; then
|
|||
workers=1
|
||||
fi
|
||||
|
||||
SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
|
||||
if [[ "${SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP:-}" != "false" ]]; then
|
||||
SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
|
||||
fi
|
||||
|
||||
export IS_GUNICORN="true"
|
||||
export PROCESS_WAITING_MESSAGES="true"
|
||||
|
|
|
@ -32,6 +32,9 @@ else
|
|||
export PROCESS_WAITING_MESSAGES="true"
|
||||
fi
|
||||
export FLASK_DEBUG=1
|
||||
SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
|
||||
|
||||
if [[ "${SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP:-}" != "false" ]]; then
|
||||
SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
|
||||
fi
|
||||
FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000
|
||||
fi
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Grabs tickets from csv and makes process instances."""
|
||||
import os
|
||||
|
||||
from spiffworkflow_backend import get_hacked_up_app_for_script
|
||||
from spiffworkflow_backend.services.data_setup_service import DataSetupService
|
||||
|
||||
|
@ -11,7 +12,11 @@ def main() -> None:
|
|||
failing_process_models = DataSetupService.save_all_process_models()
|
||||
for bpmn_errors in failing_process_models:
|
||||
print(bpmn_errors)
|
||||
if os.environ.get('SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS') != "false" and len(failing_process_models) > 0:
|
||||
if (
|
||||
os.environ.get("SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS")
|
||||
!= "false"
|
||||
and len(failing_process_models) > 0
|
||||
):
|
||||
exit(1)
|
||||
|
||||
|
||||
|
|
|
@ -49,3 +49,7 @@ SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
|
|||
# Sentry Configuration
|
||||
SENTRY_DSN = environ.get("SENTRY_DSN", default="")
|
||||
SENTRY_SAMPLE_RATE = environ.get("SENTRY_SAMPLE_RATE", default="1.0")
|
||||
|
||||
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
||||
"SPIFFWORKFLOW_BACKEND_LOG_LEVEL", default="info"
|
||||
)
|
||||
|
|
|
@ -4,3 +4,7 @@ from os import environ
|
|||
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
|
||||
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="staging.yml"
|
||||
)
|
||||
|
||||
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
||||
"SPIFFWORKFLOW_BACKEND_LOG_LEVEL", default="debug"
|
||||
)
|
||||
|
|
|
@ -34,7 +34,9 @@ class DataSetupService:
|
|||
]
|
||||
if process_model.primary_file_name in bad_files:
|
||||
continue
|
||||
# print(f"primary_file_name: {process_model.primary_file_name}")
|
||||
current_app.logger.debug(
|
||||
f"primary_file_name: {process_model.primary_file_name}"
|
||||
)
|
||||
try:
|
||||
SpecFileService.update_file(
|
||||
process_model,
|
||||
|
|
|
@ -23,7 +23,14 @@ from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
|
|||
# full message list:
|
||||
# {'name': 'gunicorn.error', 'msg': 'GET /admin/token', 'args': (), 'levelname': 'DEBUG', 'levelno': 10, 'pathname': '~/.cache/pypoetry/virtualenvs/spiffworkflow-backend-R_hdWfN1-py3.10/lib/python3.10/site-packages/gunicorn/glogging.py', 'filename': 'glogging.py', 'module': 'glogging', 'exc_info': None, 'exc_text': None, 'stack_info': None, 'lineno': 267, 'funcName': 'debug', 'created': 1657307111.4513023, 'msecs': 451.30228996276855, 'relativeCreated': 1730.785846710205, 'thread': 139945864087360, 'threadName': 'MainThread', 'processName': 'MainProcess', 'process': 2109561, 'message': 'GET /admin/token', 'asctime': '2022-07-08T15:05:11.451Z'}
|
||||
|
||||
|
||||
class InvalidLogLevelError(Exception):
|
||||
"""InvalidLogLevelError."""
|
||||
|
||||
|
||||
# originally from https://stackoverflow.com/a/70223539/6090676
|
||||
|
||||
|
||||
class JsonFormatter(logging.Formatter):
|
||||
"""Formatter that outputs JSON strings after parsing the LogRecord.
|
||||
|
||||
|
@ -108,8 +115,16 @@ class SpiffFilter(logging.Filter):
|
|||
|
||||
def setup_logger(app: Flask) -> None:
|
||||
"""Setup_logger."""
|
||||
log_level = logging.DEBUG
|
||||
spiff_log_level = logging.DEBUG
|
||||
upper_log_level_string = app.config["SPIFFWORKFLOW_BACKEND_LOG_LEVEL"].upper()
|
||||
log_levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
|
||||
|
||||
if upper_log_level_string not in log_levels:
|
||||
raise InvalidLogLevelError(
|
||||
f"Log level given is invalid: '{upper_log_level_string}'. Valid options are {log_levels}"
|
||||
)
|
||||
|
||||
log_level = getattr(logging, upper_log_level_string)
|
||||
spiff_log_level = getattr(logging, upper_log_level_string)
|
||||
log_formatter = logging.Formatter(
|
||||
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
)
|
||||
|
|
4
wsgi.py
4
wsgi.py
|
@ -14,7 +14,3 @@ app = create_app()
|
|||
if os.environ.get("SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA") == "true":
|
||||
with app.app_context():
|
||||
load_acceptance_test_fixtures()
|
||||
|
||||
if os.environ.get("SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP") != "false":
|
||||
with app.app_context():
|
||||
DataSetupService.run_setup()
|
||||
|
|
Loading…
Reference in New Issue