From 6ebefc9f17c6b592d7426ad4ff29aa2d29a495b8 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 6 Sep 2020 15:52:48 +0200 Subject: [PATCH] root: fix some logs not being json --- docker/gunicorn.conf.py | 12 ++++++++++++ passbook/root/settings.py | 22 +++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/docker/gunicorn.conf.py b/docker/gunicorn.conf.py index 742240854..43c35c14d 100644 --- a/docker/gunicorn.conf.py +++ b/docker/gunicorn.conf.py @@ -35,4 +35,16 @@ logconfig_dict = { }, "console": {"class": "logging.StreamHandler", "formatter": "json_formatter"}, }, + "loggers": { + "uvicorn": { + "handlers": ["console"], + "level": "WARNING", + "propagate": False, + }, + "gunicorn": { + "handlers": ["console"], + "level": "INFO", + "propagate": False, + }, + }, } diff --git a/passbook/root/settings.py b/passbook/root/settings.py index 43006443e..c74bd475c 100644 --- a/passbook/root/settings.py +++ b/passbook/root/settings.py @@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/2.1/ref/settings/ import importlib import os import sys +from json import dumps import structlog from celery.schedules import crontab @@ -270,8 +271,15 @@ if CONFIG.y("postgresql.backup"): AWS_STORAGE_BUCKET_NAME = CONFIG.y("postgresql.backup.bucket") AWS_S3_ENDPOINT_URL = CONFIG.y("postgresql.backup.host") AWS_DEFAULT_ACL = None - LOGGER.info( - "Database backup is configured", host=CONFIG.y("postgresql.backup.host") + print( + dumps( + { + "event": "Database backup is configured.", + "level": "info", + "logger": __name__, + "host": CONFIG.y("postgresql.backup.host"), + } + ) ) # Add automatic task to backup CELERY_BEAT_SCHEDULE["db_backup"] = { @@ -282,7 +290,15 @@ if CONFIG.y("postgresql.backup"): # Sentry integration _ERROR_REPORTING = CONFIG.y_bool("error_reporting.enabled", False) if not DEBUG and _ERROR_REPORTING: - LOGGER.info("Error reporting is enabled.") + print( + dumps( + { + "event": "Error reporting is enabled.", + "level": "info", + "logger": __name__, + } + ) + ) sentry_init( dsn="https://33cdbcb23f8b436dbe0ee06847410b67@sentry.beryju.org/3", integrations=[