diff --git a/main/core.js b/main/core.js index 3849a7163..8e12db14a 100644 --- a/main/core.js +++ b/main/core.js @@ -10,7 +10,7 @@ const Sentry = require('@sentry/node') const consts = require('./consts') const { randomUUID } = require('node:crypto') const { Activities } = require('./activities') -const { Logs } = require('./logs') +const { LogLines } = require('./logs') const split2 = require('split2') const { parseEther } = require('ethers/lib/utils') @@ -23,7 +23,7 @@ const corePath = app.isPackaged : join(__dirname, '..', 'core', 'bin', 'station.js') console.log('Core binary: %s', corePath) -const logs = new Logs() +const logLines = new LogLines() const activities = new Activities() let totalJobsCompleted = 0 @@ -39,7 +39,7 @@ async function setup (ctx) { ctx.showUI() const { filePath } = await dialog.showSaveDialog(opts) if (filePath) { - await fs.writeFile(filePath, logs.get()) + await fs.writeFile(filePath, logLines.get()) } } await maybeMigrateFiles() @@ -68,7 +68,7 @@ async function start (ctx) { childProcess.stdout .pipe(split2()) .on('data', line => { - logs.push(line) + logLines.push(line) let event try { event = JSON.parse(line) @@ -115,7 +115,7 @@ async function start (ctx) { childProcess.stderr.setEncoding('utf8') childProcess.stderr .pipe(split2()) - .on('data', line => logs.push(line)) + .on('data', line => logLines.push(line)) /** @type {string | null} */ let exitReason = null @@ -130,7 +130,7 @@ async function start (ctx) { ;(async () => { Sentry.captureException('Core exited', scope => { // Sentry UI can't show the full 100 lines - scope.setExtra('logs', logs.getLast(10)) + scope.setExtra('logs', logLines.getLast(10)) scope.setExtra('reason', exitReason) return scope }) diff --git a/main/logs.js b/main/logs.js index 1e9ef081a..69cdb0ff5 100644 --- a/main/logs.js +++ b/main/logs.js @@ -1,16 +1,16 @@ 'use strict' -class Logs { +class LogLines { /** @type {string[]} */ - #logs = [] + #logLines = [] /** * Keep last 100 lines of logs for inspection * @param {string} line */ push (line) { - this.#logs.push(line) - this.#logs.splice(0, this.#logs.length - 100) + this.#logLines.push(line) + this.#logLines.splice(0, this.#logLines.length - 100) } get () { @@ -22,10 +22,10 @@ class Logs { * @returns string */ getLast (n) { - return this.#logs.slice(-n).join('\n') + return this.#logLines.slice(-n).join('\n') } } module.exports = { - Logs + LogLines }