Skip to content

Environments

Auralog groups logs by the environment string you pass to init(). Use distinct values per deployment so the dashboard can filter cleanly.

import os
from auralog import init
init(
api_key=os.environ["AURALOG_API_KEY"],
environment=os.environ.get("APP_ENV", "dev"),
)

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,
)

In unit tests you usually want the SDK inert. Either:

  • Skip init() entirely — calling auralog.* without init raises RuntimeError("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 pytest
from 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()

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()