Compare commits
2 Commits
gemini_v2
...
gemini_v2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
755003e203
|
|||
|
dc6714c3bf
|
193
index.html
193
index.html
@@ -4,12 +4,15 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Log Viewer Pro // Timeline Brush</title>
|
<title>Log Viewer Pro // Zoom Edition</title>
|
||||||
|
|
||||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link href="css/dataTables.bootstrap5.min.css" rel="stylesheet">
|
<link href="css/dataTables.bootstrap5.min.css" rel="stylesheet">
|
||||||
<script src="js/lucide.min.js"></script>
|
<script src="js/lucide.min.js"></script>
|
||||||
|
|
||||||
<script src="js/chart.js"></script>
|
<script src="js/chart.js"></script>
|
||||||
|
<script src="js/hammer.min.js"></script>
|
||||||
|
<script src="js/chartjs-plugin-zoom.min.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
@@ -18,8 +21,6 @@
|
|||||||
--bg-dark: #0f172a;
|
--bg-dark: #0f172a;
|
||||||
--card-dark: #1e293b;
|
--card-dark: #1e293b;
|
||||||
--border-color: #334155;
|
--border-color: #334155;
|
||||||
--selection-bg: rgba(74, 222, 128, 0.2);
|
|
||||||
--selection-border: rgba(74, 222, 128, 0.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@@ -91,34 +92,14 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Chart Area with Selection Overlay */
|
|
||||||
.chart-container {
|
.chart-container {
|
||||||
height: 160px;
|
height: 160px;
|
||||||
background: #0b0e14;
|
background: #0b0e14;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
position: relative;
|
position: relative;
|
||||||
user-select: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#selection-overlay {
|
|
||||||
position: absolute;
|
|
||||||
top: 10px;
|
|
||||||
left: 20px;
|
|
||||||
right: 20px;
|
|
||||||
bottom: 10px;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selection-rect {
|
|
||||||
fill: var(--selection-bg);
|
|
||||||
stroke: var(--selection-border);
|
|
||||||
stroke-width: 1;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Toggles & Controls */
|
|
||||||
.level-toggles .btn {
|
.level-toggles .btn {
|
||||||
border: none;
|
border: none;
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
@@ -152,6 +133,7 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Search Input Styling */
|
||||||
.search-container {
|
.search-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 280px;
|
width: 280px;
|
||||||
@@ -186,6 +168,10 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clear-btn:hover {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
.content-area {
|
.content-area {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
@@ -230,10 +216,10 @@
|
|||||||
<aside>
|
<aside>
|
||||||
<div class="sidebar-header">
|
<div class="sidebar-header">
|
||||||
<h6 class="mb-3 d-flex align-items-center gap-2">
|
<h6 class="mb-3 d-flex align-items-center gap-2">
|
||||||
<i data-lucide="activity" class="text-success"></i> LogAnalytics
|
<i data-lucide="shield-check" class="text-success"></i> LogViewer Pro
|
||||||
</h6>
|
</h6>
|
||||||
<button class="btn btn-sm btn-outline-secondary w-100" onclick="$('#dir-input').click()">
|
<button class="btn btn-sm btn-outline-secondary w-100" onclick="$('#dir-input').click()">
|
||||||
<i data-lucide="folder" size="14"></i> Directory
|
<i data-lucide="folder" size="14"></i> Open Directory
|
||||||
</button>
|
</button>
|
||||||
<input type="file" id="dir-input" webkitdirectory hidden>
|
<input type="file" id="dir-input" webkitdirectory hidden>
|
||||||
</div>
|
</div>
|
||||||
@@ -254,9 +240,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex align-items-center gap-2">
|
<div class="d-flex align-items-center gap-2">
|
||||||
<div id="filter-info" class="small text-muted me-2" style="display:none">
|
<button class="btn btn-sm btn-outline-secondary" id="reset-chart-btn" title="Reset Chart Zoom">
|
||||||
<span class="badge bg-secondary">Time Filtered</span>
|
<i data-lucide="maximize" size="14"></i> Reset Chart
|
||||||
</div>
|
</button>
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<i data-lucide="search" size="14" class="search-icon"></i>
|
<i data-lucide="search" size="14" class="search-icon"></i>
|
||||||
<input type="text" id="global-search" placeholder="Search... (RegEx enabled)">
|
<input type="text" id="global-search" placeholder="Search... (RegEx enabled)">
|
||||||
@@ -265,11 +251,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="chart-container" id="chart-parent">
|
<div class="chart-container" id="chart-parent" title="Drag to Zoom | Right Click to Zoom Out">
|
||||||
<canvas id="intensityChart"></canvas>
|
<canvas id="intensityChart"></canvas>
|
||||||
<svg id="selection-overlay" width="100%" height="100%">
|
|
||||||
<rect class="selection-rect" x="0" y="0" width="0" height="100%"></rect>
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content-area">
|
<div class="content-area">
|
||||||
@@ -293,6 +276,10 @@
|
|||||||
<div class="modal fade" id="logModal" tabindex="-1">
|
<div class="modal fade" id="logModal" tabindex="-1">
|
||||||
<div class="modal-dialog modal-xl modal-dialog-centered">
|
<div class="modal-dialog modal-xl modal-dialog-centered">
|
||||||
<div class="modal-content bg-dark border-secondary">
|
<div class="modal-content bg-dark border-secondary">
|
||||||
|
<div class="modal-header py-2 border-secondary">
|
||||||
|
<h6 class="modal-title small">Log Context / Exception</h6>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||||
|
</div>
|
||||||
<div class="modal-body p-0">
|
<div class="modal-body p-0">
|
||||||
<pre id="modal-content" class="m-0 p-4 text-success-emphasis"
|
<pre id="modal-content" class="m-0 p-4 text-success-emphasis"
|
||||||
style="font-size: 0.75rem; background: #000; overflow-x: auto; font-family: 'Fira Code', monospace;"></pre>
|
style="font-size: 0.75rem; background: #000; overflow-x: auto; font-family: 'Fira Code', monospace;"></pre>
|
||||||
@@ -309,7 +296,8 @@
|
|||||||
<script>
|
<script>
|
||||||
lucide.createIcons();
|
lucide.createIcons();
|
||||||
let chart, table;
|
let chart, table;
|
||||||
let timeRange = { start: null, end: null };
|
let rawLogs = [];
|
||||||
|
let visibleTimeRange = { min: null, max: null };
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
table = $('#log-table').DataTable({
|
table = $('#log-table').DataTable({
|
||||||
@@ -326,30 +314,35 @@
|
|||||||
drawCallback: () => lucide.createIcons()
|
drawCallback: () => lucide.createIcons()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Global Search
|
// Search Controls
|
||||||
$('#global-search').on('keyup', function () {
|
$('#global-search').on('keyup', function () {
|
||||||
table.search(this.value, true, false).draw();
|
table.search(this.value, true, false).draw();
|
||||||
$('#clear-search').toggle(this.value.length > 0);
|
$('#clear-search').toggle(this.value.length > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#clear-search').on('click', resetFilters);
|
$('#clear-search').on('click', function () {
|
||||||
|
|
||||||
function resetFilters() {
|
|
||||||
$('#global-search').val('').trigger('keyup');
|
$('#global-search').val('').trigger('keyup');
|
||||||
timeRange = { start: null, end: null };
|
chart.resetZoom();
|
||||||
table.draw();
|
});
|
||||||
$('#filter-info').hide();
|
|
||||||
$('.selection-rect').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Intensity Chart
|
// Initialize Chart with Zoom Plugin
|
||||||
const ctx = document.getElementById('intensityChart').getContext('2d');
|
const ctx = document.getElementById('intensityChart').getContext('2d');
|
||||||
chart = new Chart(ctx, {
|
chart = new Chart(ctx, {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: { labels: [], datasets: [{ label: 'Logs', data: [], backgroundColor: '#4ade80', barPercentage: 0.9, categoryPercentage: 0.9 }] },
|
data: { labels: [], datasets: [{ label: 'Logs', data: [], backgroundColor: '#4ade80', barPercentage: 0.9, categoryPercentage: 0.9 }] },
|
||||||
options: {
|
options: {
|
||||||
responsive: true, maintainAspectRatio: false,
|
responsive: true, maintainAspectRatio: false,
|
||||||
plugins: { legend: { display: false }, tooltip: { enabled: true } },
|
plugins: {
|
||||||
|
legend: { display: false },
|
||||||
|
zoom: {
|
||||||
|
zoom: {
|
||||||
|
drag: { enabled: true, backgroundColor: 'rgba(74, 222, 128, 0.1)', borderColor: 'rgba(74, 222, 128, 0.4)', borderWidth: 1 },
|
||||||
|
mode: 'x',
|
||||||
|
onZoomComplete: ({ chart }) => updateFiltersFromZoom(chart)
|
||||||
|
},
|
||||||
|
pan: { enabled: true, mode: 'x', onPanComplete: ({ chart }) => updateFiltersFromZoom(chart) }
|
||||||
|
}
|
||||||
|
},
|
||||||
scales: {
|
scales: {
|
||||||
x: { ticks: { color: '#64748b', font: { size: 10 } }, grid: { display: false } },
|
x: { ticks: { color: '#64748b', font: { size: 10 } }, grid: { display: false } },
|
||||||
y: { beginAtZero: true, grid: { color: '#1e293b' }, ticks: { color: '#64748b', font: { size: 10 } } }
|
y: { beginAtZero: true, grid: { color: '#1e293b' }, ticks: { color: '#64748b', font: { size: 10 } } }
|
||||||
@@ -357,78 +350,51 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- DRAG TO SELECT LOGIC ---
|
// Manual Zoom Controls
|
||||||
let isDragging = false;
|
$('#reset-chart-btn').on('click', () => chart.resetZoom());
|
||||||
let startX = 0;
|
|
||||||
const $overlay = $('#selection-overlay');
|
|
||||||
const $rect = $('.selection-rect');
|
|
||||||
|
|
||||||
$('#chart-parent').on('mousedown', function (e) {
|
// Right Click on Canvas to Zoom Out
|
||||||
isDragging = true;
|
document.getElementById('intensityChart').addEventListener('contextmenu', (e) => {
|
||||||
startX = e.pageX - $overlay.offset().left;
|
e.preventDefault();
|
||||||
$rect.attr({ 'x': startX, 'width': 0 }).show();
|
chart.resetZoom();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('mousemove', function (e) {
|
function updateFiltersFromZoom(chartInstance) {
|
||||||
if (!isDragging) return;
|
const minIndex = Math.floor(chartInstance.scales.x.min);
|
||||||
let currentX = e.pageX - $overlay.offset().left;
|
const maxIndex = Math.ceil(chartInstance.scales.x.max);
|
||||||
let width = currentX - startX;
|
const labels = chartInstance.data.labels;
|
||||||
if (width < 0) {
|
|
||||||
$rect.attr('x', currentX).attr('width', Math.abs(width));
|
|
||||||
} else {
|
|
||||||
$rect.attr('width', width);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$(window).on('mouseup', function (e) {
|
visibleTimeRange = {
|
||||||
if (!isDragging) return;
|
min: labels[Math.max(0, minIndex)],
|
||||||
isDragging = false;
|
max: labels[Math.min(labels.length - 1, maxIndex)]
|
||||||
|
|
||||||
const finalX = parseInt($rect.attr('x'));
|
|
||||||
const finalWidth = parseInt($rect.attr('width'));
|
|
||||||
|
|
||||||
if (finalWidth < 5) { // If just a click
|
|
||||||
resetFilters();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map pixels to Chart labels
|
|
||||||
const labels = chart.data.labels;
|
|
||||||
const chartArea = chart.chartArea;
|
|
||||||
const scale = chart.scales.x;
|
|
||||||
|
|
||||||
const getValAtPixel = (px) => {
|
|
||||||
const decimal = scale.getValueForPixel(px);
|
|
||||||
const index = Math.round(decimal);
|
|
||||||
return labels[Math.max(0, Math.min(labels.length - 1, index))];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
timeRange.start = getValAtPixel(finalX);
|
// Update main level counters based on zoomed logs
|
||||||
timeRange.end = getValAtPixel(finalX + finalWidth);
|
const filteredLogs = rawLogs.filter(l => {
|
||||||
|
const time = l.time.substring(0, 5);
|
||||||
$('#filter-info').show();
|
return time >= visibleTimeRange.min && time <= visibleTimeRange.max;
|
||||||
table.draw();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Right-click reset
|
updateLevelCounts(filteredLogs);
|
||||||
$('#chart-parent').on('contextmenu', e => { e.preventDefault(); resetFilters(); });
|
table.draw(); // Refresh table view based on global search + new time range
|
||||||
|
}
|
||||||
|
|
||||||
// Custom Table Filter (Time + Level)
|
// Combined Filter (DataTable search + Level toggles + Zoom range)
|
||||||
$.fn.dataTable.ext.search.push((settings, data, dataIndex) => {
|
$.fn.dataTable.ext.search.push((settings, data, dataIndex) => {
|
||||||
const lvl = data[1];
|
const lvl = data[1];
|
||||||
const checked = $('.btn-check:checked').map((i, el) => $(el).val()).get();
|
const checked = $('.btn-check:checked').map((i, el) => $(el).val()).get();
|
||||||
if (!checked.includes(lvl)) return false;
|
if (!checked.includes(lvl)) return false;
|
||||||
|
|
||||||
if (timeRange.start && timeRange.end) {
|
if (visibleTimeRange.min && visibleTimeRange.max) {
|
||||||
const logTime = data[2].substring(0, 5); // HH:mm
|
const logTime = data[2].substring(0, 5);
|
||||||
return logTime >= timeRange.start && logTime <= timeRange.end;
|
return logTime >= visibleTimeRange.min && logTime <= visibleTimeRange.max;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn-check').on('change', () => table.draw());
|
$('.btn-check').on('change', () => table.draw());
|
||||||
|
|
||||||
// File loading
|
// File/Directory logic
|
||||||
$('#dir-input').on('change', function (e) {
|
$('#dir-input').on('change', function (e) {
|
||||||
const files = Array.from(e.target.files).filter(f => f.name.endsWith('.log'));
|
const files = Array.from(e.target.files).filter(f => f.name.endsWith('.log'));
|
||||||
$('#file-list').empty().append(files.map((f, i) => `<div class="file-item" onclick="loadLog(${i})"><span>${f.name}</span></div>`));
|
$('#file-list').empty().append(files.map((f, i) => `<div class="file-item" onclick="loadLog(${i})"><span>${f.name}</span></div>`));
|
||||||
@@ -439,17 +405,28 @@
|
|||||||
$('.file-item').removeClass('active').eq(idx).addClass('active');
|
$('.file-item').removeClass('active').eq(idx).addClass('active');
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = e => {
|
reader.onload = e => {
|
||||||
const logs = parseLogs(e.target.result);
|
rawLogs = parseLogs(e.target.result);
|
||||||
table.clear().rows.add(logs).draw();
|
table.clear().rows.add(rawLogs).draw();
|
||||||
updateAnalytics(logs);
|
|
||||||
resetFilters();
|
// Set initial chart data
|
||||||
|
const bins = {};
|
||||||
|
rawLogs.forEach(l => {
|
||||||
|
const min = l.time.substring(0, 5);
|
||||||
|
bins[min] = (bins[min] || 0) + 1;
|
||||||
|
});
|
||||||
|
const sortedLabels = Object.keys(bins).sort();
|
||||||
|
chart.data.labels = sortedLabels;
|
||||||
|
chart.data.datasets[0].data = sortedLabels.map(l => bins[l]);
|
||||||
|
|
||||||
|
chart.resetZoom();
|
||||||
|
updateLevelCounts(rawLogs);
|
||||||
};
|
};
|
||||||
reader.readAsText(window.loadedFiles[idx]);
|
reader.readAsText(window.loadedFiles[idx]);
|
||||||
};
|
};
|
||||||
|
|
||||||
function parseLogs(text) {
|
function parseLogs(text) {
|
||||||
const logs = [];
|
const logs = [];
|
||||||
const regex = /^(\d{2}:\d{2}:\d{2}\.\d{3})\s\[(TRC|DBG|INF|WRN|ERR|CRT)\]\s(.*)$/;
|
const regex = /^(\d{2}:\d{2}:\d{2}\.\d{3})\s\[(INF|WRN|ERR|CRT|DBG|TRC)\]\s(.*)$/;
|
||||||
text.split(/\r?\n/).forEach(line => {
|
text.split(/\r?\n/).forEach(line => {
|
||||||
const match = line.match(regex);
|
const match = line.match(regex);
|
||||||
if (match) logs.push({ time: match[1], level: match[2], message: match[3], exception: "" });
|
if (match) logs.push({ time: match[1], level: match[2], message: match[3], exception: "" });
|
||||||
@@ -458,18 +435,10 @@
|
|||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAnalytics(logs) {
|
function updateLevelCounts(logs) {
|
||||||
const counts = { INF: 0, WRN: 0, ERR: 0, CRT: 0 }, bins = {};
|
const counts = { INF: 0, WRN: 0, ERR: 0, CRT: 0 };
|
||||||
logs.forEach(l => {
|
logs.forEach(l => { if (counts[l.level] !== undefined) counts[l.level]++; });
|
||||||
if (counts[l.level] !== undefined) counts[l.level]++;
|
|
||||||
const min = l.time.substring(0, 5);
|
|
||||||
bins[min] = (bins[min] || 0) + 1;
|
|
||||||
});
|
|
||||||
Object.keys(counts).forEach(k => $(`#c-${k}`).text(counts[k].toLocaleString()));
|
Object.keys(counts).forEach(k => $(`#c-${k}`).text(counts[k].toLocaleString()));
|
||||||
const sortedLabels = Object.keys(bins).sort();
|
|
||||||
chart.data.labels = sortedLabels;
|
|
||||||
chart.data.datasets[0].data = sortedLabels.map(l => bins[l]);
|
|
||||||
chart.update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#log-table tbody').on('click', 'tr', function () {
|
$('#log-table tbody').on('click', 'tr', function () {
|
||||||
|
|||||||
7
js/chartjs-plugin-zoom.min.js
vendored
Normal file
7
js/chartjs-plugin-zoom.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
js/hammer.min.js
vendored
Normal file
7
js/hammer.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user