log
import { log } from "@tynd/core/client";JSON-lines format on disk with size, hourly UTC, or daily UTC rotation. Backend and frontend entries land in the same file.
configure(options): Promise<void>
Section titled “configure(options): Promise<void>”await log.configure({ level: "info", // "debug" | "info" | "warn" | "error" file: "/abs/path/app.log", // absolute, inside the fs scope; default below maxBytes: 2 * 1024 * 1024, // rotate at 2 MiB (default 5 MiB) maxFiles: 5, // keep .log.1 .. .log.5 (default 3) rotation: "both", // "size" | "hourly" | "daily" | "both"});size is the default. hourly and daily rotate before the first entry in
the next UTC bucket. both combines the size limit and daily UTC rotation.
maxFiles is the exact number of numbered backups retained.
configure rejects a relative file, a file outside the security.fs scope, and an unknown level or rotation.
debug|info|warn|error(message, fields?): Promise<void>
Section titled “debug|info|warn|error(message, fields?): Promise<void>”await log.info("boot complete", { runtime: "bun", ms: 142 });await log.error("http 500", { url: "/api/sync", code: 500 });Entries below the configured level are dropped.
path(): Promise<string>
Section titled “path(): Promise<string>”Absolute path of the currently active log file.
captureConsole(): void — bridge console.* into the log
Section titled “captureConsole(): void — bridge console.* into the log”Idempotent. Wraps every console.log / info / warn / error / debug so it still prints to DevTools but also lands in the log file at the mapped level.
log.captureConsole();console.warn("slow query", { ms: 812 }); // -> stderr AND log fileCall log.restoreConsole() to revert.
Default location
Section titled “Default location”<cache_dir>/<app>/logs/app.log, the folder os.appLogDir() returns, where <app> is bundle.identifier (the executable name when unset; the data dir, then the temp dir, stand in when the OS has no cache dir). Backups use app.log.1,
app.log.2, …; anything past maxFiles is deleted.