apifrom.config

Configuration module for APIFromAnything.

This module provides configuration classes and utilities for different environments.

Overview

Classes

  • BaseConfig

  • DevelopmentConfig

  • Environment

  • ProductionConfig

  • StagingConfig

  • TestingConfig

Functions

Classes

class apifrom.config.BaseConfig[source]

Base configuration class with common settings.

DevelopmentConfig:bases: BaseConfig

Development environment configuration.

Environment:bases: enum.Enum

Environment types for the application.

ProductionConfig:bases: BaseConfig

Production environment configuration.

StagingConfig:bases: BaseConfig

Staging environment configuration.

TestingConfig:bases: BaseConfig

Testing environment configuration.

Functions

apifrom.config.configure_logging()[source]
Return type:

None

Configure logging for the application.

apifrom.config.configure_logging_dict(log_level='INFO', log_format='structured', log_file=None, max_bytes=10485760, backup_count=5)[source]
Parameters:
  • log_level (str)

  • log_format (str)

  • log_file (Optional[str])

  • max_bytes (int)

  • backup_count (int)

Return type:

Dict[str, Any]

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.

apifrom.config.get_config()[source]
Return type:

BaseConfig

Get the configuration for the current environment.

returns:

The configuration instance for the current environment.

apifrom.config.setup_sentry(dsn, environment, release)[source]
Parameters:
Return type:

None

Set up Sentry for error tracking.

param dsn:

The Sentry DSN.

param environment:

The environment name.

param release:

The release version.