Alokai

installConsoleBridge

Routes the runtime's raw console.error/console.warn output - framework SSR/render errors (which Next.js/Nitro print via console.error) and third-party library output - through logger, so each call becomes a single structured (GCP JSON in production) entry instead of a multi-line util.inspect dump that log collectors cannot parse. Empty/whitespace-only output (blank spacing lines) is dropped on every patched method so it does not become empty log entries.

The bridge is safe against the logger's own reporter (which itself writes via console.error): re-entrant output is passed straight to the native console, output that is already a structured logger line is passed through untouched, and any failure inside the bridge falls back to the native console.

Signature

declare function installConsoleBridge(
	logger: LoggerInterface,
	options?: InstallConsoleBridgeOptions
): ConsoleBridge;

Parameters

NameRequiredTypeDescription
loggerRequiredLoggerInterface
optionsOptionalInstallConsoleBridgeOptions

Referenced Types

On this page