Skip to content

Commit 9108540

Browse files
committed
Add option to provide log location via ?url
1 parent 1b9103a commit 9108540

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ No server side code is required - it's all just static
1111
files - and all modern web servers support Range (tested lighttpd, cherokee,
1212
apache). Tested (briefly) in IE, FF, Chrome.
1313

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

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

logtail.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ var dataelem = "#data";
77
var pausetoggle = "#pause";
88
var scrollelems = ["html", "body"];
99

10-
var url = "log";
10+
var url_string = window.location.href;
11+
var urlObject = new URL(url_string);
12+
var urlParam = urlObject.searchParams.get("url");
13+
var url = urlParam ?? "log"
1114
var fix_rn = true;
1215
var load = 30 * 1024; /* 30KB */
1316
var poll = 1000; /* 1s */
@@ -146,7 +149,7 @@ function show_log() {
146149
if (reverse) {
147150
var t_a = t.split(/\n/g);
148151
t_a.reverse();
149-
if (t_a[0] == "")
152+
if (t_a[0] == "")
150153
t_a.shift();
151154
t = t_a.join("\n");
152155
}
@@ -163,7 +166,7 @@ function error(what) {
163166
kill = true;
164167

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

0 commit comments

Comments
 (0)