| 869 | const consoleMethods = ['log', 'info', 'warn', 'error', 'debug'] |
| 870 | const origConsoleMethods = {} |
| 871 | const captureLog = level => (...args) => { |
| 872 | if (consoleLogs.length >= MAX_LOG_ENTRIES) return |
| 873 | const message = args.map(a => { |
| 874 | if (typeof a === 'string') return a |
| 875 | return truncateString(safeStringify(a, [], 2), MAX_LOG_MSG_BYTES).value |
| 876 | }).join(' ') |
| 877 | consoleLogs.push({ level, message, t: Date.now() - startedAt }) |
| 878 | } |
| 879 | for (const m of consoleMethods) { |
| 880 | origConsoleMethods[m] = console[m] |
| 881 | console[m] = captureLog(m) |
no test coverage detected