Skip to content

Commit

Permalink
Merge pull request #119 from uktrade/feat/asim-logging
Browse files Browse the repository at this point in the history
feat/asim logging
  • Loading branch information
larry6point6 authored Dec 3, 2024
2 parents 4d69d8c + 04704ed commit ef57f95
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ DJANGO_SETTINGS_MODULE=redbox_app.settings
DEBUG=True
DJANGO_SECRET_KEY=1n53cur3K3y
DJANGO_LOG_LEVEL=DEBUG
# If you want to disable asim_log formatting comment out below line
DJANGO_LOG_FORMAT=asim_formatter
ENVIRONMENT=LOCAL
POSTGRES_USER=redbox-core
POSTGRES_DB=redbox-core
Expand Down
19 changes: 17 additions & 2 deletions django_app/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions django_app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ scikit-learn = "^1.5.2"
django-staff-sso-client = "^4.3.0"
dj-database-url = "^2.3.0"
dbt-copilot-python = "^0.2.2"
django-log-formatter-asim = "^0.0.6"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.2"
Expand Down
17 changes: 12 additions & 5 deletions django_app/redbox_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sentry_sdk
from dbt_copilot_python.database import database_from_env
from django.urls import reverse_lazy
from django_log_formatter_asim import ASIMFormatter
from dotenv import load_dotenv
from import_export.formats.base_formats import CSV
from sentry_sdk.integrations.django import DjangoIntegration
Expand Down Expand Up @@ -279,7 +280,7 @@
ALLOWED_HOSTS = ENVIRONMENT.hosts
else:
LOCALHOST = socket.gethostbyname(socket.gethostname())
ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ["*"]

if not ENVIRONMENT.is_local:

Expand All @@ -306,7 +307,7 @@ def filter_transactions(event):
)
SENTRY_REPORT_TO_ENDPOINT = URL(env.str("SENTRY_REPORT_TO_ENDPOINT", "")) or None

database_credentials = os.getenv('DATABASE_CREDENTIALS')
database_credentials = os.getenv("DATABASE_CREDENTIALS")
if database_credentials:
DATABASES = database_from_env("DATABASE_CREDENTIALS")
DATABASES["default"]["ENGINE"] = "django.db.backends.postgresql"
Expand All @@ -324,16 +325,22 @@ def filter_transactions(event):
}

LOG_LEVEL = env.str("DJANGO_LOG_LEVEL", "WARNING")
LOG_FORMAT = env.str("DJANGO_LOG_FORMAT", "verbose")
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {"verbose": {"format": "%(asctime)s %(levelname)s %(module)s: %(message)s"}},
"formatters": {
"verbose": {"format": "%(asctime)s %(levelname)s %(module)s: %(message)s"},
"asim_formatter": {
"()": ASIMFormatter,
},
},
"handlers": {
"console": {
"level": LOG_LEVEL,
"class": "logging.StreamHandler",
"formatter": "verbose",
},
"formatter": LOG_FORMAT,
}
},
"root": {"handlers": ["console"], "level": LOG_LEVEL},
"loggers": {
Expand Down

0 comments on commit ef57f95

Please sign in to comment.