Platform 14–15 · Study guide
Configure nested settings and write structured logs — including production config caching.
from tpy.config import Config
# Always parse tpy.toml + env
cfg = Config.load(".")
# Prefer JSON cache when TPY_CONFIG_CACHE=1 and cache is fresh
cfg = Config.load_auto(".")
print(cfg.get("app.name"))
print(cfg.get("database.driver"))
print(cfg.get("server.port", 8000))
cfg.set("cache.driver", "redis") # runtime only
$ tpy config show $ tpy config show app.name $ tpy config cache $ tpy config status $ tpy config clear $ set TPY_CONFIG_CACHE=1 # Windows
tpy config cache writes storage/framework/config.cache.json.tpy.toml and .env.TPY_CONFIG_CACHE=1, load_auto() reads the cache when fresh; otherwise it reloads live sources.from tpy.logging import get_logger, LogManager
log = get_logger("app")
log.info("booted", version="0.1.9")
manager = LogManager()
manager.configure(level="INFO", log_dir="storage/logs", app_name="myapp")
manager.channel("stack").error("something failed")