diff --git a/src/client/stores/settings.ts b/src/client/stores/settings.ts index 03fa03e..de7a08a 100644 --- a/src/client/stores/settings.ts +++ b/src/client/stores/settings.ts @@ -17,7 +17,7 @@ const defaultSettings: Settings = { }; function getSettingsFromStorage(): Settings { - let settings = JSON.parse(localStorage.getItem("WebTailSettings")); + const settings = JSON.parse(localStorage.getItem("WebTailSettings")); if (settings === null) { localStorage.setItem("WebTailSettings", JSON.stringify(defaultSettings)); return getSettingsFromStorage(); diff --git a/src/client/stores/sources.ts b/src/client/stores/sources.ts index b408a2a..e70ae9c 100644 --- a/src/client/stores/sources.ts +++ b/src/client/stores/sources.ts @@ -6,8 +6,8 @@ export default function () { async function get() { loadingSources.set(true); - let response = await fetch("/sources"); - let data: Array = await response.json(); + const response = await fetch("/sources"); + const data: Array = await response.json(); sources.set(data); loadingSources.set(false); } diff --git a/src/server/index.ts b/src/server/index.ts index 2cb805a..581749a 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -32,7 +32,7 @@ function getConfig() { } catch { raw = fs.readFileSync(join(__dirname, "web-tail.config.json")); } - let config: Config = JSON.parse(raw); + const config: Config = JSON.parse(raw); return config; } @@ -43,11 +43,11 @@ function heartbeat() { let LogSource: Source; wss.on("connection", function connection(ws, req) { - let sourceName = req.url.split("/")[1]; - let initialLinesAmount = req.url.split("/")[2]; + const sourceName = req.url.split("/")[1]; + const initialLinesAmount = req.url.split("/")[2]; console.log("Connection established", sourceName, initialLinesAmount); - for (let source of getConfig()["sources"]) { + for (const source of getConfig()["sources"]) { if (sourceName === source.name) { LogSource = getSourceClassFromConfig( source, diff --git a/src/server/models/sources/local.ts b/src/server/models/sources/local.ts index 6918053..e2d3368 100644 --- a/src/server/models/sources/local.ts +++ b/src/server/models/sources/local.ts @@ -13,13 +13,17 @@ class LocalFileSource extends Source { newLineCallback: CallableFunction ) { super(config, initialLinesAmount, newLineCallback); - this.tail = new Tail(this.config.path); + this.tail = new Tail(this.config.path, { force: true }); } configConnection() { this.tail.on("line", (line) => { this.newLineCallback(line); }); + + this.tail.on("error", (error) => { + this.newLineCallback(error.toString()); + }); } startReading() { diff --git a/src/server/models/sources/ssh.ts b/src/server/models/sources/ssh.ts index 380edae..06b9498 100644 --- a/src/server/models/sources/ssh.ts +++ b/src/server/models/sources/ssh.ts @@ -41,7 +41,7 @@ abstract class SSHSource extends Source { this.newLineCallback(data.toString()); }) .stderr.on("data", (data) => { - console.log("STDERR: " + data); + this.newLineCallback(data.toString()); }); }); })