Logging
The library uses a lightweight console logger by default for both Node.js and web environments. The logger outputs structured JSON logs with timestamps. You can configure the log level via setLogLevel() API or provide a custom logger that satisfies the ILogger interface.
Default Logger
import { Logger } from "@ar.io/sdk";
// set the log level
Logger.default.setLogLevel("debug");
// Create a new logger instance with a specific level
const logger = new Logger({ level: "debug" });Custom Logger Implementation
You can provide any custom logger that implements the ILogger interface:
import { ARIO, ILogger } from "@ar.io/sdk";
// Custom logger example
const customLogger: ILogger = {
info: (message, ...args) => console.log(`[INFO] ${message}`, ...args),
warn: (message, ...args) => console.warn(`[WARN] ${message}`, ...args),
error: (message, ...args) => console.error(`[ERROR] ${message}`, ...args),
debug: (message, ...args) => console.debug(`[DEBUG] ${message}`, ...args),
setLogLevel: (level) => {
/* implement level filtering */
},
};
// Set it as the default logger across the entire SDK — every class
// (ARIO, ANT, ANTRegistry, etc.) will route logs through it. `ARIO.init`
// does not accept a per-instance logger.
Logger.default = customLogger;How is this guide?