Console Channel
ConsoleLog writes colorized, icon-prefixed lines to the terminal. No external dependencies, no configuration required to start.
import { ConsoleLog } from "@warlock.js/logger";
const channel = new ConsoleLog();It sets terminal: true, so ANSI color codes in your messages are preserved (unlike the file channels, which strip them).
Terminal output
Section titled “Terminal output”Each line follows this format:
{icon} {level} ({time}) [{module}] [{action}] {message}The console shows a time-only timestamp (HH:mm:ss.SSS) — within a dev session the date rarely changes, so the full ISO date is dropped here. The persistent channels (FileLog / JSONFileLog) keep the full ISO timestamp.
Real output:
⚙ debug (10:22:00.000) [auth] [hashPassword] Hashing startedℹ info (10:22:01.482) [users] [register] New user created⚠ warn (10:22:02.300) [queue] [process] Retry limit approaching✗ error (10:22:03.111) [payments] [charge] Card declined✓ success (10:22:03.890) [email] [send] Welcome email deliveredPrefix by level — each line is prefixed with the level’s icon and name. The name is padded to a fixed width so the timestamp, module, and action columns line up vertically across a stream of logs:
| Level | Prefix |
|---|---|
debug | ⚙ debug |
info | ℹ info |
warn | ⚠ warn |
error | ✗ error |
success | ✓ success |
fatal | ☠ fatal — white on a bright-red background badge (deliberately louder than error so a fatal entry can’t be missed) |
Colors by part
| Part | Color |
|---|---|
Timestamp (…) | Gray (dimmed, so the message stands out) |
Module […] | Cyan |
Action […] | Magenta |
Message — debug | Magenta bright |
Message — info | Blue bright |
Message — warn | Yellow bright |
Message — error | Red bright |
Message — success | Green bright |
Message — fatal | Red bright + bold |
Showing context
Section titled “Showing context”By default ConsoleLog discards the context payload — the file/JSON channels still record it, but the terminal stays uncluttered. Set showContext: true to render the context object on a second line, pretty-printed with util.inspect:
import { ConsoleLog, log } from "@warlock.js/logger";
log.addChannel(new ConsoleLog({ showContext: true }));
log.info("payments", "charge", "card declined", { userId: 42, amount: 1999,});// ℹ info (…) [payments] [charge] card declined// ↳ { userId: 42, amount: 1999 }contextDepth (default 4) clamps how deep util.inspect recurses into nested objects — useful when one context field is a giant payload you don’t want sprawling across the terminal:
new ConsoleLog({ showContext: true, contextDepth: 1, // collapses nested objects to [Object]});Filtering
Section titled “Filtering”ConsoleLog accepts the shared levels array and filter predicate (see Channels Overview). A common pattern is keeping the terminal focused on the subsystem you’re working on:
import { ConsoleLog } from "@warlock.js/logger";
// Only show auth-related messages during local developmentnew ConsoleLog({ filter: (data) => data.module === "auth",});
// Show everything except background workersnew ConsoleLog({ filter: (data) => !["queue", "scheduler"].includes(data.module),});
// Errors always pass through, info only for paymentsnew ConsoleLog({ filter: (data) => data.type === "error" || data.module === "payments",});The full option shape is ConsoleLogConfig — the shared options plus showContext / contextDepth.