rev2
This commit is contained in:
184
index.html
184
index.html
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Compact Log Parser</title>
|
||||
<title>Advanced Log Parser</title>
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css/dataTables.bootstrap5.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
@@ -12,17 +12,18 @@
|
||||
body {
|
||||
background-color: #f4f7f6;
|
||||
font-size: 0.85rem;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#drop-zone {
|
||||
border: 2px dashed #0d6efd;
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: 0.2s;
|
||||
margin-bottom: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#drop-zone:hover {
|
||||
@@ -31,14 +32,15 @@
|
||||
|
||||
.table-container {
|
||||
background: #fff;
|
||||
padding: 15px;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
/* Level Colors */
|
||||
/* Badges */
|
||||
.badge-ERR {
|
||||
background-color: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.badge-INF {
|
||||
@@ -48,13 +50,15 @@
|
||||
|
||||
.badge-DBG {
|
||||
background-color: #6c757d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.badge-TRC {
|
||||
background-color: #6610f2;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Row styling */
|
||||
/* Detail Rows */
|
||||
td.details-control {
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
@@ -65,59 +69,68 @@
|
||||
.exception-box {
|
||||
background: #fff5f5;
|
||||
border-left: 4px solid #dc3545;
|
||||
padding: 10px;
|
||||
font-family: monospace;
|
||||
padding: 12px;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 0.8rem;
|
||||
white-space: pre-wrap;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.clickable-text {
|
||||
color: #0d6efd;
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.props-cell {
|
||||
max-width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 0.75rem;
|
||||
color: #666;
|
||||
/* Search styling */
|
||||
.dataTables_filter input {
|
||||
border-radius: 20px;
|
||||
padding: 5px 15px;
|
||||
border: 1px solid #ddd;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.dataTables_filter input:focus {
|
||||
border-color: #0d6efd;
|
||||
box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, .15);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container-fluid py-3">
|
||||
<div class="container-fluid">
|
||||
<div id="drop-zone" onclick="document.getElementById('file-input').click()">
|
||||
<strong><i class="bi bi-cloud-arrow-up"></i> Drop Log File Here</strong> or Click to Browse
|
||||
<h3><i class="bi bi-file-earmark-text"></i> Drag & Drop Log File</h3>
|
||||
<p class="text-muted mb-0">The parser now supports inconsistent log formats and multi-line errors.</p>
|
||||
<input type="file" id="file-input" hidden accept=".log,.txt">
|
||||
</div>
|
||||
|
||||
<div class="table-container">
|
||||
<div class="d-flex gap-3 mb-3">
|
||||
<div style="width: 200px;">
|
||||
<div class="row g-3 mb-4 align-items-end">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label fw-bold small text-uppercase">Filter Level</label>
|
||||
<select id="level-filter" class="form-select form-select-sm">
|
||||
<option value="">All Levels</option>
|
||||
<option value="INF">INF</option>
|
||||
<option value="ERR">ERR</option>
|
||||
<option value="DBG">DBG</option>
|
||||
<option value="TRC">TRC</option>
|
||||
<option value="">Show All Levels</option>
|
||||
<option value="INF">INF (Info)</option>
|
||||
<option value="ERR">ERR (Error)</option>
|
||||
<option value="DBG">DBG (Debug)</option>
|
||||
<option value="TRC">TRC (Trace)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="log-table" class="table table-sm table-hover w-100" style="border-top: 1px solid #dee2e6;">
|
||||
<table id="log-table" class="table table-sm table-hover w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="30"></th>
|
||||
<th width="100">Time</th>
|
||||
<th width="110">Time</th>
|
||||
<th width="70">Level</th>
|
||||
<th width="50">Tag</th>
|
||||
<th width="50">ID</th>
|
||||
<th width="70">Tag</th>
|
||||
<th>Message</th>
|
||||
<th>Properties</th>
|
||||
<th>Props</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
@@ -126,15 +139,15 @@
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="logModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Full Log Detail</h5>
|
||||
<h6 class="modal-title fw-bold">Full Log Content</h6>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="modal-body p-0">
|
||||
<div id="modal-content-text"
|
||||
style="white-space: pre-wrap; font-family: monospace; background: #f8f9fa; padding: 15px; border-radius: 5px;">
|
||||
style="white-space: pre-wrap; font-family: monospace; background: #212529; color: #f8f9fa; padding: 20px; margin: 0; min-height: 200px;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -148,81 +161,73 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
const MAX_MSG_LEN = 80;
|
||||
|
||||
// DataTable Formatting Function for Child Row (Exceptions)
|
||||
function format(d) {
|
||||
if (!d.exception) return null;
|
||||
return `<div class="exception-box"><strong>Stack Trace:</strong><br>${d.exception}</div>`;
|
||||
}
|
||||
const MAX_LEN = 100;
|
||||
|
||||
// DataTable setup
|
||||
let table = $('#log-table').DataTable({
|
||||
// 'f' adds the search filter box
|
||||
dom: '<"d-flex justify-content-between align-items-center mb-3"lf>rtip',
|
||||
columns: [
|
||||
{
|
||||
className: 'details-control',
|
||||
orderable: false,
|
||||
data: null,
|
||||
defaultContent: '',
|
||||
render: function (data, type, row) {
|
||||
return row.exception ? '<i class="bi bi-plus-square"></i>' : '';
|
||||
}
|
||||
render: (data, type, row) => row.exception ? '<i class="bi bi-plus-circle-fill"></i>' : ''
|
||||
},
|
||||
{ data: 'time' },
|
||||
{
|
||||
data: 'level',
|
||||
render: l => `<span class="badge badge-${l}">${l}</span>`
|
||||
},
|
||||
{ data: 'id' },
|
||||
{ data: 'tag' },
|
||||
{
|
||||
data: 'message',
|
||||
render: function (data, type, row) {
|
||||
if (data.length > MAX_MSG_LEN) {
|
||||
return `${data.substr(0, MAX_MSG_LEN)}... <span class="clickable-text show-full" data-full="${btoa(unescape(encodeURIComponent(data)))}">[more]</span>`;
|
||||
render: (data) => {
|
||||
if (data.length > MAX_LEN) {
|
||||
return `${data.substr(0, MAX_LEN)}... <span class="clickable-text show-full" data-full="${btoa(unescape(encodeURIComponent(data)))}">[view more]</span>`;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'props',
|
||||
className: 'props-cell',
|
||||
render: p => p ? `<span title="${p}">${p}</span>` : ''
|
||||
render: p => `<span class="text-muted small" title="${p}">${p}</span>`
|
||||
}
|
||||
],
|
||||
order: [[1, 'asc']],
|
||||
dom: 'ltipr'
|
||||
language: { search: "", searchPlaceholder: "Search any log..." }
|
||||
});
|
||||
|
||||
// Handle Click to Expand (Exception)
|
||||
// Expand Exceptions
|
||||
$('#log-table tbody').on('click', 'td.details-control', function () {
|
||||
let tr = $(this).closest('tr');
|
||||
let row = table.row(tr);
|
||||
|
||||
let tr = $(this).closest('tr'), row = table.row(tr);
|
||||
if (row.child.isShown()) {
|
||||
row.child.hide();
|
||||
$(this).html('<i class="bi bi-plus-square"></i>');
|
||||
$(this).html('<i class="bi bi-plus-circle-fill"></i>');
|
||||
} else if (row.data().exception) {
|
||||
row.child(format(row.data())).show();
|
||||
$(this).html('<i class="bi bi-dash-square text-danger"></i>');
|
||||
row.child(`<div class="exception-box">${row.data().exception}</div>`).show();
|
||||
$(this).html('<i class="bi bi-dash-circle-fill text-danger"></i>');
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Click for Full Modal
|
||||
// Full Content Modal
|
||||
$('#log-table tbody').on('click', '.show-full', function () {
|
||||
const fullText = decodeURIComponent(escape(atob($(this).data('full'))));
|
||||
$('#modal-content-text').text(fullText);
|
||||
new bootstrap.Modal('#logModal').show();
|
||||
});
|
||||
|
||||
// Filtering logic
|
||||
$('#level-filter').on('change', function () {
|
||||
table.column(2).search(this.value).draw();
|
||||
});
|
||||
// Filters
|
||||
$('#level-filter').on('change', function () { table.column(2).search(this.value).draw(); });
|
||||
|
||||
// Drag & Drop / File Input
|
||||
// File Input
|
||||
$('#file-input').on('change', e => handleFile(e.target.files[0]));
|
||||
$('#drop-zone').on('dragover', e => { e.preventDefault(); $(this).addClass('bg-light'); });
|
||||
$('#drop-zone').on('dragover', e => { e.preventDefault(); $('#drop-zone').css('background', '#f0f7ff'); });
|
||||
$('#drop-zone').on('dragleave', e => { $('#drop-zone').css('background', '#fff'); });
|
||||
$('#drop-zone').on('drop', e => {
|
||||
e.preventDefault();
|
||||
$('#drop-zone').css('background', '#fff');
|
||||
handleFile(e.originalEvent.dataTransfer.files[0]);
|
||||
});
|
||||
|
||||
@@ -239,31 +244,43 @@
|
||||
function parseLogs(text) {
|
||||
const lines = text.split(/\r?\n/);
|
||||
const logs = [];
|
||||
const headerRegex = /^(\d{2}:\d{2}:\d{2}\.\d{3})\s\[(\w+)\]\s(\d+)\s\|\s\((.*?)\)\s(.*)$/;
|
||||
|
||||
// Revised Regex: Just gets Time, Level, and the rest.
|
||||
const baseRegex = /^(\d{2}:\d{2}:\d{2}\.\d{3})\s\[(\w+)\]\s(.*)$/;
|
||||
// Secondary regex to see if the "rest" starts with the ID | (Tag) pattern
|
||||
const metaRegex = /^(\d+)\s\|\s\((.*?)\)\s(.*)$/;
|
||||
|
||||
lines.forEach(line => {
|
||||
if (!line.trim()) return;
|
||||
const match = line.match(headerRegex);
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) return;
|
||||
|
||||
if (match) {
|
||||
let msg = match[5];
|
||||
let props = "";
|
||||
const propMatch = msg.match(/\((idtask:.*)\)$/);
|
||||
if (propMatch) {
|
||||
props = propMatch[1];
|
||||
msg = msg.replace(propMatch[0], "").trim();
|
||||
const baseMatch = line.match(baseRegex);
|
||||
|
||||
if (baseMatch) {
|
||||
let time = baseMatch[1];
|
||||
let level = baseMatch[2];
|
||||
let content = baseMatch[3];
|
||||
|
||||
let id = "", tag = "", message = content, props = "";
|
||||
|
||||
// Check if this line has the "ID | (TAG)" format
|
||||
const metaMatch = content.match(metaRegex);
|
||||
if (metaMatch) {
|
||||
id = metaMatch[1];
|
||||
tag = metaMatch[2];
|
||||
message = metaMatch[3];
|
||||
}
|
||||
|
||||
logs.push({
|
||||
time: match[1],
|
||||
level: match[2],
|
||||
tag: match[4],
|
||||
message: msg,
|
||||
props: props,
|
||||
exception: ""
|
||||
});
|
||||
// Extract Props if they exist at the end (idtask: 123)
|
||||
const propMatch = message.match(/\(([^)]+:[^)]+)\)$/);
|
||||
if (propMatch) {
|
||||
props = propMatch[1];
|
||||
message = message.replace(propMatch[0], "").trim();
|
||||
}
|
||||
|
||||
logs.push({ time, level, id, tag, message, props, exception: "" });
|
||||
} else {
|
||||
// It's a stack trace / exception line
|
||||
// If it's not a header line, it's an exception/stack trace
|
||||
if (logs.length > 0) {
|
||||
logs[logs.length - 1].exception += line + "\n";
|
||||
}
|
||||
@@ -273,7 +290,6 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user