Console LoggerJavaScript Logger for Browser & Node.js
Structured, namespaced console logging with child loggers, beautiful terminal output, and flexible transports — TypeScript-first, zero dependencies, ~10 KB.
Structured, namespaced console logging with child loggers, beautiful terminal output, and flexible transports — TypeScript-first, zero dependencies, ~10 KB.
Console Logger is a TypeScript-first JavaScript logger built for both browser and Node.js. It replaces console.log with structured, namespaced logging — six numeric log levels (trace, debug, info, warn, error, fatal), child loggers that carry request context, beautiful ANSI terminal output, browser DevTools styling, redaction, and pluggable transports (HTTP, file, stream).
Where most loggers force you to pick a side — Pino, Winston, and Bunyan are Node-only, while loglevel and debug are browser-only — Console Logger is one library that runs in both. Same API. Same JSON schema. Auto-detects the environment and picks the right format: pretty ANSI in a TTY, NDJSON in CI, styled %c badges in the browser console.
import { Konsole } from 'konsole-logger';
const log = new Konsole({ namespace: 'App' });
log.info('Server started', { port: 3000 }); // INF [App] Server started port=3000
log.warn('Slow query', { ms: 812, sql }); // WRN [App] Slow query ms=812 sql=...
log.error(new Error('DB unreachable')); // ERR [App] DB unreachable
const req = log.child({ requestId: 'r_42' }); // attaches requestId to every line
req.debug('Cache miss'); // DBG [App] Cache miss requestId=r_42Same API on both. Auto-picks ANSI, NDJSON, or DevTools.
child({ requestId }) attaches context to every line.
Pino-compatible schema with six numeric levels.
ISO, epoch, custom, or nanosecond — switchable at runtime.
Mask passwords & PII with dot-notation paths.
HTTP batching, file rotation + gzip, streams.
Off-main-thread storage and HTTP batching.
Full types, zero runtime dependencies.
On par with Pino; smaller than Winston and Bunyan.
Six numeric log levels — discard everything below your threshold.
const logger = new Konsole({
namespace: 'App',
level: 'info', // trace + debug discarded
});
logger.trace('→ entering loop'); // 10 — dropped
logger.debug('Cache miss'); // 20 — dropped
logger.info('Server started', { port: 3000 }); // 30 ✅
logger.warn('Memory at 80%'); // 40 ✅
logger.error(new Error('timeout')); // 50 ✅
logger.fatal('Out of memory'); // 60 ✅Console has no framework dependency — it works everywhere: React, plain HTML, and Node.js servers.
Import as a module in any React app — works with Next.js, Vite, and CRA.
import { Konsole } from 'konsole-logger';
// Create loggers at module level
const logger = new Konsole({ namespace: 'App', format: 'silent' });
const api = new Konsole({ namespace: 'API', level: 'warn' });
function Dashboard() {
const handleClick = () => {
const req = logger.child({ requestId: crypto.randomUUID() });
req.info('Dashboard loaded', { userId: 42 });
};
return <button onClick={handleClick}>Load</button>;
}
// Expose for DevTools debugging
Konsole.exposeToWindow();Measured on Apple M5 Max, Node.js v24.15, 100K iterations. Pino, Winston, and Bunyan are Node.js only; Consola runs in the browser but without worker offloading. Console runs in both with worker offloading. Run npm run benchmark to reproduce.
Production throughput — emitting structured JSON to a stream (the path that runs in real apps; higher is better)
| Logger | ops/sec | p50 |
|---|---|---|
| Console | 4.16M | 125 ns |
| Consola | 795.9K | 1.13 µs |
| Bunyan | 741.8K | 1.25 µs |
| Winston | 672.9K | 917 ns |
| Pino | 560.5K | 1.63 µs |
Disabled / silent — microbenchmark for per-call overhead (not a realistic throughput; nobody ships silenced loggers)
| Mode | Console | Pino | Consola | Winston |
|---|---|---|---|---|
| Silent / disabled | 13.45M | 13.57M | 15.24M | 2.98M |
| Child (silent / disabled) | 32.86M | 34.02M | 22.60M | 2.12M |
Console, Pino, and Consola are within run-to-run V8 noise on the silent path — the gap shows up where it matters: actually emitting log lines.
Browser-only
| Scenario | Console |
|---|---|
| Silent + buffer | 6.01M |
| With Worker | non-blocking |
Bundle & install size (smaller is better)
| Console | Pino | Winston | Bunyan | Consola | |
|---|---|---|---|---|---|
| Bundle (gzip) | ~10 KB | ~32 KB | ~70 KB | ~45 KB | ~12 KB |
| Install size | 135 KB | 1.17 MB | 360 KB | 212 KB | 420 KB |
| Dependencies | 0 | 11 | 11 | 0 | 0 |
See the Performance Guide for details.