Environments
Auralog groups logs by the environment string you pass to init(). Use distinct values per deployment so the dashboard can filter cleanly.
import osfrom auralog import init
init( api_key=os.environ["AURALOG_API_KEY"], environment=os.environ.get("APP_ENV", "dev"),)Local development
Section titled “Local development”For local dev, pass environment="dev" and consider raising flush_interval or setting capture_errors=False to reduce noise during debugging:
init( api_key="aura_dev_key", environment="dev", flush_interval=30.0, capture_errors=False,)Testing
Section titled “Testing”In unit tests you usually want the SDK inert. Either:
- Skip
init()entirely — callingauralog.*without init raisesRuntimeError("auralog.init() must be called before using the logger"). Stub the proxy or guard usage. - Point at a mock endpoint — set
endpoint="http://localhost:1"to let calls fail fast and silently (network errors are swallowed).
Example pytest fixture:
import pytestfrom auralog import init, shutdown
@pytest.fixture(autouse=True)def _auralog(): init(api_key="test", environment="test", endpoint="http://localhost:1", capture_errors=False) yield shutdown()Serverless / short-lived processes
Section titled “Serverless / short-lived processes”For AWS Lambda, Cloud Run jobs, and similar: call shutdown() at the end of the handler to guarantee a flush before the process is frozen.
def lambda_handler(event, context): try: do_work(event) finally: from auralog import shutdown shutdown()