Documentation / @zerotal/core / logger
logger
Structured, channel-based logging for Zerotal applications.
A single LogManager owns a set of named channels
(console, single file, date-rotated daily files, null, or a stack that
fans out to several at once) and routes every LogEntry to the channel
you select. Entries are enriched automatically with hostname, pid, app/env,
and the active request id, and each channel has its own minimum
LogLevel. Reach the container-bound manager through the Log
facade; configure it with LoggingConfig.
Examples
import { Log } from "@zerotal/core/logger";
// Log at any of the five levels on the default channel.
Log.info("User signed in", { userId: 42 });
Log.error("Payment failed", { orderId: 99 }, err);
// Bind shared context, or target a specific channel.
Log.withContext({ requestId: "abc" }).warn("Retrying");
Log.channel("daily").info("Written to today's file");
// config/logging.ts — a "stack" that writes to both console and daily files.
import { LoggingConfig } from "@zerotal/core/logger";
export default LoggingConfig({
default: "stack",
channels: {
stack: { driver: "stack", channels: ["console", "daily"] },
console: { driver: "console", format: "pretty" },
daily: { driver: "daily", path: "./storage/logs", days: 14, level: "info" },
},
});