Serverless-first. Built for cold starts, tight memory, and one binary.Deploy guide →

console

All output goes to stderr, every argument is printed (joined with a space), and every method returns undefined.

console.log("plain");
console.info("same as log");
console.debug("same as log");
console.warn("yellow");
console.error("red");
console.log("multiple", 1, true, null);   // multiple 1 true null

Methods

MethodOutputNotes
console.log(...)plainwrites to stderr
console.info(...)plainalias of log
console.debug(...)plainalias of log
console.warn(...)yellownon-standard colouring
console.error(...)rednon-standard colouring
console.slops(...)yellowalias of warn
console.detail(...)greensuccess / detail line
console.redbal(...)redalias of error
console.time(label)—start or restart a named timer
console.timeLog(label)label: Nmsread elapsed without stopping
console.timeEnd(label)label: Nmsread elapsed and remove the label

Timers

// timing.js — ff timing.js
console.time("db-query");
// ... work ...
console.timeLog("db-query");   // db-query: 1ms

// ... more work ...
console.timeEnd("db-query");   // db-query: 12ms (timer removed)

Output is integer milliseconds measured on the wall clock (CLOCK_REALTIME), printed as label: 12ms.

Unknown labels warn instead of throwing:

console.timeEnd("never-started");
// warning: unknown timer 'never-started'

Calling timeEnd twice warns — the label is removed once ended. timeLog may be called repeatedly while the timer runs.

Everything goes to stderr

$ ff app.js            # logs appear on the terminal
$ ff app.js 2>/dev/null # nothing — that's stderr being discarded
$ ff app.js > out.txt   # out.txt is empty
$ ff app.js 2> out.txt  # out.txt has the logs

That's deliberate: stdout stays clean for program output (JSON you pipe to jq, a generated file listing), while diagnostics stay visible in a terminal.

Arguments

Every argument is printed, converted with standard toString semantics:

console.log("count:", 3, { ok: true });
// count: 3 [object Object]

console.log({ ok: true });     // objects do NOT pretty-print
console.log(JSON.stringify({ ok: true }, null, 2));  // use this instead
  • Objects print as [object Object] — serialize explicitly if you want structure.
  • A single line is buffered up to 4096 bytes; longer lines flush in chunks, so a huge argument still prints in full.
  • console.log.length is 2 and console.time.length is 1 — the arity QuickJS reports. Don't rely on it.

Gotchas

  • stderr, not stdout. console.log > file captures nothing.
  • No console.table, console.trace, console.assert, console.count — they're not defined; calling them throws TypeError.
  • Colours are raw ANSI escapes; piping to a file keeps the escape codes.
  • Timers use wall-clock time, so an NTP step can make a duration look negative or huge. For measurements, prefer performance.now().

See also