(
loggedErrorHandler,
{ shouldResetForDebugging= false}= {})
| 6591 | |
| 6592 | /** @type {MakeLoggingConsoleKit} */$h_once.consoleWhitelist(consoleWhitelist); |
| 6593 | const makeLoggingConsoleKit= ( |
| 6594 | loggedErrorHandler, |
| 6595 | { shouldResetForDebugging= false}= {})=> |
| 6596 | { |
| 6597 | if( shouldResetForDebugging) { |
| 6598 | // eslint-disable-next-line @endo/no-polymorphic-call |
| 6599 | loggedErrorHandler.resetErrorTagNum(); |
| 6600 | } |
| 6601 | |
| 6602 | // Not frozen! |
| 6603 | let logArray= []; |
| 6604 | |
| 6605 | const loggingConsole= fromEntries( |
| 6606 | arrayMap(consoleWhitelist, ([name, _])=> { |
| 6607 | // Use an arrow function so that it doesn't come with its own name in |
| 6608 | // its printed form. Instead, we're hoping that tooling uses only |
| 6609 | // the `.name` property set below. |
| 6610 | /** |
| 6611 | * @param {...any} args |
| 6612 | */ |
| 6613 | const method= (...args)=> { |
| 6614 | arrayPush(logArray, [name, ...args]); |
| 6615 | }; |
| 6616 | defineProperty(method, 'name', { value: name}); |
| 6617 | return [name, freeze(method)]; |
| 6618 | })); |
| 6619 | |
| 6620 | freeze(loggingConsole); |
| 6621 | |
| 6622 | const takeLog= ()=> { |
| 6623 | const result= freeze(logArray); |
| 6624 | logArray= []; |
| 6625 | return result; |
| 6626 | }; |
| 6627 | freeze(takeLog); |
| 6628 | |
| 6629 | const typedLoggingConsole= /** @type {VirtualConsole} */ loggingConsole; |
| 6630 | |
| 6631 | return freeze({ loggingConsole: typedLoggingConsole, takeLog}); |
| 6632 | };$h_once.makeLoggingConsoleKit(makeLoggingConsoleKit); |
| 6633 | freeze(makeLoggingConsoleKit); |
| 6634 | |
| 6635 |
nothing calls this directly
no test coverage detected