VirtualConsolePrinter buffers console logs, destructively drains on read/readAsString calls, filters by log level, formats group indentation and collapsed group suppression, dispatches lifecycle events, and is exposed on Window via happyDOM.virtualConsolePrinter.
VirtualConsolePrinter buffers console logs, destructively drains on read/readAsString calls, filters by log level, formats group indentation and collapsed group suppression, dispatches lifecycle events, and is exposed on Window via happyDOM.virtualConsolePrinter. HOW
readAsString() and read() inspect captured virtual console logs non-destructively without clearing the internal buffer until an explicit clear() invocation.
VirtualConsolePrinter.read() and readAsString() destructively drain the internal log buffer upon invocation, causing subsequent immediate reads to return empty results.
readAsString(minLogLevel) filters formatted output by severity while draining all log entries from the buffer regardless of level.
console.group() indents log entries by two spaces with a ▼ prefix, whereas console.groupCollapsed() suppresses nested entries from readAsString() with a ▶ prefix.
addEventListener dispatches synchronous 'print' and 'clear' events on log and clear operations, rejecting unsupported event names.
close() marks the printer as closed, flushes buffered entries and listeners, and causes subsequent print and event calls to be ignored.
Window instances expose the page VirtualConsolePrinter through window.happyDOM.virtualConsolePrinter.