# -*- coding: utf-8 -*-
'''
Production Configuration
'''
from .common import *  # noqa

MIDDLEWARE_CLASSES = (
    # Make sure djangosecure.middleware.SecurityMiddleware is listed first
    'django.middleware.security.SecurityMiddleware',
) + MIDDLEWARE_CLASSES

# get an exception when starting, if they are not defined
SECRET_KEY = env.str("DJANGO_SECRET_KEY")
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS")
DATABASES['default'] = env.db("DJANGO_DATABASE_URL")

INSTALLED_APPS += (
    'gunicorn',
    # sentry
    'raven.contrib.django.raven_compat',
)

# STORAGE CONFIGURATION
# ------------------------------------------------------------------------------
# Uploaded Media Files
# ------------------------
# See: http://django-storages.readthedocs.org/en/latest/index.html
# we are prepared for this but aren't using it right now
INSTALLED_APPS += (
    # 'storages',
)

# Static Assets
# ------------------------
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

RAVEN_CONFIG = {
    'dsn': env.str('SENTRY_DSN'),
    # If you are using git, you can also automatically configure the
    # release based on the git info.
    'release': env.str('SENTRY_RELEASE'),
}

@@ -993,45 +993,1358 @@
 e'%0A%0A
-RAVEN_CONFIG = %7B%0A    'dsn': env.str('
+# SENTRY%0ASENTRY_DSN = env.str('SENTRY_DSN', default=None)%0A%0Aif SENTRY_DSN:%0A    LOGGING = %7B%0A        'version': 1,%0A        'disable_existing_loggers': True,%0A        'root': %7B%0A            'level': 'WARNING',%0A            'handlers': %5B'sentry'%5D,%0A        %7D,%0A        'formatters': %7B%0A            'verbose': %7B%0A                'format': '%25(levelname)s %25(asctime)s %25(module)s '%0A                          '%25(process)d %25(thread)d %25(message)s'%0A            %7D,%0A        %7D,%0A        'handlers': %7B%0A            'sentry': %7B%0A                'level': 'ERROR',%0A                'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler'%0A            %7D,%0A            'console': %7B%0A                'level': 'DEBUG',%0A                'class': 'logging.StreamHandler',%0A                'formatter': 'verbose'%0A            %7D%0A        %7D,%0A        'loggers': %7B%0A            'django.db.backends': %7B%0A                'level': 'ERROR',%0A                'handlers': %5B'console'%5D,%0A                'propagate': False,%0A            %7D,%0A            'raven': %7B%0A                'level': 'DEBUG',%0A                'handlers': %5B'console'%5D,%0A                'propagate': False,%0A            %7D,%0A            'sentry.errors': %7B%0A                'level': 'DEBUG',%0A                'handlers': %5B'console'%5D,%0A                'propagate': False,%0A            %7D,%0A        %7D,%0A    %7D%0A%0A    RAVEN_CONFIG = %7B%0A        'dsn': 
 SENT
@@ -2349,20 +2349,22 @@
 NTRY_DSN
-')
 ,%0A
+    
     # If
@@ -2428,16 +2428,20 @@
 the%0A    
+   
+ 
 # releas
@@ -2465,16 +2465,20 @@
 t info.%0A
+    
     'rel
@@ -2512,9 +2512,25 @@
 ASE'
-),%0A
+, default=''),%0A    
 %7D%0A

configure logging correctly for sentry