()
| 19983 | }; |
| 19984 | } |
| 19985 | |
| 19986 | function updateConsole(logs) { |
| 19987 | if (!logs || !Array.isArray(logs)) { |
| 19988 | // If no logs available, add informational messages |
| 19989 | if (consoleBuffer.length === 0) { |
| 19990 | addConsoleMessage('No historical logs available', 'warning'); |
| 19991 | addConsoleMessage('New activity will appear here as it occurs', 'info'); |
| 19992 | } |
| 19993 | return; |
| 19994 | } |
| 19995 | |
| 19996 | // If logs are empty array, provide user feedback |
| 19997 | if (logs.length === 0) { |
| 19998 | if (consoleBuffer.length === 0) { |
| 19999 | addConsoleMessage('No recent activity logged', 'info'); |
| 20000 | addConsoleMessage('Waiting for new events...', 'info'); |
| 20001 | } |
| 20002 | return; |
| 20003 | } |
| 20004 | |
| 20005 | const cleanedLogs = logs |
| 20006 | .map(log => typeof log === 'string' ? log.trim() : '') |
| 20007 | .filter(log => log && !shouldHideConsoleLog(log)); |
| 20008 | |
| 20009 | if (cleanedLogs.length === 0) { |
| 20010 | return; |
| 20011 | } |
| 20012 | |
| 20013 | let newLogLines = []; |
| 20014 | if (!lastConsoleLogLine) { |
| 20015 | consoleBuffer = []; |
| 20016 | newLogLines = cleanedLogs.slice(-MAX_CONSOLE_LINES); |
| 20017 | } else { |
| 20018 | const lastIndex = cleanedLogs.lastIndexOf(lastConsoleLogLine); |
| 20019 | if (lastIndex === cleanedLogs.length - 1) { |
| 20020 | lastConsoleLogLine = cleanedLogs[cleanedLogs.length - 1]; |
| 20021 | return; |
| 20022 | } |
| 20023 | if (lastIndex !== -1) { |
| 20024 | newLogLines = cleanedLogs.slice(lastIndex + 1); |
| 20025 | } else { |
nothing calls this directly
no test coverage detected