Compare commits
2 Commits
gemini_v2
...
gemini_v2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
755003e203
|
|||
|
dc6714c3bf
|
195
index.html
195
index.html
@@ -4,12 +4,15 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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/dataTables.bootstrap5.min.css" rel="stylesheet">
|
||||
<script src="js/lucide.min.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>
|
||||
:root {
|
||||
@@ -18,8 +21,6 @@
|
||||
--bg-dark: #0f172a;
|
||||
--card-dark: #1e293b;
|
||||
--border-color: #334155;
|
||||
--selection-bg: rgba(74, 222, 128, 0.2);
|
||||
--selection-border: rgba(74, 222, 128, 0.5);
|
||||
}
|
||||
|
||||
body {
|
||||
@@ -91,34 +92,14 @@
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Chart Area with Selection Overlay */
|
||||
.chart-container {
|
||||
height: 160px;
|
||||
background: #0b0e14;
|
||||
padding: 10px 20px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
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 {
|
||||
border: none;
|
||||
font-size: 0.7rem;
|
||||
@@ -152,6 +133,7 @@
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Search Input Styling */
|
||||
.search-container {
|
||||
position: relative;
|
||||
width: 280px;
|
||||
@@ -186,6 +168,10 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
.clear-btn:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.content-area {
|
||||
flex-grow: 1;
|
||||
padding: 1rem;
|
||||
@@ -230,10 +216,10 @@
|
||||
<aside>
|
||||
<div class="sidebar-header">
|
||||
<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>
|
||||
<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>
|
||||
<input type="file" id="dir-input" webkitdirectory hidden>
|
||||
</div>
|
||||
@@ -254,9 +240,9 @@
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<div id="filter-info" class="small text-muted me-2" style="display:none">
|
||||
<span class="badge bg-secondary">Time Filtered</span>
|
||||
</div>
|
||||
<button class="btn btn-sm btn-outline-secondary" id="reset-chart-btn" title="Reset Chart Zoom">
|
||||
<i data-lucide="maximize" size="14"></i> Reset Chart
|
||||
</button>
|
||||
<div class="search-container">
|
||||
<i data-lucide="search" size="14" class="search-icon"></i>
|
||||
<input type="text" id="global-search" placeholder="Search... (RegEx enabled)">
|
||||
@@ -265,11 +251,8 @@
|
||||
</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>
|
||||
<svg id="selection-overlay" width="100%" height="100%">
|
||||
<rect class="selection-rect" x="0" y="0" width="0" height="100%"></rect>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div class="content-area">
|
||||
@@ -293,6 +276,10 @@
|
||||
<div class="modal fade" id="logModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-xl modal-dialog-centered">
|
||||
<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">
|
||||
<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>
|
||||
@@ -309,7 +296,8 @@
|
||||
<script>
|
||||
lucide.createIcons();
|
||||
let chart, table;
|
||||
let timeRange = { start: null, end: null };
|
||||
let rawLogs = [];
|
||||
let visibleTimeRange = { min: null, max: null };
|
||||
|
||||
$(document).ready(function () {
|
||||
table = $('#log-table').DataTable({
|
||||
@@ -326,30 +314,35 @@
|
||||
drawCallback: () => lucide.createIcons()
|
||||
});
|
||||
|
||||
// Global Search
|
||||
// Search Controls
|
||||
$('#global-search').on('keyup', function () {
|
||||
table.search(this.value, true, false).draw();
|
||||
$('#clear-search').toggle(this.value.length > 0);
|
||||
});
|
||||
|
||||
$('#clear-search').on('click', resetFilters);
|
||||
|
||||
function resetFilters() {
|
||||
$('#clear-search').on('click', function () {
|
||||
$('#global-search').val('').trigger('keyup');
|
||||
timeRange = { start: null, end: null };
|
||||
table.draw();
|
||||
$('#filter-info').hide();
|
||||
$('.selection-rect').hide();
|
||||
}
|
||||
chart.resetZoom();
|
||||
});
|
||||
|
||||
// Intensity Chart
|
||||
// Initialize Chart with Zoom Plugin
|
||||
const ctx = document.getElementById('intensityChart').getContext('2d');
|
||||
chart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: { labels: [], datasets: [{ label: 'Logs', data: [], backgroundColor: '#4ade80', barPercentage: 0.9, categoryPercentage: 0.9 }] },
|
||||
options: {
|
||||
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: {
|
||||
x: { ticks: { color: '#64748b', font: { size: 10 } }, grid: { display: false } },
|
||||
y: { beginAtZero: true, grid: { color: '#1e293b' }, ticks: { color: '#64748b', font: { size: 10 } } }
|
||||
@@ -357,78 +350,51 @@
|
||||
}
|
||||
});
|
||||
|
||||
// --- DRAG TO SELECT LOGIC ---
|
||||
let isDragging = false;
|
||||
let startX = 0;
|
||||
const $overlay = $('#selection-overlay');
|
||||
const $rect = $('.selection-rect');
|
||||
// Manual Zoom Controls
|
||||
$('#reset-chart-btn').on('click', () => chart.resetZoom());
|
||||
|
||||
$('#chart-parent').on('mousedown', function (e) {
|
||||
isDragging = true;
|
||||
startX = e.pageX - $overlay.offset().left;
|
||||
$rect.attr({ 'x': startX, 'width': 0 }).show();
|
||||
// Right Click on Canvas to Zoom Out
|
||||
document.getElementById('intensityChart').addEventListener('contextmenu', (e) => {
|
||||
e.preventDefault();
|
||||
chart.resetZoom();
|
||||
});
|
||||
|
||||
$(window).on('mousemove', function (e) {
|
||||
if (!isDragging) return;
|
||||
let currentX = e.pageX - $overlay.offset().left;
|
||||
let width = currentX - startX;
|
||||
if (width < 0) {
|
||||
$rect.attr('x', currentX).attr('width', Math.abs(width));
|
||||
} else {
|
||||
$rect.attr('width', width);
|
||||
}
|
||||
});
|
||||
function updateFiltersFromZoom(chartInstance) {
|
||||
const minIndex = Math.floor(chartInstance.scales.x.min);
|
||||
const maxIndex = Math.ceil(chartInstance.scales.x.max);
|
||||
const labels = chartInstance.data.labels;
|
||||
|
||||
$(window).on('mouseup', function (e) {
|
||||
if (!isDragging) return;
|
||||
isDragging = false;
|
||||
|
||||
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))];
|
||||
visibleTimeRange = {
|
||||
min: labels[Math.max(0, minIndex)],
|
||||
max: labels[Math.min(labels.length - 1, maxIndex)]
|
||||
};
|
||||
|
||||
timeRange.start = getValAtPixel(finalX);
|
||||
timeRange.end = getValAtPixel(finalX + finalWidth);
|
||||
// Update main level counters based on zoomed logs
|
||||
const filteredLogs = rawLogs.filter(l => {
|
||||
const time = l.time.substring(0, 5);
|
||||
return time >= visibleTimeRange.min && time <= visibleTimeRange.max;
|
||||
});
|
||||
|
||||
$('#filter-info').show();
|
||||
table.draw();
|
||||
});
|
||||
updateLevelCounts(filteredLogs);
|
||||
table.draw(); // Refresh table view based on global search + new time range
|
||||
}
|
||||
|
||||
// Right-click reset
|
||||
$('#chart-parent').on('contextmenu', e => { e.preventDefault(); resetFilters(); });
|
||||
|
||||
// Custom Table Filter (Time + Level)
|
||||
// Combined Filter (DataTable search + Level toggles + Zoom range)
|
||||
$.fn.dataTable.ext.search.push((settings, data, dataIndex) => {
|
||||
const lvl = data[1];
|
||||
const checked = $('.btn-check:checked').map((i, el) => $(el).val()).get();
|
||||
if (!checked.includes(lvl)) return false;
|
||||
|
||||
if (timeRange.start && timeRange.end) {
|
||||
const logTime = data[2].substring(0, 5); // HH:mm
|
||||
return logTime >= timeRange.start && logTime <= timeRange.end;
|
||||
if (visibleTimeRange.min && visibleTimeRange.max) {
|
||||
const logTime = data[2].substring(0, 5);
|
||||
return logTime >= visibleTimeRange.min && logTime <= visibleTimeRange.max;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$('.btn-check').on('change', () => table.draw());
|
||||
|
||||
// File loading
|
||||
// File/Directory logic
|
||||
$('#dir-input').on('change', function (e) {
|
||||
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>`));
|
||||
@@ -439,17 +405,28 @@
|
||||
$('.file-item').removeClass('active').eq(idx).addClass('active');
|
||||
const reader = new FileReader();
|
||||
reader.onload = e => {
|
||||
const logs = parseLogs(e.target.result);
|
||||
table.clear().rows.add(logs).draw();
|
||||
updateAnalytics(logs);
|
||||
resetFilters();
|
||||
rawLogs = parseLogs(e.target.result);
|
||||
table.clear().rows.add(rawLogs).draw();
|
||||
|
||||
// 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]);
|
||||
};
|
||||
|
||||
function parseLogs(text) {
|
||||
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 => {
|
||||
const match = line.match(regex);
|
||||
if (match) logs.push({ time: match[1], level: match[2], message: match[3], exception: "" });
|
||||
@@ -458,18 +435,10 @@
|
||||
return logs;
|
||||
}
|
||||
|
||||
function updateAnalytics(logs) {
|
||||
const counts = { INF: 0, WRN: 0, ERR: 0, CRT: 0 }, bins = {};
|
||||
logs.forEach(l => {
|
||||
if (counts[l.level] !== undefined) counts[l.level]++;
|
||||
const min = l.time.substring(0, 5);
|
||||
bins[min] = (bins[min] || 0) + 1;
|
||||
});
|
||||
function updateLevelCounts(logs) {
|
||||
const counts = { INF: 0, WRN: 0, ERR: 0, CRT: 0 };
|
||||
logs.forEach(l => { if (counts[l.level] !== undefined) counts[l.level]++; });
|
||||
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 () {
|
||||
|
||||
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