# preview/staging/production all use the same config with the exception of the
# environment-specific secrets

#
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
#

from .common import *
from .environment_specific_settings import *

DEBUG = False

TEMPLATE_DEBUG = False

CSRF_COOKIE_SECURE = True  # avoid transmitting the CSRF cookie over HTTP

SESSION_COOKIE_SECURE = True  # avoid transmitting the session cookie over HTTP

VARNISH_CACHES = [
    ('http://frontend-app-1', 7999),
    ('http://frontend-app-2', 7999),
]

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'standard': {
            'format': ("[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s]"
                       " %(message)s"),
            'datefmt': "%d-%b-%y %H:%M:%S"
        },
        'logstash_json': {
            '()': 'logstash_formatter.LogstashFormatter',
            'fmt': '{"extra": {"@tags": ["application", "stagecraft"]}}',
        },
    },
    'filters': {
        'additional_fields': {
            '()': 'stagecraft.libs.request_logger.middleware.AdditionalFieldsFilter',  # noqa
        }
    },
    'handlers': {
        'null': {
            'level': 'INFO',
            'class': 'django.utils.log.NullHandler',
        },
        'logfile': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': BASE_DIR + "/log/stagecraft.log",
            'maxBytes': 4 * 1024 * 1024,
            'backupCount': 2,
            'formatter': 'standard',
            'filters': ['additional_fields'],
        },
        'json_log': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': BASE_DIR + "/log/production.json.log",
            'formatter': 'logstash_json',
        },
        'json_audit_log': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': BASE_DIR + "/log/audit/stagecraft.json.log",
            'maxBytes': 4 * 1024 * 1024,
            'backupCount': 2,
            'formatter': 'logstash_json',
            'filters': ['additional_fields'],
        },
    },
    'loggers': {
        '': {
            'level': 'WARN',
            'handlers': ['logfile', 'json_log'],
        },
        'django.request': {
            'handlers': ['logfile', 'json_log'],
            'level': 'INFO',
            'propagate': True,  # also handle in parent handler
        },

        'stagecraft.apps': {
            'handlers': ['logfile', 'json_log'],
            'level': 'INFO',
            'propagate': True,
        },
        'stagecraft.libs': {
            'handlers': ['logfile', 'json_log'],
            'level': 'INFO',
            'propagate': True,
        },
        'stagecraft.audit': {
            'handlers': ['json_audit_log'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

@@ -181,16 +181,80 @@
 ist/%0A#%0A%0A
+import os%0A%0Afrom os.path import abspath, dirname, join as pjoin%0A%0A
 from .co
@@ -508,16 +508,733 @@
 r HTTP%0A%0A
+USE_DEVELOPMENT_USERS = False%0A%0AALLOWED_HOSTS = %5B%0A    '*',%0A%5D%0A%0AAPP_HOSTNAME = 'stagecraft%7B0%7D'.format(ENV_HOSTNAME)%0A%0AAPP_ROOT = 'https://%7B0%7D'.format(APP_HOSTNAME)%0AGOVUK_ROOT = os.getenv('GOVUK_WEBSITE_ROOT')%0A%0ABASE_DIR = abspath(pjoin(dirname(__file__), '..', '..'))%0ASTATIC_URL = '%7B0%7D/stagecraft/'.format(os.getenv('GOVUK_ASSET_HOST'))%0ASTATIC_ROOT = abspath(pjoin(BASE_DIR, 'public', 'stagecraft'))%0A%0ABACKDROP_PUBLIC_URL = 'https://www%7B0%7D'.format(PUBLIC_HOSTNAME)%0ABACKDROP_READ_URL = 'https://backdrop-read.%7B0%7D'.format(%0A    os.getenv('GOVUK_APP_DOMAIN'))%0ABACKDROP_WRITE_URL = 'https://backdrop-write.%7B0%7D'.format(%0A    os.getenv('GOVUK_APP_DOMAIN'))%0A%0ASIGNON_URL = 'https://signon.%7B0%7D'.format(os.getenv('GOVUK_APP_DOMAIN'))%0A%0A
 VARNISH_

Add non-secret production config