Skip to content

Commit

Permalink
Fixed logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ysavary committed Aug 6, 2022
1 parent ca8b2a3 commit f6d706c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 67 deletions.
72 changes: 38 additions & 34 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ psycopg2 = "2.9.3"
pymongo = "3.12.2"
pyjwt = "2.4.0"
redis = "4.3.3"
sentry-sdk = "1.6.0"
sentry-sdk = "1.9.2"
whitenoise = "5.3.0"

[tool.poetry.dev-dependencies]
Expand Down
54 changes: 22 additions & 32 deletions winds_mobi_admin/settings.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
"""
Django settings for winds_mobi_admin project.
Generated by 'django-admin startproject' using Django 2.2.1.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

import dj_database_url
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get("SECRET_KEY", "dev")
JWT_ALGORITHM = "HS256"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get("DEBUG", "True").lower() not in ("false", "no", "0")

ALLOWED_HOSTS = [s for s in os.environ.get("ALLOWED_HOSTS", "").split(",") if s]
# https://docs.djangoproject.com/en/2.2/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")


Expand Down Expand Up @@ -83,19 +66,14 @@
WSGI_APPLICATION = "winds_mobi_admin.wsgi.application"


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
"default": dj_database_url.parse(os.environ.get("DB_URL", "postgres://postgres:postgres@localhost:5432/winds"))
}
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

REDIS_URL = os.environ.get("REDIS_URL", None)
MONGODB_URL = os.environ.get("MONGODB_URL", None)

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -114,8 +92,6 @@


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = "en-us"
TIME_ZONE = "Europe/Zurich"

Expand All @@ -125,22 +101,36 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_ROOT = os.environ.get("STATIC_ROOT") or os.path.join(BASE_DIR, "static/")
STATIC_URL = os.environ.get("STATIC_URL") or "/static/"

LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"default": {"format": "%(asctime)s %(levelname)s %(name)s | %(message)s", "datefmt": "%Y-%m-%dT%H:%M:%S%z"},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
"formatter": "default",
}
},
"root": {"handlers": ["console"], "level": "INFO"},
"loggers": {"django": {"level": "INFO"}},
}

# winds.mobi settings

CORS_ORIGIN_ALLOW_ALL = True

SENTRY_DSN = os.environ.get("SENTRY_DSN")
ENVIRONMENT = os.environ.get("ENVIRONMENT") or "development"
ENVIRONMENT = os.environ.get("ENVIRONMENT", "development")

GOOGLE_CLIENT_SECRET = os.environ.get("GOOGLE_CLIENT_SECRET")
FACEBOOK_REDIRECT_URI = os.environ.get("FACEBOOK_REDIRECT_URI")
FACEBOOK_CLIENT_ID = os.environ.get("FACEBOOK_CLIENT_ID")
FACEBOOK_CLIENT_SECRET = os.environ.get("FACEBOOK_CLIENT_SECRET")

sentry_sdk.init(dsn=SENTRY_DSN, environment=ENVIRONMENT, integrations=[DjangoIntegration()])

sentry_sdk.init(SENTRY_DSN, environment=ENVIRONMENT, integrations=[LoggingIntegration(), DjangoIntegration()])

0 comments on commit f6d706c

Please sign in to comment.