adding log files for the server w/ burnettk

This commit is contained in:
jasquat 2022-07-07 10:19:52 -04:00
parent 034e4d4471
commit ac40540c57
6 changed files with 4698 additions and 3959 deletions

View File

@ -163,6 +163,13 @@ jobs:
name: docs name: docs
path: docs/_build path: docs/_build
- name: Upload logs
if: failure() && matrix.session == 'tests'
uses: "actions/upload-artifact@v3.0.0"
with:
name: logs
path: "./log/*.log"
coverage: coverage:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: tests needs: tests

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -39,6 +39,7 @@ services:
- "7000:7000" - "7000:7000"
volumes: volumes:
- ${BPMN_SPEC_ABSOLUTE_DIR:-./../sample-process-models}:/app/process_models - ${BPMN_SPEC_ABSOLUTE_DIR:-./../sample-process-models}:/app/process_models
- ./log:/app/log
healthcheck: healthcheck:
test: curl localhost:7000/v1.0/status --fail test: curl localhost:7000/v1.0/status --fail

View File

@ -1,4 +1,5 @@
"""__init__.""" """__init__."""
import logging
import os import os
from typing import Any from typing import Any
@ -72,5 +73,6 @@ def create_app() -> flask.app.Flask:
app.config["MAIL_APP"] = mail app.config["MAIL_APP"] = mail
app.json_encoder = MyJSONEncoder app.json_encoder = MyJSONEncoder
logging.basicConfig(filename="filename.log", level=logging.DEBUG)
return app # type: ignore return app # type: ignore

View File

@ -19,6 +19,24 @@ def setup_logger_for_sql_statements(app: Flask) -> None:
db_logger.setLevel(db_logger_log_level) db_logger.setLevel(db_logger_log_level)
# formats:
# from: https://www.askpython.com/python-modules/flask/flask-logging
# %(asctime)s— The timestamp as a string.
# %(levelname)s—The logging level as a string.
# %(name)s—The logger name as a string.
# %(threadname)s—The thread name as a string.
# %(message)s—The log message.
def setup_logger(app: Flask) -> None:
"""Setup_logger."""
server_log_file_name = f"log/server_{app.env}.log"
formatting = "%(asctime)s - %(levelname)s - %(message)s"
logging.basicConfig(
filename=server_log_file_name, level=logging.DEBUG, format=formatting
)
setup_logger_for_sql_statements(app)
def setup_database_uri(app: Flask) -> None: def setup_database_uri(app: Flask) -> None:
"""Setup_database_uri.""" """Setup_database_uri."""
if os.environ.get("SPIFFWORKFLOW_BACKEND_DATABASE_URI") is None: if os.environ.get("SPIFFWORKFLOW_BACKEND_DATABASE_URI") is None:
@ -56,7 +74,7 @@ def setup_config(app: Flask) -> None:
app.config.from_object("spiffworkflow_backend.config.default") app.config.from_object("spiffworkflow_backend.config.default")
setup_database_uri(app) setup_database_uri(app)
setup_logger_for_sql_statements(app) setup_logger(app)
env_config_module = "spiffworkflow_backend.config." + app.env env_config_module = "spiffworkflow_backend.config." + app.env
try: try: