console

js/globals/console.ts

Console globals available as globalThis.console.

The console API provides synchronous diagnostic output for programs and runtime tooling. Methods write formatted text directly to stdout or stderr, so logging is available before stream globals or the event loop are fully initialized.

Values are formatted with a small inspector that understands primitives, arrays, plain objects, errors, dates, maps, sets, typed arrays, and circular references. String-first calls support printf-style substitutions such as %s, %d, %f, %o, %O, %c, and %%.

Grouping indents later output until groupEnd() is called. Timers and counters are stored per label, matching the shape of the WHATWG Console API while keeping terminal-only operations such as clear() and timeStamp() as no-ops.

console.group('request');
console.log({ method: 'GET', url: '/health' });
console.time('work');
console.timeEnd('work');
console.groupEnd();

Console Standard: https://console.spec.whatwg.org/

Interfaces

interface Console {

The console object installed on globalThis.console.

Console methods synchronously format their arguments and write one line to stdout or stderr. Formatting supports common JavaScript values, % style substitutions in string-first calls, indentation groups, timers, and counters.

The runtime installs a singleton implementing this interface on globalThis.console, so no import is needed:

console.log('user %s logged in', 'ada');   // stdout: user ada logged in
console.error(new Error('boom'));          // stderr: [error] Error: boom ...
console.time('parse');
JSON.parse('{"large": "payload"}');
console.timeEnd('parse');                  // stdout: parse: 0.42ms
console.count('requests');                 // stdout: requests: 1

Methods

log(...args: unknown[]): void

Write a formatted line to stdout.

info(...args: unknown[]): void

Write a formatted informational line to stdout.

debug(...args: unknown[]): void

Write a formatted debug line to stdout.

warn(...args: unknown[]): void

Write a formatted warning line to stderr with a warning prefix.

error(...args: unknown[]): void

Write a formatted error line to stderr with an error prefix.

assert(condition: unknown, ...args: unknown[]): void

Write an assertion failure to stderr when condition is falsy.

dir(obj: unknown, opts?: { depth?: number; colors?: boolean; }): void

Inspect obj and write the result to stdout.

depth controls object and array recursion. colors is accepted for compatibility but ignored because console output is plain text.

table(data: unknown): void

Write table data to stdout.

Fino currently prints JSON when possible and falls back to normal object inspection for values that cannot be serialized.

group(...args: unknown[]): void

Write an optional heading and indent subsequent console output.

groupCollapsed(...args: unknown[]): void

Write an optional heading and indent subsequent output.

This is equivalent to group() in the terminal runtime because there is no DevTools UI that can collapse groups.

groupEnd(): void

End the current indentation group.

time(label?: string): void

Start or replace a timer for label.

Omitting label uses the label 'default'. Starting a timer that already exists silently restarts it.

timeEnd(label?: string): void

Print the elapsed time for label to stdout and remove the timer.

If no timer with that label exists, a [warn] line is written to stderr instead.

timeLog(label?: string, ...args: unknown[]): void

Print the elapsed time for label without removing the timer.

Extra arguments are formatted and appended after the elapsed time. If no timer with that label exists, a [warn] line is written to stderr instead.

count(label?: string): void

Increment and print the counter for label.

Omitting label uses the label 'default'. The first call for a label prints 1.

countReset(label?: string): void

Reset the counter for label.

If no counter with that label exists, a [warn] line is written to stderr.

clear(): void

Clear the console when an interactive console is available.

This is a no-op in Fino's terminal runtime.

trace(...args: unknown[]): void

Write a stack trace to stdout with optional formatted leading text.

dirxml(...args: unknown[]): void

Write XML-like diagnostic output.

Because Fino has no DOM renderer, this delegates to normal console formatting.

timeStamp(label?: string): void

Record a performance timestamp when a DevTools timeline is available.

This is a no-op in Fino's terminal runtime.

Constants

const console: Console

Runtime console singleton exposed as globalThis.console.

Methods write directly to stdout or stderr through internal libc bindings. Formatting is intentionally small and synchronous so console works before stream globals or the event loop are fully initialized.

console.log('ready');
console.warn('slow path');

Methods

log(...args)
info(...args)
debug(...args)
warn(...args)
error(...args)
assert(condition: unknown, ...args: unknown[])
dir(obj: unknown, opts?: { depth?: number; colors?: boolean; })
table(data: unknown)
group(...args)
groupCollapsed(...args)
groupEnd()
time(label?: unknown)
timeEnd(label?: unknown)
timeLog(label?: unknown, ...args)
count(label?: unknown)
countReset(label?: unknown)
clear()
trace(...args)
dirxml(...args)
timeStamp(_label?: string)