mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
add logic to conditionally set log level
This commit is contained in:
parent
a3346d666c
commit
db97a3f715
24 changed files with 67 additions and 7 deletions
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-ab.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-ab.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-ad.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-ad.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-ag.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-ag.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-backup.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-backup.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-bob.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-bob.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-cb.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-cb.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-development.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-development.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-dk.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-dk.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-el.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-el.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-es.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-es.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-gd.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-gd.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-hotgov.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-hotgov.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-ko.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-ko.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-ky.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-ky.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-litterbox.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-litterbox.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-meoward.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-meoward.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-ms.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-ms.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: DEBUG
|
DJANGO_LOG_LEVEL: DEBUG
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-nl.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-nl.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-rb.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-rb.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-rh.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-rh.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-rjm.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-rjm.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: console
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://manage.get.gov
|
DJANGO_BASE_URL: https://manage.get.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: json
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Which OIDC provider to use
|
# Which OIDC provider to use
|
||||||
|
|
|
@ -21,6 +21,8 @@ applications:
|
||||||
DJANGO_BASE_URL: https://getgov-staging.app.cloud.gov
|
DJANGO_BASE_URL: https://getgov-staging.app.cloud.gov
|
||||||
# Tell Django how much stuff to log
|
# Tell Django how much stuff to log
|
||||||
DJANGO_LOG_LEVEL: INFO
|
DJANGO_LOG_LEVEL: INFO
|
||||||
|
# tell django what log format to use: console or json. See settings.py for more details.
|
||||||
|
DJANGO_LOG_FORMAT: json
|
||||||
# default public site location
|
# default public site location
|
||||||
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
GETGOV_PUBLIC_SITE_URL: https://get.gov
|
||||||
# Flag to disable/enable features in prod environments
|
# Flag to disable/enable features in prod environments
|
||||||
|
|
|
@ -60,6 +60,7 @@ env_db_url = env.dj_db_url("DATABASE_URL")
|
||||||
env_debug = env.bool("DJANGO_DEBUG", default=False)
|
env_debug = env.bool("DJANGO_DEBUG", default=False)
|
||||||
env_is_production = env.bool("IS_PRODUCTION", default=False)
|
env_is_production = env.bool("IS_PRODUCTION", default=False)
|
||||||
env_log_level = env.str("DJANGO_LOG_LEVEL", "DEBUG")
|
env_log_level = env.str("DJANGO_LOG_LEVEL", "DEBUG")
|
||||||
|
env_log_format = env.str("DJANGO_LOG_FORMAT", "console")
|
||||||
env_base_url: str = env.str("DJANGO_BASE_URL")
|
env_base_url: str = env.str("DJANGO_BASE_URL")
|
||||||
env_getgov_public_site_url = env.str("GETGOV_PUBLIC_SITE_URL", "")
|
env_getgov_public_site_url = env.str("GETGOV_PUBLIC_SITE_URL", "")
|
||||||
env_oidc_active_provider = env.str("OIDC_ACTIVE_PROVIDER", "identity sandbox")
|
env_oidc_active_provider = env.str("OIDC_ACTIVE_PROVIDER", "identity sandbox")
|
||||||
|
@ -485,6 +486,24 @@ class JsonServerFormatter(ServerFormatter):
|
||||||
|
|
||||||
log_entry = {"server_time": record.server_time, "level": record.levelname, "message": formatted_record}
|
log_entry = {"server_time": record.server_time, "level": record.levelname, "message": formatted_record}
|
||||||
return json.dumps(log_entry)
|
return json.dumps(log_entry)
|
||||||
|
|
||||||
|
# Define console handler outside LOGGING so we can conditionally enablefilters
|
||||||
|
console_handler = {
|
||||||
|
"level": env_log_level,
|
||||||
|
"class": "logging.StreamHandler",
|
||||||
|
"formatter": "verbose",
|
||||||
|
}
|
||||||
|
|
||||||
|
if env_log_format == "json":
|
||||||
|
# in production we need everything to be logged as json so that log levels are parsed correctly
|
||||||
|
django_handlers = ["json"]
|
||||||
|
else:
|
||||||
|
# for non-production environments, send non-error messages to console handler
|
||||||
|
# we do this because json clutters logs when debugging
|
||||||
|
django_handlers = ["console", "json"]
|
||||||
|
# Only add below_error filter for non-production environments
|
||||||
|
console_handler["filters"] = ["below_error"]
|
||||||
|
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
"version": 1,
|
"version": 1,
|
||||||
|
@ -515,12 +534,7 @@ LOGGING = {
|
||||||
# define where log messages will be sent;
|
# define where log messages will be sent;
|
||||||
# each logger can have one or more handlers
|
# each logger can have one or more handlers
|
||||||
"handlers": {
|
"handlers": {
|
||||||
"console": {
|
"console": console_handler,
|
||||||
"level": env_log_level,
|
|
||||||
"class": "logging.StreamHandler",
|
|
||||||
"formatter": "verbose",
|
|
||||||
"filters": ["below_error"],
|
|
||||||
},
|
|
||||||
"django.server": {
|
"django.server": {
|
||||||
"level": "INFO",
|
"level": "INFO",
|
||||||
"class": "logging.StreamHandler",
|
"class": "logging.StreamHandler",
|
||||||
|
@ -546,7 +560,7 @@ LOGGING = {
|
||||||
"loggers": {
|
"loggers": {
|
||||||
# Django's generic logger
|
# Django's generic logger
|
||||||
"django": {
|
"django": {
|
||||||
"handlers": ["console", "json"],
|
"handlers": django_handlers,
|
||||||
"level": "INFO",
|
"level": "INFO",
|
||||||
"propagate": False,
|
"propagate": False,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue