279 lines
9.5 KiB
HTML
279 lines
9.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Compact 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">
|
|
<style>
|
|
body {
|
|
background-color: #f4f7f6;
|
|
font-size: 0.85rem;
|
|
}
|
|
|
|
#drop-zone {
|
|
border: 2px dashed #0d6efd;
|
|
background: #fff;
|
|
padding: 20px;
|
|
text-align: center;
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
transition: 0.2s;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
#drop-zone:hover {
|
|
background: #f0f7ff;
|
|
}
|
|
|
|
.table-container {
|
|
background: #fff;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
/* Level Colors */
|
|
.badge-ERR {
|
|
background-color: #dc3545;
|
|
}
|
|
|
|
.badge-INF {
|
|
background-color: #0dcaf0;
|
|
color: #000;
|
|
}
|
|
|
|
.badge-DBG {
|
|
background-color: #6c757d;
|
|
}
|
|
|
|
.badge-TRC {
|
|
background-color: #6610f2;
|
|
}
|
|
|
|
/* Row styling */
|
|
td.details-control {
|
|
cursor: pointer;
|
|
text-align: center;
|
|
color: #0d6efd;
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
.exception-box {
|
|
background: #fff5f5;
|
|
border-left: 4px solid #dc3545;
|
|
padding: 10px;
|
|
font-family: monospace;
|
|
font-size: 0.8rem;
|
|
white-space: pre-wrap;
|
|
}
|
|
|
|
.clickable-text {
|
|
color: #0d6efd;
|
|
cursor: pointer;
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.props-cell {
|
|
max-width: 200px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
font-size: 0.75rem;
|
|
color: #666;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container-fluid py-3">
|
|
<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
|
|
<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;">
|
|
<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>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<table id="log-table" class="table table-sm table-hover w-100" style="border-top: 1px solid #dee2e6;">
|
|
<thead>
|
|
<tr>
|
|
<th width="30"></th>
|
|
<th width="100">Time</th>
|
|
<th width="70">Level</th>
|
|
<th width="50">Tag</th>
|
|
<th>Message</th>
|
|
<th>Properties</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="logModal" tabindex="-1">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Full Log Detail</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div id="modal-content-text"
|
|
style="white-space: pre-wrap; font-family: monospace; background: #f8f9fa; padding: 15px; border-radius: 5px;">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="js/jquery-3.7.0.min.js"></script>
|
|
<script src="js/jquery.dataTables.min.js"></script>
|
|
<script src="js/dataTables.bootstrap5.min.js"></script>
|
|
<script src="js/bootstrap.bundle.min.js"></script>
|
|
|
|
<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>`;
|
|
}
|
|
|
|
let table = $('#log-table').DataTable({
|
|
columns: [
|
|
{
|
|
className: 'details-control',
|
|
orderable: false,
|
|
data: null,
|
|
defaultContent: '',
|
|
render: function (data, type, row) {
|
|
return row.exception ? '<i class="bi bi-plus-square"></i>' : '';
|
|
}
|
|
},
|
|
{ data: 'time' },
|
|
{
|
|
data: 'level',
|
|
render: l => `<span class="badge badge-${l}">${l}</span>`
|
|
},
|
|
{ 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>`;
|
|
}
|
|
return data;
|
|
}
|
|
},
|
|
{
|
|
data: 'props',
|
|
className: 'props-cell',
|
|
render: p => p ? `<span title="${p}">${p}</span>` : ''
|
|
}
|
|
],
|
|
order: [[1, 'asc']],
|
|
dom: 'ltipr'
|
|
});
|
|
|
|
// Handle Click to Expand (Exception)
|
|
$('#log-table tbody').on('click', 'td.details-control', function () {
|
|
let tr = $(this).closest('tr');
|
|
let row = table.row(tr);
|
|
|
|
if (row.child.isShown()) {
|
|
row.child.hide();
|
|
$(this).html('<i class="bi bi-plus-square"></i>');
|
|
} else if (row.data().exception) {
|
|
row.child(format(row.data())).show();
|
|
$(this).html('<i class="bi bi-dash-square text-danger"></i>');
|
|
}
|
|
});
|
|
|
|
// Handle Click for Full 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();
|
|
});
|
|
|
|
// Drag & Drop / 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('drop', e => {
|
|
e.preventDefault();
|
|
handleFile(e.originalEvent.dataTransfer.files[0]);
|
|
});
|
|
|
|
function handleFile(file) {
|
|
if (!file) return;
|
|
const reader = new FileReader();
|
|
reader.onload = e => {
|
|
const logs = parseLogs(e.target.result);
|
|
table.clear().rows.add(logs).draw();
|
|
};
|
|
reader.readAsText(file);
|
|
}
|
|
|
|
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(.*)$/;
|
|
|
|
lines.forEach(line => {
|
|
if (!line.trim()) return;
|
|
const match = line.match(headerRegex);
|
|
|
|
if (match) {
|
|
let msg = match[5];
|
|
let props = "";
|
|
const propMatch = msg.match(/\((idtask:.*)\)$/);
|
|
if (propMatch) {
|
|
props = propMatch[1];
|
|
msg = msg.replace(propMatch[0], "").trim();
|
|
}
|
|
|
|
logs.push({
|
|
time: match[1],
|
|
level: match[2],
|
|
tag: match[4],
|
|
message: msg,
|
|
props: props,
|
|
exception: ""
|
|
});
|
|
} else {
|
|
// It's a stack trace / exception line
|
|
if (logs.length > 0) {
|
|
logs[logs.length - 1].exception += line + "\n";
|
|
}
|
|
}
|
|
});
|
|
return logs;
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |