Auralogs Python SDK — agentic logging and application awareness.
Project description
auralogs
Python SDK for Auralogs — agentic logging and application awareness.
Auralogs acts as an on-call engineer — powered by your choice of model (Claude, OpenAI, or any MCP-compatible LLM) — monitoring your logs and errors, alerting you when something's wrong, and opening fix PRs automatically.
Install
pip install auralogs
Quick start
from auralogs import init, auralogs
init(api_key="aura_your_key", environment="production")
auralogs.info("user signed in", metadata={"user_id": "123"})
auralogs.error("payment failed", metadata={"order_id": "abc"})
Python 3.10+.
Bridge the stdlib logging module (recommended for existing codebases)
Python's logging module is used everywhere — including frameworks (Django, Flask, FastAPI) and libraries (requests, SQLAlchemy, Celery). AuralogsHandler captures those logs without requiring code changes:
import logging
from auralogs import init, AuralogsHandler
init(api_key="aura_your_key", environment="production")
logging.getLogger().addHandler(AuralogsHandler())
logging.getLogger().setLevel(logging.INFO)
# Any existing logging.* calls — including from third-party libraries — flow to auralogs
logging.info("payment processed", extra={"order_id": "abc"})
Restricting which extra fields ship (metadata_allowlist)
By default AuralogsHandler forwards every key from the underlying LogRecord.__dict__ minus a curated denylist of stdlib fields. If your codebase passes sensitive values via extra={...} (auth tokens, raw PII, internal IDs) and you'd rather opt-in than opt-out, pass an explicit allowlist:
logging.getLogger().addHandler(
AuralogsHandler(metadata_allowlist={"user_id", "tenant", "request_id"})
)
# Only "user_id" reaches the wire — "auth_token" is dropped.
logging.info("user fetched", extra={"user_id": "u_1", "auth_token": "secret"})
When metadata_allowlist is set, only the named keys are included; default behavior (denylist of stdlib fields) is preserved when it is omitted.
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
api_key |
str |
required | Your Auralogs project API key |
environment |
str |
"production" |
e.g. "production", "staging", "dev" |
endpoint |
str |
https://ingest.auralogs.ai |
Ingest endpoint override |
flush_interval |
float |
5.0 |
Seconds between batched flushes (errors flush immediately) |
capture_errors |
bool |
True |
Capture uncaught exceptions (main thread, threads, asyncio) |
trace_id |
str |
auto-generated | Custom trace ID for distributed tracing |
global_metadata |
dict[str, Any] or Callable[[], dict[str, Any]] |
None |
Baseline metadata merged into every emitted log entry. Per-call metadata keys win on collision (shallow merge). Synchronous suppliers only. |
max_queue_size |
int |
1000 |
Maximum buffered (non-error) log entries held in memory between flushes. When the buffer is full, the oldest entries are dropped first so an unreachable ingest endpoint can't OOM the host process. Errors bypass the buffer. |
allow_insecure_endpoint |
bool |
False |
Permit a non-https:// endpoint. Off by default so a misconfigured endpoint=http://... can't silently downgrade every POST to plaintext. Opt in for local development ingests only. |
Attaching session-scoped fields to every log (global_metadata)
To pin fields like user_id, tenant, or a feature-flag snapshot onto every log entry — including framework-bridge captures (AuralogsHandler) and uncaught-error captures — pass global_metadata to init. Two forms are supported:
Static dict — for values that don't change over the process lifetime:
init(api_key="aura_your_key", global_metadata={"service": "billing", "region": "us-east"})
Callable supplier — invoked at every emit, so values can change over time. This is the canonical recipe for attaching the current user to every log:
from contextvars import ContextVar
from auralogs import init, auralogs
current_user: ContextVar[str | None] = ContextVar("current_user", default=None)
def session_metadata() -> dict[str, object]:
return {"user_id": current_user.get()}
init(api_key="aura_your_key", global_metadata=session_metadata)
# Anywhere a request handler sets the user, every subsequent log carries it:
current_user.set("u_123")
auralogs.info("checkout completed")
# -> metadata = {"user_id": "u_123"}
Per-call metadata still wins on collision, so impersonation and admin actions can override:
auralogs.info("admin override", metadata={"user_id": "admin_7"}) # admin_7, not u_123
Caveats:
- The supplier runs on every emit — keep it O(1) cheap. Don't hit a database or do I/O.
- Synchronous only. If your supplier is an
async def, or returns a coroutine/awaitable, the entry is emitted withoutglobal_metadataand a one-time warning is logged. Cache async state into aContextVaror thread-local from the sync side. - If the supplier raises, the entry is still emitted (without
global_metadata) — logging never crashes the host. - Non-JSON-serializable values are dropped (with a one-time warning); the entry still ships with per-call metadata.
Attaching a traceback
try:
risky()
except Exception as e:
auralogs.error("task crashed", metadata={"task": "ingest"}, exc_info=e)
Graceful shutdown
auralogs flushes pending logs on interpreter exit automatically via atexit. For deterministic flush (serverless handlers, short-lived scripts):
from auralogs import shutdown
shutdown()
Thread and async safety
- Threads: The transport uses a
threading.Lockaround the in-memory batch. Safe for multi-threaded apps (Django under Gunicorn, FastAPI workers, Celery). - Background flushing: A daemon thread flushes every
flush_intervalseconds; errors send immediately on a separate endpoint. - Asyncio: Error capture installs a handler on the active event loop when
init()runs inside one. Callinit()from your framework's startup hook so it installs against your app's loop.
Verify this package
Every release is published with sigstore provenance attestations via GitHub Actions. The attestation proves the distribution was built from a specific commit in this repository — without having to trust PyPI or the maintainer.
Inspect the attestation on pypi.org/project/auralogs under "Provenance".
Documentation
Full docs at docs.auralogs.ai.
Security
Found a vulnerability? See SECURITY.md for how to report it.
License
MIT © James Thomas
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auralogs-1.0.0.tar.gz.
File metadata
- Download URL: auralogs-1.0.0.tar.gz
- Upload date:
- Size: 23.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3605919bb7961b8febb570ffa8220d2d6ec3ce049017d5838c8697fb122da5e
|
|
| MD5 |
d566c72d55c037c74e327ef33707fe4b
|
|
| BLAKE2b-256 |
71251065d1e83ceb5f401bb7609923b6b0d32af3f4ad866477bf3ed93d3d2647
|
Provenance
The following attestation bundles were made for auralogs-1.0.0.tar.gz:
Publisher:
release.yml on auralogs-ai/auralogs-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
auralogs-1.0.0.tar.gz -
Subject digest:
c3605919bb7961b8febb570ffa8220d2d6ec3ce049017d5838c8697fb122da5e - Sigstore transparency entry: 1547654447
- Sigstore integration time:
-
Permalink:
auralogs-ai/auralogs-python@5d157b748e1a6f1cf25df17294742257165b4d09 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/auralogs-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5d157b748e1a6f1cf25df17294742257165b4d09 -
Trigger Event:
release
-
Statement type:
File details
Details for the file auralogs-1.0.0-py3-none-any.whl.
File metadata
- Download URL: auralogs-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b347f15c4dd76b073a2e1786f5e4fd8ec91ec480c1848f8ce148b8b7f3c4552
|
|
| MD5 |
3bc9fc5bc41dbbf5eb4afc6750a39333
|
|
| BLAKE2b-256 |
312aa7b23cdd163ee1fafee770e287484fc322ae9c11a719deedf808502d065b
|
Provenance
The following attestation bundles were made for auralogs-1.0.0-py3-none-any.whl:
Publisher:
release.yml on auralogs-ai/auralogs-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
auralogs-1.0.0-py3-none-any.whl -
Subject digest:
7b347f15c4dd76b073a2e1786f5e4fd8ec91ec480c1848f8ce148b8b7f3c4552 - Sigstore transparency entry: 1547654568
- Sigstore integration time:
-
Permalink:
auralogs-ai/auralogs-python@5d157b748e1a6f1cf25df17294742257165b4d09 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/auralogs-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5d157b748e1a6f1cf25df17294742257165b4d09 -
Trigger Event:
release
-
Statement type: