Skip to content

Commit

Permalink
Add option to provide log location via ?url
Browse files Browse the repository at this point in the history
  • Loading branch information
petr-balogh committed Sep 26, 2023
1 parent 1b9103a commit 9108540
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ No server side code is required - it's all just static
files - and all modern web servers support Range (tested lighttpd, cherokee,
apache). Tested (briefly) in IE, FF, Chrome.

Usage: symlink the log to /log, or alter the url in logtail.js. Other settings
available in logtail.js including poll frequency. Then browse to index.html
Usage: symlink the log to /log, provide ?url=http://my.custom.path/log, or alter
the url in logtail.js. Other settings available in logtail.js including poll
frequency. Then browse to index.html

License is GNU GPL 3; see http://www.gnu.org/licenses/

Expand Down
9 changes: 6 additions & 3 deletions logtail.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ var dataelem = "#data";
var pausetoggle = "#pause";
var scrollelems = ["html", "body"];

var url = "log";
var url_string = window.location.href;
var urlObject = new URL(url_string);
var urlParam = urlObject.searchParams.get("url");
var url = urlParam ?? "log"
var fix_rn = true;
var load = 30 * 1024; /* 30KB */
var poll = 1000; /* 1s */
Expand Down Expand Up @@ -146,7 +149,7 @@ function show_log() {
if (reverse) {
var t_a = t.split(/\n/g);
t_a.reverse();
if (t_a[0] == "")
if (t_a[0] == "")
t_a.shift();
t = t_a.join("\n");
}
Expand All @@ -163,7 +166,7 @@ function error(what) {
kill = true;

$(dataelem).text("An error occured :-(.\r\n" +
"Reloading may help; no promises.\r\n" +
"Reloading may help; no promises.\r\n" +
what);
scroll(0);

Expand Down

0 comments on commit 9108540

Please sign in to comment.