Below is a single-page HTML app that meets your requirements. It uses SVG for rendering the waterfall view, regex for parsing the log data, and provides zoom functionality. The app also includes a text area for displaying comma-delimited results.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Log File Waterfall View</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
#logInput {
width: 100%;
height: 200px;
margin-bottom: 20px;
}
#waterfall {
border: 1px solid #ccc;
margin-bottom: 20px;
overflow: auto;
}
#results {
width: 100%;
height: 100px;
}
.transaction {
fill: #4CAF50;
stroke: #000;
stroke-width: 1;
cursor: pointer;
}
.transaction:hover {
fill: #45a049;
}
.tooltip {
position: absolute;
background: #fff;
border: 1px solid #000;
padding: 5px;
pointer-events: none;
display: none;
}
</style>
</head>
<body>
<h1>Log File Waterfall View</h1>
<textarea id="logInput" placeholder="Paste your log file here..."></textarea>
<button onclick="parseLog()">Parse Log</button>
<div id="waterfall"></div>
<textarea id="results" placeholder="Comma-delimited results will appear here..." readonly></textarea>
<script>
let svg, tooltip, zoomLevel = 1, transactions = [];
function initSVG() {
svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("width", "100%");
svg.setAttribute("height", "500");
document.getElementById("waterfall").innerHTML = "";
document.getElementById("waterfall").appendChild(svg);
tooltip = document.createElement("div");
tooltip.className = "tooltip";
document.body.appendChild(tooltip);
}
function parseLog() {
const log = document.getElementById("logInput").value;
const lines = log.split("\n");
const regex = /(\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}:\d{3}) - .* \| PID: (\d+) - TID: (\d+) - (?:FUNCTION )?(.*)/;
const finishRegex = /- FINISH - PROC-TIME: (\d+) \/ SIZE: (\d+)/;
const startTimeMap = new Map();
const results = [];
transactions = [];
lines.forEach(line => {
const match = line.match(regex);
if (match) {
const [, startTime, pid, tid, details] = match;
if (details.includes("STARTED")) {
startTimeMap.set(`${pid}-${tid}`, { startTime, line });
} else if (details.includes("FINISH")) {
const finishMatch = line.match(finishRegex);
if (finishMatch) {
const [, procTime, size] = finishMatch;
const key = `${pid}-${tid}`;
if (startTimeMap.has(key)) {
const { startTime: start, line: startLine } = startTimeMap.get(key);
const taskNumber = startLine.match(/FUNCTION ProcessTrans (\d+)/);
transactions.push({
pid,
tid,
taskNumber: taskNumber ? taskNumber[1] : "N/A",
startTime: new Date(start).getTime(),
endTime: new Date(startTime).getTime(),
elapsedTime: procTime,
size,
});
results.push(`${pid},${tid},${taskNumber ? taskNumber[1] : "N/A"},${start},${startTime},${procTime},${size}`);
startTimeMap.delete(key);
}
}
}
}
});
document.getElementById("results").value = results.join("\n");
renderWaterfall();
}
function renderWaterfall() {
initSVG();
const viewBoxHeight = transactions.length * 50;
svg.setAttribute("viewBox", `0 0 ${svg.clientWidth} ${viewBoxHeight}`);
transactions.forEach((tx, index) => {
const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rect.setAttribute("x", (tx.startTime / 1000) * zoomLevel);
rect.setAttribute("y", index * 50);
rect.setAttribute("width", (tx.elapsedTime / 1000) * zoomLevel);
rect.setAttribute("height", 40);
rect.setAttribute("class", "transaction");
rect.addEventListener("mouseover", (e) => {
tooltip.style.display = "block";
tooltip.style.left = `${e.pageX + 10}px`;
tooltip.style.top = `${e.pageY + 10}px`;
tooltip.innerHTML = `PID: ${tx.pid}<br>TID: ${tx.tid}<br>Task: ${tx.taskNumber}<br>Start: ${new Date(tx.startTime).toISOString()}<br>End: ${new Date(tx.endTime).toISOString()}<br>Elapsed: ${tx.elapsedTime}ms<br>Size: ${tx.size} bytes`;
});
rect.addEventListener("mouseout", () => {
tooltip.style.display = "none";
});
svg.appendChild(rect);
});
}
document.getElementById("waterfall").addEventListener("wheel", (e) => {
e.preventDefault();
zoomLevel += e.deltaY * -0.01;
zoomLevel = Math.max(0.1, Math.min(zoomLevel, 2));
renderWaterfall();
});
</script>
</body>
</html>