Logging
After calling init(), use the auralogs object to send logs:
import { auralog } from "auralog-sdk";
auralog.debug("Cache miss for user profile", { userId: "usr_123" });auralog.info("Order placed", { orderId: "ord_456", total: 99.99 });auralog.warn("Rate limit approaching", { current: 950, limit: 1000 });auralog.error("Payment failed", { userId: "usr_123", error: "card_declined" });auralog.fatal("Database connection lost", { host: "db-primary" });Log levels
Section titled “Log levels”| Level | Severity | Behavior |
|---|---|---|
debug | 0 | Batched. Useful for development tracing. |
info | 1 | Batched. General operational events. |
warn | 2 | Batched. Something unexpected but not broken. |
error | 3 | Sent immediately. Triggers AI analysis. |
fatal | 4 | Sent immediately. Triggers AI analysis. |
Logs at error and fatal level bypass the batch queue and are sent to the ingest endpoint immediately.
Metadata
Section titled “Metadata”The second argument is an optional metadata object. Use it to attach structured context:
auralog.error("Checkout failed", { userId: "usr_123", cartId: "cart_789", paymentMethod: "stripe", errorCode: "card_declined",});Metadata values can be strings, numbers, booleans, or nested objects. They appear in the dashboard log viewer and are included in AI analysis context.
Combining with global metadata
Section titled “Combining with global metadata”If you’ve configured globalMetadata, it is shallow-merged with the per-call object before the entry is sent. Per-call keys win on collision:
init({ apiKey: "aura_...", globalMetadata: () => ({ user_id: currentUser?.id }),});
auralog.warn("rate limited", { route: "/api/checkout" });// wire metadata: { user_id: "u_42", route: "/api/checkout" }This is also how captured console.* calls and uncaught errors get attribution — they pick up globalMetadata automatically since they have no per-call object of their own.
Stack traces
Section titled “Stack traces”error and fatal accept an optional third argument for a stack trace:
try { await processOrder(order);} catch (err) { auralog.error("Order processing failed", { orderId: order.id }, err.stack);}If you’re using automatic error capture (enabled by default), stack traces are captured automatically for uncaught exceptions. See Error Capture.
Trace IDs
Section titled “Trace IDs”Every log automatically includes a trace ID for correlating logs across services. See Distributed Tracing for details.