During high-pressure incidents, log lines collected from multiple services, containers, and gateways often arrive out of order and in mixed timestamp formats. This zero-dependency client-side tool parses raw logs locally in the browser, normalizes timestamps, classifies severity levels, reconstructs the exact chronological sequence, and flags notable time gaps above 30 seconds.
// Resource exhaustion guardrails (checked prior to regex parsing & O(n log n) sort)
const MAX_LOG_SIZE = 5 * 1024 * 1024; // 5 MB
const MAX_LINES = 50000;
const MAX_LINE_LENGTH = 4096;
if (rawInput.length > MAX_LOG_SIZE || lines.length > MAX_LINES) {
throw new Error('Input exceeds the maximum supported size.');
}
// Chronological sort & >30s stall detection; rendered strictly via textContent (XSS-safe)
events.sort((a, b) => a.time - b.time);
const msgNode = document.createElement('span');
msgNode.textContent = ev.message;