Compare commits
2 Commits
main
..
712bceccbe
| Author | SHA1 | Date | |
|---|---|---|---|
|
712bceccbe
|
|||
|
d2bf90ccec
|
+287
-269
@@ -4,238 +4,255 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Log Viewer Pro // Dark Mode</title>
|
||||
<title>Log Analytics Dashboard</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>
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--bg-color: #0f111a;
|
||||
--card-bg: #1a1c27;
|
||||
--border-color: #2d303e;
|
||||
--accent-color: #3d5afe;
|
||||
--sidebar-width: 260px;
|
||||
--brand-color: #4ade80;
|
||||
--bg-dark: #0f172a;
|
||||
--card-dark: #1e293b;
|
||||
--border-color: #334155;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-color);
|
||||
color: #e0e0e0;
|
||||
font-family: 'Inter', -apple-system, sans-serif;
|
||||
background-color: var(--bg-dark);
|
||||
color: #f1f5f9;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 0.85rem;
|
||||
overflow-x: hidden;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Full Screen Drop Zone */
|
||||
#drop-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(61, 90, 254, 0.9);
|
||||
z-index: 9999;
|
||||
display: none;
|
||||
.wrapper {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
aside {
|
||||
width: var(--sidebar-width);
|
||||
background: var(--card-dark);
|
||||
border-right: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 4px dashed #fff;
|
||||
color: white;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Sleek Table Design */
|
||||
.main-container {
|
||||
padding: 1.5rem;
|
||||
max-width: 1600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
.sidebar-header {
|
||||
padding: 1rem;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
table.dataTable {
|
||||
border: none !important;
|
||||
.file-list {
|
||||
overflow-y: auto;
|
||||
flex-grow: 1;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.file-item {
|
||||
padding: 8px 12px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 2px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.file-item:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.file-item.active {
|
||||
background: rgba(74, 222, 128, 0.15);
|
||||
color: var(--brand-color);
|
||||
}
|
||||
|
||||
/* Main Content */
|
||||
main {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.top-bar {
|
||||
padding: 0.75rem 1.5rem;
|
||||
background: var(--card-dark);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Chart Area */
|
||||
.chart-container {
|
||||
height: 180px;
|
||||
background: #111827;
|
||||
padding: 10px 20px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
/* Stats & Toggles */
|
||||
.level-toggles .btn {
|
||||
border: none;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
padding: 4px 10px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.btn-check:not(:checked)+.btn {
|
||||
opacity: 0.2;
|
||||
filter: grayscale(1);
|
||||
}
|
||||
|
||||
.btn-dbg {
|
||||
background: #0ea5e9;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-inf {
|
||||
background: #10b981;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-wrn {
|
||||
background: #f59e0b;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-err {
|
||||
background: #ef4444;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Table */
|
||||
.content-area {
|
||||
flex-grow: 1;
|
||||
padding: 1.25rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
background: var(--card-dark);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
table.dataTable thead th {
|
||||
background: #242736;
|
||||
text-transform: uppercase;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
font-size: 0.7rem;
|
||||
letter-spacing: 1px;
|
||||
text-transform: uppercase;
|
||||
padding: 10px 15px !important;
|
||||
border-bottom: 1px solid var(--border-color) !important;
|
||||
}
|
||||
|
||||
/* Level Badges */
|
||||
.lvl-badge {
|
||||
font-weight: 700;
|
||||
font-size: 0.7rem;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
.lvl-indicator {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
min-width: 40px;
|
||||
text-align: center;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.lvl-TRC {
|
||||
background: #424242;
|
||||
color: #bdbdbd;
|
||||
.row-INF .lvl-indicator {
|
||||
background: #10b981;
|
||||
}
|
||||
|
||||
.lvl-DBG {
|
||||
background: #1e3a8a;
|
||||
color: #93c5fd;
|
||||
.row-ERR .lvl-indicator {
|
||||
background: #ef4444;
|
||||
}
|
||||
|
||||
.lvl-INF {
|
||||
background: #064e3b;
|
||||
color: #6ee7b7;
|
||||
.row-DBG .lvl-indicator {
|
||||
background: #0ea5e9;
|
||||
}
|
||||
|
||||
.lvl-WRN {
|
||||
background: #78350f;
|
||||
color: #fcd34d;
|
||||
.row-WRN .lvl-indicator {
|
||||
background: #f59e0b;
|
||||
}
|
||||
|
||||
.lvl-ERR {
|
||||
background: #7f1d1d;
|
||||
color: #fca5a5;
|
||||
}
|
||||
|
||||
.lvl-CRT {
|
||||
background: #ec4899;
|
||||
color: white;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.4);
|
||||
}
|
||||
|
||||
70% {
|
||||
box-shadow: 0 0 0 10px rgba(236, 72, 153, 0);
|
||||
}
|
||||
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 rgba(236, 72, 153, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Controls */
|
||||
.details-control {
|
||||
cursor: pointer;
|
||||
color: var(--accent-color);
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.details-control:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
.exception-view {
|
||||
background: #000;
|
||||
color: #ff5555;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
font-family: 'Fira Code', monospace;
|
||||
font-size: 0.75rem;
|
||||
margin: 0.5rem 0;
|
||||
border-left: 3px solid #7f1d1d;
|
||||
}
|
||||
|
||||
/* Search Bar Customization */
|
||||
.dataTables_filter input {
|
||||
background: #242736;
|
||||
.search-input {
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
padding: 6px 12px;
|
||||
width: 300px !important;
|
||||
}
|
||||
|
||||
.btn-more {
|
||||
color: var(--accent-color);
|
||||
cursor: pointer;
|
||||
font-size: 0.75rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.props-col {
|
||||
color: #888;
|
||||
font-family: monospace;
|
||||
font-size: 0.75rem;
|
||||
border-radius: 4px;
|
||||
padding: 4px 10px;
|
||||
font-size: 0.8rem;
|
||||
width: 250px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="drop-overlay">
|
||||
<i data-lucide="upload-cloud" size="64"></i>
|
||||
<h2 class="mt-3">Drop Log File to Import</h2>
|
||||
</div>
|
||||
|
||||
<div class="main-container">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="mb-0 fw-bold"><i data-lucide="terminal" class="me-2 text-primary"></i>LogView <span
|
||||
class="text-primary">Pro</span></h4>
|
||||
<p class="text-muted small mb-0">v3.0 • Dark Mode Enabled</p>
|
||||
<div class="wrapper">
|
||||
<aside>
|
||||
<div class="sidebar-header">
|
||||
<h6 class="mb-3"><i data-lucide="activity" class="text-success me-2"></i>LogViewer Pro</h6>
|
||||
<button class="btn btn-sm btn-outline-secondary w-100"
|
||||
onclick="document.getElementById('dir-input').click()">
|
||||
<i data-lucide="folder" size="14"></i> Load Directory
|
||||
</button>
|
||||
<input type="file" id="dir-input" webkitdirectory hidden>
|
||||
</div>
|
||||
<button class="btn btn-outline-primary btn-sm" onclick="document.getElementById('file-input').click()">
|
||||
<i data-lucide="file-plus" class="me-1"></i> Open File
|
||||
</button>
|
||||
<input type="file" id="file-input" hidden accept=".log,.txt">
|
||||
</header>
|
||||
<div class="file-list" id="file-list"></div>
|
||||
</aside>
|
||||
|
||||
<div class="table-card">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<select id="level-filter" class="form-select form-select-sm bg-dark border-secondary"
|
||||
style="width: 150px;">
|
||||
<option value="">All Levels</option>
|
||||
<option value="CRT">CRT (Critical)</option>
|
||||
<option value="ERR">ERR (Error)</option>
|
||||
<option value="WRN">WRN (Warning)</option>
|
||||
<option value="INF">INF (Info)</option>
|
||||
<option value="DBG">DBG (Debug)</option>
|
||||
<option value="TRC">TRC (Trace)</option>
|
||||
</select>
|
||||
<div id="stats-area" class="small text-muted"></div>
|
||||
<main>
|
||||
<div class="top-bar">
|
||||
<div class="level-toggles" id="filter-buttons">
|
||||
<input type="checkbox" class="btn-check" id="toggle-DBG" checked value="DBG">
|
||||
<label class="btn btn-dbg" for="toggle-DBG">DBG <span id="count-DBG">0</span></label>
|
||||
<input type="checkbox" class="btn-check" id="toggle-INF" checked value="INF">
|
||||
<label class="btn btn-inf" for="toggle-INF">INF <span id="count-INF">0</span></label>
|
||||
<input type="checkbox" class="btn-check" id="toggle-WRN" checked value="WRN">
|
||||
<label class="btn btn-wrn" for="toggle-WRN">WRN <span id="count-WRN">0</span></label>
|
||||
<input type="checkbox" class="btn-check" id="toggle-ERR" checked value="ERR">
|
||||
<label class="btn btn-err" for="toggle-ERR">ERR <span id="count-ERR">0</span></label>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-3">
|
||||
<input type="text" id="global-search" class="search-input" placeholder="Search RegEx...">
|
||||
<button class="btn btn-link text-white p-0" id="reset-filter" title="Reset Filters">
|
||||
<i data-lucide="rotate-ccw" size="18"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="log-table" class="table table-dark table-hover w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="30"></th>
|
||||
<th width="120">Timestamp</th>
|
||||
<th width="80">Level</th>
|
||||
<th>Message</th>
|
||||
<th width="300">Properties</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="chart-container">
|
||||
<canvas id="intensityChart"></canvas>
|
||||
</div>
|
||||
|
||||
<div class="content-area">
|
||||
<div class="table-container">
|
||||
<table id="log-table" class="table table-dark table-hover table-sm w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="30"></th>
|
||||
<th width="90">Level</th>
|
||||
<th width="120">Time</th>
|
||||
<th>Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="logModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg modal-dialog-centered">
|
||||
<div class="modal-content border-secondary shadow-lg">
|
||||
<div class="modal-header border-secondary">
|
||||
<h6 class="modal-title">Log Message Detail</h6>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-dialog modal-xl modal-dialog-centered">
|
||||
<div class="modal-content bg-dark border-secondary">
|
||||
<div class="modal-body p-0">
|
||||
<pre id="modal-body-content" class="m-0 p-3"
|
||||
style="background:#000; color:#fff; font-size:0.8rem;"></pre>
|
||||
<pre id="modal-content" class="m-0 p-4 text-info"
|
||||
style="font-size: 0.8rem; background: #000;"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -248,139 +265,140 @@
|
||||
|
||||
<script>
|
||||
lucide.createIcons();
|
||||
const TRUNCATE_LIMIT = 150;
|
||||
let chart;
|
||||
let rawData = [];
|
||||
|
||||
$(document).ready(function () {
|
||||
const table = $('#log-table').DataTable({
|
||||
dom: '<"d-flex justify-content-between align-items-center mb-2"f>rtip',
|
||||
pageLength: 50,
|
||||
dom: 'rtip',
|
||||
pageLength: 100,
|
||||
order: [[2, 'desc']],
|
||||
columns: [
|
||||
{
|
||||
className: 'details-control',
|
||||
className: 'text-center opacity-50',
|
||||
orderable: false,
|
||||
data: null,
|
||||
render: (d, t, row) => row.exception ? '<i data-lucide="chevron-right" size="16"></i>' : ''
|
||||
render: (d, t, row) => row.exception ? '<i data-lucide="plus-square" size="14"></i>' : ''
|
||||
},
|
||||
{ data: 'time', className: 'text-muted' },
|
||||
{
|
||||
data: 'level',
|
||||
render: l => `<span class="lvl-badge lvl-${l}">${l}</span>`
|
||||
render: l => `<span class="lvl-indicator"></span><strong>${l}</strong>`
|
||||
},
|
||||
{ data: 'time' },
|
||||
{
|
||||
data: 'message',
|
||||
render: function (data) {
|
||||
if (data.length > TRUNCATE_LIMIT) {
|
||||
return `<span>${data.substring(0, TRUNCATE_LIMIT)}</span><a class="btn-more ms-1" onclick="viewMore('${btoa(unescape(encodeURIComponent(data)))}')">...more</a>`;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'props',
|
||||
className: 'props-col',
|
||||
render: p => p ? `<span title="${p} text-truncate d-block" style="max-width:280px">${p}</span>` : ''
|
||||
render: m => `<span class="text-truncate d-block" style="max-width: 900px;">${m}</span>`
|
||||
}
|
||||
],
|
||||
order: [[1, 'asc']],
|
||||
drawCallback: function () { lucide.createIcons(); },
|
||||
language: { search: "", searchPlaceholder: "Filter logs..." }
|
||||
createdRow: (row, data) => $(row).addClass('row-' + data.level),
|
||||
drawCallback: () => lucide.createIcons()
|
||||
});
|
||||
|
||||
// Expandable Exception Rows
|
||||
$('#log-table tbody').on('click', 'td.details-control', function () {
|
||||
let tr = $(this).closest('tr'), row = table.row(tr);
|
||||
if (row.child.isShown()) {
|
||||
row.child.hide();
|
||||
$(this).html('<i data-lucide="chevron-right" size="16"></i>');
|
||||
} else if (row.data().exception) {
|
||||
row.child(`<div class="exception-view">${row.data().exception}</div>`).show();
|
||||
$(this).html('<i data-lucide="chevron-down" class="text-danger" size="16"></i>');
|
||||
// Search & Reset
|
||||
$('#global-search').on('keyup', function () { table.search(this.value, true, false).draw(); });
|
||||
$('#reset-filter').on('click', () => {
|
||||
$('#global-search').val('');
|
||||
table.search('').column(2).search('').draw();
|
||||
});
|
||||
|
||||
// Initialize Chart.js
|
||||
const ctx = document.getElementById('intensityChart').getContext('2d');
|
||||
chart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: { labels: [], datasets: [{ label: 'Logs', data: [], backgroundColor: '#4ade80' }] },
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: { legend: { display: false }, tooltip: { mode: 'index', intersect: false } },
|
||||
scales: {
|
||||
x: { ticks: { color: '#64748b', font: { size: 10 } }, grid: { display: false } },
|
||||
y: { beginAtZero: true, grid: { color: '#334155' }, ticks: { color: '#64748b' } }
|
||||
},
|
||||
onClick: (e, activeEls) => {
|
||||
if (activeEls.length > 0) {
|
||||
const index = activeEls[0].index;
|
||||
const label = chart.data.labels[index];
|
||||
// Filter table by the HH:mm from the chart
|
||||
table.column(2).search('^' + label, true, false).draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
lucide.createIcons();
|
||||
});
|
||||
|
||||
// Level Filter
|
||||
$('#level-filter').on('change', function () {
|
||||
table.column(2).search(this.value ? `^${this.value}$` : '', true, false).draw();
|
||||
// Level Toggles
|
||||
$('.btn-check').on('change', () => table.draw());
|
||||
$.fn.dataTable.ext.search.push((settings, data, dataIndex) => {
|
||||
const level = data[1];
|
||||
const checked = $('.btn-check:checked').map((i, el) => $(el).val()).get();
|
||||
return checked.includes(level);
|
||||
});
|
||||
|
||||
// --- FULL SCREEN DRAG & DROP ---
|
||||
let dragCounter = 0;
|
||||
window.addEventListener('dragenter', e => {
|
||||
e.preventDefault();
|
||||
dragCounter++;
|
||||
$('#drop-overlay').css('display', 'flex');
|
||||
// Directory Handler
|
||||
$('#dir-input').on('change', function (e) {
|
||||
const files = Array.from(e.target.files).filter(f => f.name.endsWith('.log'));
|
||||
const list = $('#file-list').empty();
|
||||
files.forEach((file, idx) => {
|
||||
list.append(`<div class="file-item" onclick="loadLog(${idx})"><span>${file.name}</span></div>`);
|
||||
});
|
||||
window.loadedFiles = files;
|
||||
});
|
||||
|
||||
window.addEventListener('dragleave', e => {
|
||||
dragCounter--;
|
||||
if (dragCounter === 0) $('#drop-overlay').hide();
|
||||
});
|
||||
|
||||
window.addEventListener('dragover', e => e.preventDefault());
|
||||
|
||||
window.addEventListener('drop', e => {
|
||||
e.preventDefault();
|
||||
dragCounter = 0;
|
||||
$('#drop-overlay').hide();
|
||||
processFile(e.dataTransfer.files[0]);
|
||||
});
|
||||
|
||||
$('#file-input').on('change', e => processFile(e.target.files[0]));
|
||||
|
||||
function processFile(file) {
|
||||
if (!file) return;
|
||||
window.loadLog = function (idx) {
|
||||
$('.file-item').removeClass('active').eq(idx).addClass('active');
|
||||
const reader = new FileReader();
|
||||
reader.onload = e => {
|
||||
reader.onload = function (e) {
|
||||
const logs = parseLogs(e.target.result);
|
||||
rawData = logs;
|
||||
table.clear().rows.add(logs).draw();
|
||||
updateStats(logs);
|
||||
updateChart(logs);
|
||||
updateCounts(logs);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
reader.readAsText(window.loadedFiles[idx]);
|
||||
};
|
||||
|
||||
function parseLogs(text) {
|
||||
const lines = text.split(/\r?\n/);
|
||||
const results = [];
|
||||
// Support 6 levels: TRC, DBG, WRN, INF, ERR, CRT
|
||||
const headerRegex = /^(\d{2}:\d{2}:\d{2}\.\d{3})\s\[(TRC|DBG|WRN|INF|ERR|CRT)\]\s(.*)$/;
|
||||
const logs = [];
|
||||
const headerRegex = /^(\d{2}:\d{2}:\d{2}\.\d{3})\s\[(\w+)\]\s(.*)$/;
|
||||
|
||||
lines.forEach(line => {
|
||||
if (!line.trim()) return;
|
||||
const match = line.match(headerRegex);
|
||||
|
||||
if (match) {
|
||||
let content = match[3].trim();
|
||||
let message = content, props = "";
|
||||
|
||||
// Parse props at the end: (key: value)
|
||||
const lastParenIdx = content.lastIndexOf(' (');
|
||||
if (lastParenIdx !== -1 && content.endsWith(')')) {
|
||||
const possibleProps = content.substring(lastParenIdx + 2, content.length - 1);
|
||||
if (possibleProps.includes(':')) {
|
||||
props = possibleProps;
|
||||
message = content.substring(0, lastParenIdx).trim();
|
||||
}
|
||||
}
|
||||
results.push({ time: match[1], level: match[2], message, props, exception: "" });
|
||||
} else if (results.length > 0) {
|
||||
results[results.length - 1].exception += (results[results.length - 1].exception ? "\n" : "") + line;
|
||||
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 results;
|
||||
return logs;
|
||||
}
|
||||
|
||||
function updateStats(logs) {
|
||||
const count = logs.length;
|
||||
const errs = logs.filter(l => l.level === 'ERR' || l.level === 'CRT').length;
|
||||
$('#stats-area').html(`<span class="me-3">${count} total logs</span> <span class="text-danger">${errs} errors/criticals</span>`);
|
||||
function updateChart(logs) {
|
||||
// Bin logs by Minute (HH:mm)
|
||||
const bins = {};
|
||||
logs.forEach(l => {
|
||||
const min = l.time.substring(0, 5); // Get HH:mm
|
||||
bins[min] = (bins[min] || 0) + 1;
|
||||
});
|
||||
|
||||
const labels = Object.keys(bins).sort();
|
||||
const data = labels.map(l => bins[l]);
|
||||
|
||||
chart.data.labels = labels;
|
||||
chart.data.datasets[0].data = data;
|
||||
chart.update();
|
||||
}
|
||||
|
||||
window.viewMore = function (encoded) {
|
||||
const text = decodeURIComponent(escape(atob(encoded)));
|
||||
$('#modal-body-content').text(text);
|
||||
function updateCounts(logs) {
|
||||
const counts = { DBG: 0, INF: 0, WRN: 0, ERR: 0 };
|
||||
logs.forEach(l => { if (counts[l.level] !== undefined) counts[l.level]++; });
|
||||
Object.keys(counts).forEach(lvl => $(`#count-${lvl}`).text(counts[lvl]));
|
||||
}
|
||||
|
||||
$('#log-table tbody').on('click', 'tr', function () {
|
||||
const data = table.row(this).data();
|
||||
$('#modal-content').text(`[${data.time}] [${data.level}] ${data.message}\n\n${data.exception}`);
|
||||
new bootstrap.Modal('#logModal').show();
|
||||
};
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
+14
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user