Skip to content

Commit

Permalink
[script.logviewer] 2.1.6+matrix.1
Browse files Browse the repository at this point in the history
  • Loading branch information
i96751414 committed Oct 2, 2022
1 parent c1b6e56 commit 2cfab2c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 36 deletions.
5 changes: 3 additions & 2 deletions script.logviewer/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="script.logviewer" name="Log Viewer for Kodi" provider-name="i96751414" version="2.1.5+matrix.1">
<addon id="script.logviewer" name="Log Viewer for Kodi" provider-name="i96751414" version="2.1.6+matrix.1">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
</requires>
Expand All @@ -19,7 +19,8 @@
<description lang="pt_PT">Ferramenta para verificar e ler facilmente o log do Kodi.</description>
<platform>all</platform>
<news>
- Move xbmc.translatePath to xbmcvfs.translatePath (removed in v20)
- Update log level regular expressions for v20.
- Small code improvements on webtail.
</news>
<assets>
<icon>icon.png</icon>
Expand Down
2 changes: 1 addition & 1 deletion script.logviewer/resources/lib/httpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def do_GET(self):
self.end_headers()

def log_message(self, fmt, *args):
logging.info(fmt % args)
logging.debug(fmt % args)


class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
Expand Down
4 changes: 2 additions & 2 deletions script.logviewer/resources/lib/logviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def log_location(old=False):


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


Expand Down
64 changes: 33 additions & 31 deletions script.logviewer/resources/templates/webtail.html
Original file line number Diff line number Diff line change
@@ -1,73 +1,75 @@
<html>
<html lang="en">
<head>
<title>Log Viewer for Kodi</title>
<script type="text/javascript">
var offset = 0;
var polling = null;
let offset = 0;
let polling = null;

var param = function (key, fallback) {
var query = window.location.search.substring(1);
var parameters = query.split('&');
for (var i = 0; i < parameters.length; i++) {
var pair = parameters[i].split('=');
if (pair[0] == key) {
return unescape(pair[1]);
const param = function (key, fallback) {
const query = window.location.search.substring(1);
const parameters = query.split('&');
for (let i = 0; i < parameters.length; i++) {
const pair = parameters[i].split('=');
if (pair[0] === key) {
return decodeURI(pair[1]);
}
}
return fallback;
}
};

var append = function (text) {
const append = function (text) {
if (text) {
var element = document.getElementById('tail');
var scrollDown = element.scrollHeight - element.scrollTop- element.clientHeight < 1;
const element = document.getElementById('tail');
const scrollDown = element.scrollHeight - element.scrollTop - element.clientHeight < 1;
element.textContent += text;
if (scrollDown) {
element.scrollTop = element.scrollHeight;
// element.scrollLeft = 0;
}
}
}
};

var request = function (uri, callback) {
var xhr = new XMLHttpRequest();
const request = function (uri, callback) {
const xhr = new XMLHttpRequest();
xhr.open('GET', uri, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var newOffset = xhr.getResponseHeader('X-Seek-Offset');
if (newOffset) offset = parseInt(newOffset);
if (xhr.readyState === 4 && xhr.status === 200) {
const newOffset = xhr.getResponseHeader('X-Seek-Offset');
if (newOffset) {
offset = parseInt(newOffset);
}
callback(xhr.responseText);
}
};
xhr.send(null);
}
};

var tail = function () {
var uri = '/tail?offset=' + offset;
const tail = function () {
const uri = '/tail?offset=' + offset;
request(uri, append);
}
};

var refresh = function () {
const refresh = function () {
tail();
if (polling == null) {
var interval = parseInt(param('interval', 3000));
const interval = parseInt(param('interval', 3000));
polling = window.setInterval(tail, interval);
}
}
};

var sleep = function () {
const sleep = function () {
if (polling != null) {
window.clearInterval(polling);
polling = null;
}
}
};

window.onload = refresh;
window.onfocus = refresh;
window.onblur = sleep;
</script>
</head>
<body style="background: black; color: #ddd; margin: 0px;">
<pre id="tail" style="white-space: pre-wrap; margin: 0px; height: 100%; overflow: auto;"></pre>
<body style="background: black; color: #ddd; margin: 0;">
<pre id="tail" style="white-space: pre-wrap; margin: 0; height: 100%; overflow: auto;"></pre>
</body>
</html>

0 comments on commit 2cfab2c

Please sign in to comment.