rev2.1
This commit is contained in:
372
index.html
372
index.html
@@ -4,12 +4,14 @@
|
|||||||
<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 // Grafana Style</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>
|
<script src="js/chartjs-plugin-zoom.min.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -35,7 +37,6 @@
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sidebar */
|
|
||||||
aside {
|
aside {
|
||||||
width: var(--sidebar-width);
|
width: var(--sidebar-width);
|
||||||
background: var(--card-dark);
|
background: var(--card-dark);
|
||||||
@@ -61,9 +62,8 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
font-size: 0.8rem;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
font-size: 0.75rem;
|
|
||||||
transition: 0.2s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-item:hover {
|
.file-item:hover {
|
||||||
@@ -73,9 +73,9 @@
|
|||||||
.file-item.active {
|
.file-item.active {
|
||||||
background: rgba(74, 222, 128, 0.15);
|
background: rgba(74, 222, 128, 0.15);
|
||||||
color: var(--brand-color);
|
color: var(--brand-color);
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main Content */
|
|
||||||
main {
|
main {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -90,63 +90,88 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
z-index: 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Chart Area - Styled like Grafana */
|
.chart-container {
|
||||||
.chart-section {
|
height: 160px;
|
||||||
height: 200px;
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chart-hint {
|
|
||||||
position: absolute;
|
|
||||||
top: 5px;
|
|
||||||
right: 20px;
|
|
||||||
font-size: 0.7rem;
|
|
||||||
color: #64748b;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Toggles */
|
|
||||||
.level-toggles .btn {
|
.level-toggles .btn {
|
||||||
border: none;
|
border: none;
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
padding: 4px 12px;
|
padding: 4px 10px;
|
||||||
margin-right: 4px;
|
margin-right: 3px;
|
||||||
border-radius: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-check:not(:checked)+.btn {
|
.btn-check:not(:checked)+.btn {
|
||||||
opacity: 0.15;
|
opacity: 0.2;
|
||||||
filter: grayscale(1);
|
filter: grayscale(0.8);
|
||||||
}
|
|
||||||
|
|
||||||
.btn-dbg {
|
|
||||||
background: #38bdf8;
|
|
||||||
color: #000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-inf {
|
.btn-inf {
|
||||||
background: #4ade80;
|
background: #10b981;
|
||||||
color: #000;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-wrn {
|
.btn-wrn {
|
||||||
background: #fbbf24;
|
background: #f59e0b;
|
||||||
color: #000;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-err {
|
.btn-err {
|
||||||
background: #f87171;
|
background: #ef4444;
|
||||||
color: #000;
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-crt {
|
||||||
|
background: #a855f7;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Search Input Styling */
|
||||||
|
.search-container {
|
||||||
|
position: relative;
|
||||||
|
width: 280px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-container input {
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
color: white;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 4px 30px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon {
|
||||||
|
position: absolute;
|
||||||
|
left: 8px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 8px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
color: #64748b;
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-btn:hover {
|
||||||
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Table */
|
|
||||||
.content-area {
|
.content-area {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
@@ -155,33 +180,32 @@
|
|||||||
|
|
||||||
.table-container {
|
.table-container {
|
||||||
background: var(--card-dark);
|
background: var(--card-dark);
|
||||||
border-radius: 6px;
|
border-radius: 8px;
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
table.dataTable thead th {
|
table.dataTable thead th {
|
||||||
background: #111827;
|
background: rgba(255, 255, 255, 0.02);
|
||||||
font-size: 0.7rem;
|
font-size: 0.65rem;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 0.5px;
|
padding: 10px 15px !important;
|
||||||
color: #94a3b8;
|
|
||||||
border-bottom: 1px solid var(--border-color) !important;
|
border-bottom: 1px solid var(--border-color) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-input {
|
.lvl-indicator {
|
||||||
background: #0f172a;
|
width: 8px;
|
||||||
border: 1px solid var(--border-color);
|
height: 8px;
|
||||||
color: white;
|
border-radius: 50%;
|
||||||
border-radius: 4px;
|
display: inline-block;
|
||||||
padding: 4px 12px;
|
margin-right: 8px;
|
||||||
font-size: 0.8rem;
|
|
||||||
width: 280px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.range-info {
|
.row-INF .lvl-indicator {
|
||||||
font-size: 0.75rem;
|
background: #10b981;
|
||||||
color: var(--brand-color);
|
}
|
||||||
font-weight: 600;
|
|
||||||
|
.row-ERR .lvl-indicator {
|
||||||
|
background: #ef4444;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@@ -190,13 +214,12 @@
|
|||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<aside>
|
<aside>
|
||||||
<div class="sidebar-header text-center">
|
<div class="sidebar-header">
|
||||||
<h6 class="mb-3 d-flex align-items-center justify-content-center gap-2">
|
<h6 class="mb-3 d-flex align-items-center gap-2">
|
||||||
<i data-lucide="bar-chart-3" class="text-success"></i> LOG EXPLORER
|
<i data-lucide="shield-check" class="text-success"></i> LogViewer Pro
|
||||||
</h6>
|
</h6>
|
||||||
<button class="btn btn-sm btn-outline-primary w-100 mb-2"
|
<button class="btn btn-sm btn-outline-secondary w-100" onclick="$('#dir-input').click()">
|
||||||
onclick="document.getElementById('dir-input').click()">
|
<i data-lucide="folder" size="14"></i> Open Directory
|
||||||
<i data-lucide="plus" size="14"></i> Select Project Folder
|
|
||||||
</button>
|
</button>
|
||||||
<input type="file" id="dir-input" webkitdirectory hidden>
|
<input type="file" id="dir-input" webkitdirectory hidden>
|
||||||
</div>
|
</div>
|
||||||
@@ -206,40 +229,41 @@
|
|||||||
<main>
|
<main>
|
||||||
<div class="top-bar">
|
<div class="top-bar">
|
||||||
<div class="level-toggles">
|
<div class="level-toggles">
|
||||||
<input type="checkbox" class="btn-check" id="toggle-DBG" checked value="DBG">
|
<input type="checkbox" class="btn-check" id="t-INF" checked value="INF">
|
||||||
<label class="btn btn-dbg" for="toggle-DBG">DBG</label>
|
<label class="btn btn-inf" for="t-INF">INF <span id="c-INF">0</span></label>
|
||||||
<input type="checkbox" class="btn-check" id="toggle-INF" checked value="INF">
|
<input type="checkbox" class="btn-check" id="t-WRN" checked value="WRN">
|
||||||
<label class="btn btn-inf" for="toggle-INF">INF</label>
|
<label class="btn btn-wrn" for="t-WRN">WRN <span id="c-WRN">0</span></label>
|
||||||
<input type="checkbox" class="btn-check" id="toggle-WRN" checked value="WRN">
|
<input type="checkbox" class="btn-check" id="t-ERR" checked value="ERR">
|
||||||
<label class="btn btn-wrn" for="toggle-WRN">WRN</label>
|
<label class="btn btn-err" for="t-ERR">ERR <span id="c-ERR">0</span></label>
|
||||||
<input type="checkbox" class="btn-check" id="toggle-ERR" checked value="ERR">
|
<input type="checkbox" class="btn-check" id="t-CRT" checked value="CRT">
|
||||||
<label class="btn btn-err" for="toggle-ERR">ERR</label>
|
<label class="btn btn-crt" for="t-CRT">CRT <span id="c-CRT">0</span></label>
|
||||||
<span id="range-display" class="range-info ms-3"></span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex align-items-center gap-2">
|
<div class="d-flex align-items-center gap-2">
|
||||||
<input type="text" id="global-search" class="search-input" placeholder="Regex Search...">
|
<button class="btn btn-sm btn-outline-secondary" id="reset-chart-btn" title="Reset Chart Zoom">
|
||||||
<button class="btn btn-sm btn-dark border-secondary" id="reset-all" title="Reset Range & Filters">
|
<i data-lucide="maximize" size="14"></i> Reset Chart
|
||||||
<i data-lucide="refresh-cw" size="14"></i>
|
|
||||||
</button>
|
</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)">
|
||||||
|
<button id="clear-search" class="clear-btn"><i data-lucide="x" size="14"></i></button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="chart-section">
|
<div class="chart-container" id="chart-parent" title="Drag to Zoom | Right Click to Zoom Out">
|
||||||
<span class="chart-hint"><i data-lucide="mouse-pointer-2" size="10"></i> Drag to select time
|
|
||||||
range</span>
|
|
||||||
<canvas id="intensityChart"></canvas>
|
<canvas id="intensityChart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content-area">
|
<div class="content-area">
|
||||||
<div class="table-container shadow-lg">
|
<div class="table-container shadow">
|
||||||
<table id="log-table" class="table table-dark table-hover table-sm w-100">
|
<table id="log-table" class="table table-dark table-hover table-sm w-100">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="30"></th>
|
<th width="35"></th>
|
||||||
<th width="80">Level</th>
|
<th width="90">Level</th>
|
||||||
<th width="120">Time</th>
|
<th width="130">Time</th>
|
||||||
<th>Description</th>
|
<th>Message</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
@@ -249,6 +273,21 @@
|
|||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="js/jquery-3.7.0.min.js"></script>
|
<script src="js/jquery-3.7.0.min.js"></script>
|
||||||
<script src="js/jquery.dataTables.min.js"></script>
|
<script src="js/jquery.dataTables.min.js"></script>
|
||||||
<script src="js/dataTables.bootstrap5.min.js"></script>
|
<script src="js/dataTables.bootstrap5.min.js"></script>
|
||||||
@@ -256,95 +295,109 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
lucide.createIcons();
|
lucide.createIcons();
|
||||||
let chart;
|
let chart, table;
|
||||||
let selectedTimeRange = null; // {start: 'HH:mm', end: 'HH:mm'}
|
let rawLogs = [];
|
||||||
|
let visibleTimeRange = { min: null, max: null };
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
const table = $('#log-table').DataTable({
|
table = $('#log-table').DataTable({
|
||||||
dom: 'rtip',
|
dom: 'rtip',
|
||||||
pageLength: 50,
|
pageLength: 50,
|
||||||
order: [[2, 'desc']],
|
order: [[2, 'desc']],
|
||||||
columns: [
|
columns: [
|
||||||
{ data: null, orderable: false, render: () => `<i data-lucide="more-horizontal" size="14" style="opacity:0.3"></i>` },
|
{ className: 'text-center opacity-50', orderable: false, data: null, defaultContent: '<i data-lucide="eye" size="14"></i>' },
|
||||||
{
|
{ data: 'level', render: l => `<span class="lvl-indicator"></span><strong>${l}</strong>` },
|
||||||
data: 'level',
|
{ data: 'time', className: 'text-muted' },
|
||||||
render: l => `<span class="badge w-100 btn-${l.toLowerCase()}">${l}</span>`
|
{ data: 'message', render: m => `<span class="text-truncate d-block" style="max-width: 900px;">${m}</span>` }
|
||||||
},
|
|
||||||
{ data: 'time' },
|
|
||||||
{ data: 'message', render: m => `<span class="text-truncate d-block" style="max-width: 900px">${m}</span>` }
|
|
||||||
],
|
],
|
||||||
|
createdRow: (row, data) => $(row).addClass('row-' + data.level),
|
||||||
drawCallback: () => lucide.createIcons()
|
drawCallback: () => lucide.createIcons()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Chart.js Configuration
|
// 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', function () {
|
||||||
|
$('#global-search').val('').trigger('keyup');
|
||||||
|
chart.resetZoom();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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: [{ data: [], backgroundColor: '#4ade80', borderRadius: 2, barPercentage: 0.8 }] },
|
data: { labels: [], datasets: [{ label: 'Logs', data: [], backgroundColor: '#4ade80', barPercentage: 0.9, categoryPercentage: 0.9 }] },
|
||||||
options: {
|
options: {
|
||||||
responsive: true,
|
responsive: true, maintainAspectRatio: false,
|
||||||
maintainAspectRatio: false,
|
|
||||||
scales: {
|
|
||||||
x: { ticks: { color: '#64748b', font: { size: 10 } }, grid: { display: false } },
|
|
||||||
y: { beginAtZero: true, ticks: { color: '#475569' }, grid: { color: '#1e293b' } }
|
|
||||||
},
|
|
||||||
plugins: {
|
plugins: {
|
||||||
legend: { display: false },
|
legend: { display: false },
|
||||||
zoom: {
|
zoom: {
|
||||||
zoom: {
|
zoom: {
|
||||||
drag: { enabled: true, backgroundColor: 'rgba(74, 222, 128, 0.2)', borderColor: '#4ade80', borderWidth: 1 },
|
drag: { enabled: true, backgroundColor: 'rgba(74, 222, 128, 0.1)', borderColor: 'rgba(74, 222, 128, 0.4)', borderWidth: 1 },
|
||||||
mode: 'x',
|
mode: 'x',
|
||||||
onZoomComplete: ({ chart }) => {
|
onZoomComplete: ({ chart }) => updateFiltersFromZoom(chart)
|
||||||
const { min, max } = chart.scales.x;
|
},
|
||||||
const labels = chart.data.labels;
|
pan: { enabled: true, mode: 'x', onPanComplete: ({ chart }) => updateFiltersFromZoom(chart) }
|
||||||
const start = labels[Math.max(0, Math.floor(min))];
|
|
||||||
const end = labels[Math.min(labels.length - 1, Math.ceil(max))];
|
|
||||||
|
|
||||||
selectedTimeRange = { start, end };
|
|
||||||
$('#range-display').text(`Range: ${start} - ${end}`);
|
|
||||||
table.draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
x: { ticks: { color: '#64748b', font: { size: 10 } }, grid: { display: false } },
|
||||||
|
y: { beginAtZero: true, grid: { color: '#1e293b' }, ticks: { color: '#64748b', font: { size: 10 } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Custom Table Filter for Levels + Time Range
|
// Manual Zoom Controls
|
||||||
$.fn.dataTable.ext.search.push((settings, data, dataIndex) => {
|
$('#reset-chart-btn').on('click', () => chart.resetZoom());
|
||||||
const level = data[1];
|
|
||||||
const timeStr = data[2]; // HH:mm:ss.SSS
|
|
||||||
const timeShort = timeStr.substring(0, 5); // HH:mm
|
|
||||||
|
|
||||||
// 1. Filter by Level
|
// Right Click on Canvas to Zoom Out
|
||||||
const checkedLevels = $('.btn-check:checked').map((i, el) => $(el).val()).get();
|
document.getElementById('intensityChart').addEventListener('contextmenu', (e) => {
|
||||||
if (!checkedLevels.includes(level)) return false;
|
e.preventDefault();
|
||||||
|
|
||||||
// 2. Filter by Time Range (if zoomed)
|
|
||||||
if (selectedTimeRange) {
|
|
||||||
return timeShort >= selectedTimeRange.start && timeShort <= selectedTimeRange.end;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Search & Reset
|
|
||||||
$('#global-search').on('keyup', function () { table.search(this.value, true, false).draw(); });
|
|
||||||
$('#reset-all').on('click', () => {
|
|
||||||
chart.resetZoom();
|
chart.resetZoom();
|
||||||
selectedTimeRange = null;
|
});
|
||||||
$('#range-display').text('');
|
|
||||||
$('#global-search').val('');
|
function updateFiltersFromZoom(chartInstance) {
|
||||||
table.search('').draw();
|
const minIndex = Math.floor(chartInstance.scales.x.min);
|
||||||
|
const maxIndex = Math.ceil(chartInstance.scales.x.max);
|
||||||
|
const labels = chartInstance.data.labels;
|
||||||
|
|
||||||
|
visibleTimeRange = {
|
||||||
|
min: labels[Math.max(0, minIndex)],
|
||||||
|
max: labels[Math.min(labels.length - 1, maxIndex)]
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
});
|
||||||
|
|
||||||
|
updateLevelCounts(filteredLogs);
|
||||||
|
table.draw(); // Refresh table view based on global search + new time range
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (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());
|
$('.btn-check').on('change', () => table.draw());
|
||||||
|
|
||||||
// File/Directory 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'));
|
||||||
const list = $('#file-list').empty();
|
$('#file-list').empty().append(files.map((f, i) => `<div class="file-item" onclick="loadLog(${i})"><span>${f.name}</span></div>`));
|
||||||
files.forEach((f, i) => list.append(`<div class="file-item" onclick="loadLog(${i})"><span>${f.name}</span></div>`));
|
|
||||||
window.loadedFiles = files;
|
window.loadedFiles = files;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -352,36 +405,47 @@
|
|||||||
$('.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();
|
||||||
updateChart(logs);
|
|
||||||
|
// 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 lines = text.split(/\r?\n/);
|
|
||||||
const logs = [];
|
const logs = [];
|
||||||
const regex = /^(\d{2}:\d{2}:\d{2}\.\d{3})\s\[(\w+)\]\s(.*)$/;
|
const regex = /^(\d{2}:\d{2}:\d{2}\.\d{3})\s\[(INF|WRN|ERR|CRT|DBG|TRC)\]\s(.*)$/;
|
||||||
lines.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] });
|
if (match) logs.push({ time: match[1], level: match[2], message: match[3], exception: "" });
|
||||||
|
else if (logs.length > 0) logs[logs.length - 1].exception += line + "\n";
|
||||||
});
|
});
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateChart(logs) {
|
function updateLevelCounts(logs) {
|
||||||
const 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]++; });
|
||||||
const m = l.time.substring(0, 5);
|
Object.keys(counts).forEach(k => $(`#c-${k}`).text(counts[k].toLocaleString()));
|
||||||
bins[m] = (bins[m] || 0) + 1;
|
|
||||||
});
|
|
||||||
const labels = Object.keys(bins).sort();
|
|
||||||
chart.data.labels = labels;
|
|
||||||
chart.data.datasets[0].data = labels.map(l => bins[l]);
|
|
||||||
chart.resetZoom();
|
|
||||||
chart.update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#log-table tbody').on('click', 'tr', function () {
|
||||||
|
const data = table.row(this).data();
|
||||||
|
$('#modal-content').text(`[TIME] ${data.time}\n[LVL] ${data.level}\n\n${data.message}\n\n${data.exception}`);
|
||||||
|
new bootstrap.Modal('#logModal').show();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
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