Skip to content

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" });
LevelSeverityBehavior
debug0Batched. Useful for development tracing.
info1Batched. General operational events.
warn2Batched. Something unexpected but not broken.
error3Sent immediately. Triggers AI analysis.
fatal4Sent immediately. Triggers AI analysis.

Logs at error and fatal level bypass the batch queue and are sent to the ingest endpoint immediately.

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.

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.

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.

Every log automatically includes a trace ID for correlating logs across services. See Distributed Tracing for details.