Skip to main content

patchConsole

@webda/workout


Function: patchConsole()

patchConsole(output?): () => void

Defined in: packages/workout/src/consolepatch.ts:33

Route console.log|info|warn|error|debug|trace to the WorkerOutput as logs

Stray console calls (from the application or third-party code) then get the logger's formatting, level filtering and stream instead of writing straight to stdout. A call made while a log is being emitted — a logger writing through console — goes to the original method, so the patch cannot loop.

Calling it while already patched does nothing and returns a no-op restore.

Parameters​

output?​

WorkerOutput

the output to log to (default: the global WorkerOutput, resolved on each call)

Returns​

a function restoring the original console methods

() => void