Console Capture
Send existing browser console output to Logged without replacing your normal console behavior.
Setup
import { Logged } from "@oheoco/logged";
const logger = new Logged({
apiKey: process.env.NEXT_PUBLIC_LOGGED_API_KEY!,
});
logger.interceptConsole();After calling interceptConsole(), the following browser methods are forwarded to Logged while still appearing in DevTools:
- console.log
- console.info
- console.warn
- console.error
- console.table
How it works
console.log("Application started");
console.info("User authenticated");
console.warn("API response is slow");
console.error("Payment failed");
console.table([
{ name: "Alice", active: true, revenue: 1200 },
{ name: "Bob", active: false, revenue: 980 },
]);Each call still prints to the browser console. Logged receives a structured copy with the log level, message, and serialized arguments.console.table is also captured and stored in a tabular format for dashboard viewing.
Serialization
Console arguments are serialized safely so objects, arrays, and circular references do not break the SDK.
console.log("User:", {
id: "123",
role: "admin",
});This produces a Logged event with the object preserved in metadata rather than stringified into [object Object].
Cleanup
logger.stopConsoleInterception();Restores the original console methods. This is useful in tests or when disabling capture for part of an application lifecycle.
Notes
Browser only
Multiple calls are safe
interceptConsole() multiple times does not wrap the same methods more than once.