apifrom.config ============== Configuration module for APIFromAnything. This module provides configuration classes and utilities for different environments. .. py:currentmodule:: apifrom.config Overview -------- **Classes** * :py:class:`BaseConfig` * :py:class:`DevelopmentConfig` * :py:class:`Environment` * :py:class:`ProductionConfig` * :py:class:`StagingConfig` * :py:class:`TestingConfig` **Functions** * :py:func:`configure_logging` * :py:func:`configure_logging_dict` * :py:func:`get_config` * :py:func:`setup_sentry` Classes ------- .. py:class:: BaseConfig Base configuration class with common settings. .. :: ALLOWED_HOSTS .. :: APP_NAME .. :: CACHE_TTL .. :: CACHE_URL .. :: CORS_ORIGINS .. :: CSRF_PROTECTION .. :: DATABASE_URL .. :: DB_MAX_OVERFLOW .. :: DB_POOL_SIZE .. :: DB_TIMEOUT .. :: DEBUG .. :: DETAILED_HEALTH_CHECK_PATH .. :: HEALTH_CHECK_PATH .. :: HOST .. :: HTTPS_ENABLED .. :: LOG_FILE .. :: LOG_FORMAT .. :: LOG_LEVEL .. :: METRICS_ENABLED .. :: METRICS_PORT .. :: MIDDLEWARE .. :: PORT .. :: RATE_LIMIT .. :: RATE_LIMITING_ENABLED .. :: RELOAD .. :: SECRET_KEY .. :: SENTRY_DSN .. :: VERSION .. :: WORKERS .. py:class:: DevelopmentConfig:bases: BaseConfig Development environment configuration. .. :: DEBUG .. :: LOG_LEVEL .. :: METRICS_ENABLED .. :: RELOAD .. py:class:: Environment:bases: enum.Enum Environment types for the application. .. :: DEVELOPMENT .. :: PRODUCTION .. :: STAGING .. :: TESTING .. py:class:: ProductionConfig:bases: BaseConfig Production environment configuration. .. :: ALLOWED_HOSTS .. :: CORS_ORIGINS .. :: CSRF_PROTECTION .. :: HOST .. :: HTTPS_ENABLED .. :: LOG_FILE .. :: LOG_FORMAT .. :: METRICS_ENABLED .. :: MIDDLEWARE .. :: RATE_LIMITING_ENABLED .. :: WORKERS .. py:class:: StagingConfig:bases: BaseConfig Staging environment configuration. .. :: ALLOWED_HOSTS .. :: CORS_ORIGINS .. :: HOST .. :: HTTPS_ENABLED .. :: LOG_FILE .. :: LOG_FORMAT .. :: METRICS_ENABLED .. :: MIDDLEWARE .. :: RATE_LIMITING_ENABLED .. :: WORKERS .. py:class:: TestingConfig:bases: BaseConfig Testing environment configuration. .. :: DATABASE_URL .. :: DEBUG .. :: LOG_FILE .. :: LOG_LEVEL .. :: METRICS_ENABLED Functions --------- .. py:function:: configure_logging() Configure logging for the application. .. py:function:: configure_logging_dict(log_level = 'INFO', log_format = 'structured', log_file = None, max_bytes = 10485760, backup_count = 5) Create a logging configuration dictionary. :param log_level: The logging level. :param log_format: The log format ('structured' for JSON, 'simple' for text). :param log_file: The path to the log file. If None, logs will be sent to stdout. :param max_bytes: The maximum size of the log file before rotation. :param backup_count: The number of backup log files to keep. :returns: A logging configuration dictionary. .. py:function:: get_config() Get the configuration for the current environment. :returns: The configuration instance for the current environment. .. py:function:: setup_sentry(dsn, environment, release) Set up Sentry for error tracking. :param dsn: The Sentry DSN. :param environment: The environment name. :param release: The release version.