Skip to content

Commit a7e830f

Browse files
authored
[script.logviewer] 2.1.6+matrix.1 (#2324)
1 parent c1b6e56 commit a7e830f

File tree

4 files changed

+39
-36
lines changed

4 files changed

+39
-36
lines changed

script.logviewer/addon.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<addon id="script.logviewer" name="Log Viewer for Kodi" provider-name="i96751414" version="2.1.5+matrix.1">
2+
<addon id="script.logviewer" name="Log Viewer for Kodi" provider-name="i96751414" version="2.1.6+matrix.1">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0"/>
55
</requires>
@@ -19,7 +19,8 @@
1919
<description lang="pt_PT">Ferramenta para verificar e ler facilmente o log do Kodi.</description>
2020
<platform>all</platform>
2121
<news>
22-
- Move xbmc.translatePath to xbmcvfs.translatePath (removed in v20)
22+
- Update log level regular expressions for v20.
23+
- Small code improvements on webtail.
2324
</news>
2425
<assets>
2526
<icon>icon.png</icon>

script.logviewer/resources/lib/httpserver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def do_GET(self):
8585
self.end_headers()
8686

8787
def log_message(self, fmt, *args):
88-
logging.info(fmt % args)
88+
logging.debug(fmt % args)
8989

9090

9191
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):

script.logviewer/resources/lib/logviewer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def log_location(old=False):
7474

7575

7676
log_entry_regex = re.compile(r"(?:\d{4}-\d{2}-\d{2} )?\d{2}:\d{2}:\d{2}")
77-
log_error_regex = re.compile(r" ERROR(?: <[^>]*>)?: ")
78-
log_warning_regex = re.compile(r" WARNING(?: <[^>]*>)?: ")
77+
log_error_regex = re.compile(r" (ERROR|error)(?: <[^>]*>)?: ")
78+
log_warning_regex = re.compile(r" (WARNING|warning)(?: <[^>]*>)?: ")
7979
log_exception_regex = re.compile(log_error_regex.pattern + "EXCEPTION ")
8080

8181

Original file line numberDiff line numberDiff line change
@@ -1,73 +1,75 @@
1-
<html>
1+
<html lang="en">
22
<head>
33
<title>Log Viewer for Kodi</title>
44
<script type="text/javascript">
5-
var offset = 0;
6-
var polling = null;
5+
let offset = 0;
6+
let polling = null;
77

8-
var param = function (key, fallback) {
9-
var query = window.location.search.substring(1);
10-
var parameters = query.split('&');
11-
for (var i = 0; i < parameters.length; i++) {
12-
var pair = parameters[i].split('=');
13-
if (pair[0] == key) {
14-
return unescape(pair[1]);
8+
const param = function (key, fallback) {
9+
const query = window.location.search.substring(1);
10+
const parameters = query.split('&');
11+
for (let i = 0; i < parameters.length; i++) {
12+
const pair = parameters[i].split('=');
13+
if (pair[0] === key) {
14+
return decodeURI(pair[1]);
1515
}
1616
}
1717
return fallback;
18-
}
18+
};
1919

20-
var append = function (text) {
20+
const append = function (text) {
2121
if (text) {
22-
var element = document.getElementById('tail');
23-
var scrollDown = element.scrollHeight - element.scrollTop- element.clientHeight < 1;
22+
const element = document.getElementById('tail');
23+
const scrollDown = element.scrollHeight - element.scrollTop - element.clientHeight < 1;
2424
element.textContent += text;
2525
if (scrollDown) {
2626
element.scrollTop = element.scrollHeight;
2727
// element.scrollLeft = 0;
2828
}
2929
}
30-
}
30+
};
3131

32-
var request = function (uri, callback) {
33-
var xhr = new XMLHttpRequest();
32+
const request = function (uri, callback) {
33+
const xhr = new XMLHttpRequest();
3434
xhr.open('GET', uri, true);
3535
xhr.onreadystatechange = function () {
36-
if (xhr.readyState == 4 && xhr.status == 200) {
37-
var newOffset = xhr.getResponseHeader('X-Seek-Offset');
38-
if (newOffset) offset = parseInt(newOffset);
36+
if (xhr.readyState === 4 && xhr.status === 200) {
37+
const newOffset = xhr.getResponseHeader('X-Seek-Offset');
38+
if (newOffset) {
39+
offset = parseInt(newOffset);
40+
}
3941
callback(xhr.responseText);
4042
}
4143
};
4244
xhr.send(null);
43-
}
45+
};
4446

45-
var tail = function () {
46-
var uri = '/tail?offset=' + offset;
47+
const tail = function () {
48+
const uri = '/tail?offset=' + offset;
4749
request(uri, append);
48-
}
50+
};
4951

50-
var refresh = function () {
52+
const refresh = function () {
5153
tail();
5254
if (polling == null) {
53-
var interval = parseInt(param('interval', 3000));
55+
const interval = parseInt(param('interval', 3000));
5456
polling = window.setInterval(tail, interval);
5557
}
56-
}
58+
};
5759

58-
var sleep = function () {
60+
const sleep = function () {
5961
if (polling != null) {
6062
window.clearInterval(polling);
6163
polling = null;
6264
}
63-
}
65+
};
6466

6567
window.onload = refresh;
6668
window.onfocus = refresh;
6769
window.onblur = sleep;
6870
</script>
6971
</head>
70-
<body style="background: black; color: #ddd; margin: 0px;">
71-
<pre id="tail" style="white-space: pre-wrap; margin: 0px; height: 100%; overflow: auto;"></pre>
72+
<body style="background: black; color: #ddd; margin: 0;">
73+
<pre id="tail" style="white-space: pre-wrap; margin: 0; height: 100%; overflow: auto;"></pre>
7274
</body>
7375
</html>

0 commit comments

Comments
 (0)