-
Notifications
You must be signed in to change notification settings - Fork 0
/
success.html
74 lines (67 loc) · 1.88 KB
/
success.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
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<title>PM2 Log Viewer</title>
<style>
body {
margin: 0;
padding: 0;
background-color: rgb(119, 112, 112);
color: white;
font-family: "Courier New", monospace;
}
.log-container {
display: flex;
justify-content: space-between;
padding: 20px;
}
.log-box {
flex: 1;
border: 1px solid white;
padding: 10px;
background-color: #050505;
overflow: auto;
max-height: 70vh;
}
.success-box {
color: greenyellow;
}
h1 {
text-align: center;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const port = window.location.port;
const socket = io(`http://localhost:${port}`);
socket.on("connect", () => {
console.log("Connected to server");
});
socket.on("logFileChange", (logData) => {
updateLog("success-logs", logData);
});
socket.on("disconnect", () => {
console.log("Disconnected from server");
});
function updateLog(logType, logData) {
const logContainer = document.getElementById(logType);
logContainer.innerHTML = ""; // Clear existing content
const logElement = document.createElement("pre");
logElement.textContent = logData;
logContainer.appendChild(logElement);
// Automatically scroll to the bottom
logContainer.scrollTop = logContainer.scrollHeight;
}
});
</script>
</head>
<body>
<h1>Log Viewer</h1>
<div class="log-container">
<div class="log-box success-box" id="success-logs">
<h2>Logs</h2>
</div>
</div>
</body>
</html>