Load nfo settings from a .env file using python-dotenv — zero hardcoded config in code.
python-dotenv loads .env into os.environ before configure()configure() reads NFO_LEVEL, NFO_SINKS, NFO_ENV, etc. automatically.env — switch environments by swapping the filepip install nfo python-dotenv
# Copy template and adjust:
cp examples/.env.example examples/.env
python examples/env-config/main.py
from dotenv import load_dotenv
load_dotenv() # loads .env → os.environ
from nfo import configure, log_call
configure() # reads NFO_LEVEL, NFO_SINKS, NFO_ENV automatically
@log_call
def create_order(order_id: str, amount: float) -> dict:
return {"order_id": order_id, "status": "created"}
See ../.env.example for all available NFO_* variables:
| Variable | Description | Default |
|---|---|---|
NFO_LEVEL |
Log level | DEBUG |
NFO_SINKS |
Sink specs (comma-separated) | console |
NFO_ENV |
Environment tag | auto-detect |
NFO_VERSION |
App version | auto-detect |
NFO_LOG_DIR |
Log directory | ./logs |
NFO_LLM_MODEL |
LLM model for analysis | — |