from .base import *

DEBUG = False

# Configured with docker secrets
SECRET_KEY = open("/run/secrets/datasketch_key", "r").read().strip()
PG_PASSWD = open("/run/secrets/pg_passwd_datasketch", "r").read().strip()

# SECURITY WARNING: define the correct hosts in production!
ALLOWED_HOSTS = [".datasketch.io", ".androiddrew.com", "localhost", "127.0.0.1"]

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "datasketch",
        "USER": "datasketch",
        "PASSWORD": PG_PASSWD,
        "HOST": os.environ.get("DB_HOST") if os.environ.get("DB_HOST") else "127.0.0.1",
        "PORT": os.environ.get("DB_PORT") if os.environ.get("DB_PORT") else "5432",
    }
}

STATIC_ROOT = os.path.join(BASE_DIR, "staticout")
STATIC_URL = "/static/"

MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"

LOGGING = {
    "version": 1,
    "disable_exisiing_loggers": False,
    "handlers": {"console": {"class": "logging.StreamHandler"}},
    "loggers": {
        "django.request": {
            "handlers": ["console"],
            "level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
        }
    },
}


try:
    from .local import *
except ImportError:
    pass
