-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogs.html
More file actions
100 lines (87 loc) · 3.43 KB
/
Copy pathlogs.html
File metadata and controls
100 lines (87 loc) · 3.43 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<html style="height: 100%">
<head>
<title>Logs</title>
<script src="/socket.io/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>
var socket = io.connect(window.location.host);
var logfile = "log.txt";
var bScrollToBottom = true;
socket.on("connect", function() {
socket.emit("addlogwatcher");
});
function loadLogs() {
$.ajax({
url: logfile,
dataType: "text",
success: function(data) {
$("#logs")
.html(data)
.append("<br />");
bScrollToBottom ? scrollToBottom() : null;
}
});
}
function scrollToBottom() {
$("#logs").animate(
{ scrollTop: $("#logs").prop("scrollHeight") },
500 // scroll speed
);
}
// on load of page
$(function() {
loadLogs();
socket.on("newlog", loadLogs); // reload every time there's a new log
// Switch between current session and all sessions
$("#switchLink").click(function() {
if (logfile === "log.txt") {
logfile = "log_history.txt";
$("#switch").text("the current server session");
$("#which").text("all sessions");
} else {
logfile = "log.txt";
$("#switch").text("all sessions");
$("#which").text("the current server session");
}
loadLogs();
});
// Set up automatic scroll checkbox
$("#scrollToBottom")
.change(function() {
bScrollToBottom = this.checked;
})
.prop("checked", true);
// Handle resizing of "logs" div so that everything always fits on one page
var resizeLogsDiv = function() {
$("#logs").height(
$(window).height() - $("#header").height() - 30
);
};
$(window).ready(resizeLogsDiv);
$(window).bind("resize", resizeLogsDiv);
});
</script>
</head>
<body style="height: 100%; overflow: hidden;">
<div id="header">
<h2>LP Socket.IO Server Logs</h2>
<div style="font-size: 24px;">
Showing logs from <b id="which">the current server session</b>:
</div>
<a id="switchLink" href="javascript:void(0);">Switch</a> to logs
from <b id="switch">all sessions</b>
<br />
<br />
<input type="checkbox" id="scrollToBottom" />
Automatically scroll to bottom whenever there is a new log posted
</div>
<div
id="logs"
style="white-space: pre;
font-family: 'Lucida Console', Monaco, monospace;
background-color: black;
color: white;
overflow: scroll;"
></div>
</body>
</html>