Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions main/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
})
Expand Down
12 changes: 6 additions & 6 deletions main/logs.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand All @@ -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
}