Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
scrungus committed Jul 4, 2024
1 parent 0cc4d46 commit 5c629fb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion etc/coral-credits/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
# OTHER SETTINGS
}

WSGI_APPLICATION = "coral_credits.wsgi.application"
WSGI_APPLICATION = "coral_credits.wsgi.application"
65 changes: 34 additions & 31 deletions etc/coral-credits/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
https://docs.djangoproject.com/en/5.0/ref/settings/
"""

import logging
import os

from django.core.management.utils import get_random_secret_key
Expand All @@ -16,54 +17,56 @@
DEBUG = False

# In a Docker container, ALLOWED_HOSTS is always '*' - let the proxy worry about hosts
ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ["*"]

# Make sure Django interprets the script name correctly if set
if 'SCRIPT_NAME' in os.environ:
FORCE_SCRIPT_NAME = os.environ['SCRIPT_NAME']
if "SCRIPT_NAME" in os.environ:
FORCE_SCRIPT_NAME = os.environ["SCRIPT_NAME"]

# Set a default random secret key
# This can be overridden by files included later if desired
SECRET_KEY = get_random_secret_key()

# All logging should go to stdout/stderr to be collected
import logging
LOG_FORMAT = '[%(levelname)s] [%(asctime)s] [%(name)s:%(lineno)s] [%(threadName)s] %(message)s'

LOG_FORMAT = (
"[%(levelname)s] [%(asctime)s] [%(name)s:%(lineno)s] [%(threadName)s] %(message)s"
)
LOGGING = {
'version' : 1,
'disable_existing_loggers' : False,
'formatters' : {
'default' : {
'format' : LOG_FORMAT,
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"default": {
"format": LOG_FORMAT,
},
},
'filters' : {
"filters": {
# Logging filter that only accepts records with a level < WARNING
# This allows us to log level >= WARNING to stderr and level < WARNING to stdout
'less_than_warning' : {
'()': 'django.utils.log.CallbackFilter',
'callback': lambda record: record.levelno < logging.WARNING,
"less_than_warning": {
"()": "django.utils.log.CallbackFilter",
"callback": lambda record: record.levelno < logging.WARNING,
},
},
'handlers' : {
'stdout' : {
'class' : 'logging.StreamHandler',
'stream' : 'ext://sys.stdout',
'formatter' : 'default',
'filters': ['less_than_warning'],
"handlers": {
"stdout": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
"formatter": "default",
"filters": ["less_than_warning"],
},
'stderr' : {
'class' : 'logging.StreamHandler',
'stream' : 'ext://sys.stderr',
'formatter' : 'default',
'level' : 'WARNING',
"stderr": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stderr",
"formatter": "default",
"level": "WARNING",
},
},
'loggers' : {
'' : {
'handlers' : ['stdout', 'stderr'],
'level' : 'DEBUG' if DEBUG else 'INFO',
'propogate' : True,
"loggers": {
"": {
"handlers": ["stdout", "stderr"],
"level": "DEBUG" if DEBUG else "INFO",
"propogate": True,
},
},
}
Expand Down Expand Up @@ -122,4 +125,4 @@
# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
3 changes: 1 addition & 2 deletions etc/coral-credits/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Includes settings files from a sibling directory called settings.d.
"""

import os
from pathlib import Path

from flexi_settings import include, include_dir
Expand All @@ -17,4 +16,4 @@
# Then include the application-level settings
include(base_dir / "app.py")
# Then include the runtime settings from a directory
include_dir(base_dir / "settings.d")
include_dir(base_dir / "settings.d")

0 comments on commit 5c629fb

Please sign in to comment.