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} ({ISO timestamp}) [{module}] [{action}] {message}Real output:
⚙ (2024-03-15T10:22:00.000Z) [auth] [hashPassword] Hashing startedℹ (2024-03-15T10:22:01.482Z) [users] [register] New user created⚠ (2024-03-15T10:22:02.300Z) [queue] [process] Retry limit approaching✗ (2024-03-15T10:22:03.111Z) [payments] [charge] Card declined✓ (2024-03-15T10:22:03.890Z) [email] [send] Welcome email deliveredIcons by level
| Level | Icon |
|---|---|
debug | ⚙ |
info | ℹ |
warn | ⚠ |
error | ✗ |
success | ✓ |
Colors by part
| Part | Color |
|---|---|
Timestamp (…) | Yellow |
Module […] | Cyan |
Action […] | Magenta |
Message — debug | Magenta bright |
Message — info | Blue bright |
Message — warn | Yellow bright |
Message — error | Red bright |
Message — success | Green bright |
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,});// ℹ (…) [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.