from datetime import timedelta
import os

os.umask(0o002)

{% if env == 'staging' %}
DB_URL = 'postgresql://{{ distgit_stg_pagure_db_ro_user }}:{{ distgit_stg_pagure_db_ro_pass }}@{{ pagure_db_host }}/{{ distgit_stg_pagure_db_name }}'
{% else %}
DB_URL = 'postgresql://{{ distgit_pagure_db_ro_user }}:{{ distgit_pagure_db_ro_pass }}@{{ pagure_db_host }}/{{ distgit_pagure_db_name }}'
{% endif %}

{% include "pagure_shared.cfg" %}

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "standard": {
            "format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
        },
    },
    "handlers": {
        "console": {
            "formatter": "standard",
            "class": "logging.StreamHandler",
            "stream": "ext://sys.stdout",
            "level": "WARN",
        },
        "auth_handler": {
            "formatter": "standard",
            "class": "logging.handlers.TimedRotatingFileHandler",
            "filename": "/var/log/pagure/pagure_auth.log",
            "backupCount": 10,
            "utc": True,
            "when": "midnight",
        },
    },
    # The root logger configuration; this is a catch-all configuration
    # that applies to all log messages not handled by a different logger
    "root": {"level": "WARN", "handlers": ["console"]},
    "loggers": {
        "pagure": {
            "handlers": ["auth_handler"],
            "level": "INFO",
            "propagate": True,
        },
        "pagure_auth": {
            "handlers": ["auth_handler"],
            "level": "DEBUG",
            "propagate": False,
        },
    },
}

