G4X Helpers
raw JSON → 3.0.2 verified Sat May 09 auth: no python
Python helpers for G4X applications. Provides utility functions and classes for logging, configuration, monitoring, and common infrastructure patterns. Current version 3.0.2, supports Python 3.10-3.12. Active development, monthly releases.
pip install g4x-helpers Common errors
error ModuleNotFoundError: No module named 'g4x_helpers' ↓
cause Package not installed or incorrect Python environment.
fix
Run 'pip install g4x-helpers' in the correct virtual environment.
error AttributeError: module 'g4x_helpers' has no attribute 'G4XLogger' ↓
cause Version 3.0+ moved classes into submodules.
fix
Use 'from g4x_helpers.logging import G4XLogger' instead.
error TypeError: G4XLogger.__init__() missing 1 required positional argument: 'name' ↓
cause Instantiated G4XLogger without required 'name' argument (v3.0+).
fix
Call G4XLogger(name='myapp') with a string argument.
Warnings
breaking v3.0.0 restructured package: all classes moved from top-level __init__ into submodules (logging, config, monitoring, etc.). Direct imports from g4x_helpers will fail. ↓
fix Change imports to from g4x_helpers.logging import ..., from g4x_helpers.config import ..., etc.
deprecated v3.0.0 deprecated ConfigLoader(env_prefix=) in favor of prefix= parameter. ↓
fix Use prefix='MYAPP' instead of env_prefix='MYAPP'.
gotcha G4XLogger requires argument name (positional) in v3.0+. Omitting name raises TypeError: G4XLogger() missing 1 required positional argument. ↓
fix Always pass name='your_app_name' to G4XLogger.
Imports
- G4XLogger wrong
from g4x_helpers import G4XLoggercorrectfrom g4x_helpers.logging import G4XLogger - ConfigLoader wrong
from g4x_helpers import ConfigLoadercorrectfrom g4x_helpers.config import ConfigLoader - MetricsCollector wrong
from g4x_helpers import MetricsCollectorcorrectfrom g4x_helpers.monitoring import MetricsCollector
Quickstart
from g4x_helpers.logging import G4XLogger
from g4x_helpers.config import ConfigLoader
import os
logger = G4XLogger(name='myapp')
config = ConfigLoader(prefix='MYAPP', env_file='.env')
# Access configuration
api_key = config.get('API_KEY', default=os.environ.get('API_KEY', ''))
logger.info(f"Starting app with API key present: {bool(api_key)}")