from pathlib import Path

def get_logging_config(base_dir: Path):
    log_dir = base_dir / "logs"
    log_dir.mkdir(exist_ok=True)

    return {
        "version": 1,
        "disable_existing_loggers": False,
        "formatters": {
            "default": {
                "format": "[{asctime}] [{levelname}] {name}: {message}",
                "style": "{",
            },
        },
        "handlers": {
            "console": {
                "class": "logging.StreamHandler",
                "formatter": "default",
            },
            "file": {
                "class": "logging.handlers.TimedRotatingFileHandler",
                "filename": log_dir / "django.log",
                "when": "midnight",
                "backupCount": 7,
                "formatter": "default",
                "delay": True,
            },
            "mail_admins": {
                "class": "django.utils.log.AdminEmailHandler",
                "level": "ERROR",
            },
        },
        "loggers": {
            "django": {
                "handlers": ["console", "file"],
                "level": "INFO",
                "propagate": True,
            },
            "django.request": {
                "handlers": ["console", "file", "mail_admins"],
                "level": "ERROR",
                "propagate": False,
            },
        },
    }
