Logging
After calling init(), use the auralog 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.
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.