-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
65 lines (61 loc) · 2.42 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example Title</title>
<style>
body {
background-color: black;
color: white;
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
.blue { color: blue; }
.green { color: green; }
.red { color: red; }
.orange { color: orange; }
.yellow { color: yellow; }
.cyan { color: cyan; }
.olive { color: olive; }
pre {
white-space: pre-wrap;
word-wrap: break-word;
margin: 0;
}
</style>
</head>
<body>
<h1>Example text</h1>
<pre id="log"></pre>
<script>
const logElement = document.getElementById('log');
async function fetchLogs() {
try {
const response = await fetch('/logs');
const logs = await response.text();
const formattedLogs = formatLogs(logs);
logElement.innerHTML = formattedLogs;
} catch (error) {
console.error('Error fetching logs:', error);
}
}
function formatLogs(logs) {
const lines = logs.split('\n').slice(-50); // Get the last 50 lines of log
return lines.map(line => { // Gives color to certains parts of the log
line = line.replace(/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{4})/, '<span class="blue">$1</span>'); // Colored Timestamps
line = line.replace(/(Example color 1)/, '<span class="green">$1</span>'); // Example text, change it to
line = line.replace(/(Example color 2)/, '<span class="red">$1</span>'); // the text you want colored in the logs
line = line.replace(/(Example color 3)/, '<span class="orange">$1</span>');
line = line.replace(/(Example color 4)/, '<span class="green">$1</span>');
line = line.replace(/(Example color 5)/, '<span class="cyan">$1</span>');
line = line.replace(/(Example color 6)/, '<span class="olive">$1</span>');
line = line.replace(/(Example color 7)/, '<span class="yellow">$1</span>');
return line;
}).join('\n');
}
setInterval(fetchLogs, 1000); // Fetch logs every second
</script>
</body>
</html>