From 8dbbc16ac79e3817197a6f1b02c5653b8add9b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 14 Dec 2022 11:38:06 +0100 Subject: [PATCH 1/5] feat: log auto-updater messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Print the messages to stdout and the log file. Signed-off-by: Miroslav Bajtoš --- main/updater.js | 1 + 1 file changed, 1 insertion(+) diff --git a/main/updater.js b/main/updater.js index 4e35469ab..e7d3432f7 100644 --- a/main/updater.js +++ b/main/updater.js @@ -29,6 +29,7 @@ function beforeQuitCleanup () { } function setup (/** @type {import('./typings').Context} */ _ctx) { + autoUpdater.logger = log autoUpdater.autoDownload = false // we download manually in 'update-available' autoUpdater.on('error', onUpdaterError) From 881847f0637c635833d31e3e641d0411b59981e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 14 Dec 2022 11:46:29 +0100 Subject: [PATCH 2/5] feat: log station-config messages to log file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace `console.log` with `electron-log`, so that the informational messages are printed both to stdout and the log file. Signed-off-by: Miroslav Bajtoš --- main/station-config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/station-config.js b/main/station-config.js index 97499cef1..2baf119e3 100644 --- a/main/station-config.js +++ b/main/station-config.js @@ -3,6 +3,8 @@ const Store = require('electron-store') const { randomUUID } = require('crypto') +const log = require('electron-log').scope('config') + const ConfigKeys = { OnboardingCompleted: 'station.OnboardingCompleted', TrayOperationExplained: 'station.TrayOperationExplained', @@ -30,7 +32,7 @@ const configStore = new Store({ } }) -console.log('Loading Station configuration from', configStore.path) +log.info('Loading Station configuration from', configStore.path) let OnboardingCompleted = /** @type {boolean} */ (configStore.get(ConfigKeys.OnboardingCompleted, false)) let TrayOperationExplained = /** @type {boolean} */ (configStore.get(ConfigKeys.TrayOperationExplained, false)) From 825574d8c2a6c7db726cf67124fb0c7437639ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 14 Dec 2022 11:47:11 +0100 Subject: [PATCH 3/5] feat: log Station build version and computer info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- main/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/index.js b/main/index.js index 393594e61..e7946da08 100644 --- a/main/index.js +++ b/main/index.js @@ -1,9 +1,12 @@ 'use strict' const { app, dialog } = require('electron') -const log = require('electron-log') +const electronLog = require('electron-log') const path = require('node:path') +console.log('Log file:', electronLog.transports.file.findLogPath()) +const log = electronLog.scope('main') + // Override the place where we look for config files when running the end-to-end test suite. // We must call this early on, before any of our modules accesses the config store. // https://www.npmjs.com/package/electron-store @@ -23,6 +26,7 @@ const { ActivityLog } = require('./activity-log') const { BUILD_VERSION } = require('./consts') const { JobStats } = require('./job-stats') const { ipcMain } = require('electron/main') +const os = require('os') const saturnNode = require('./saturn-node') const serve = require('electron-serve') const { setupAppMenu } = require('./app-menu') @@ -38,7 +42,8 @@ const { setup: setupDialogs } = require('./dialog') const inTest = (process.env.NODE_ENV === 'test') const isDev = !app.isPackaged && !inTest -console.log('Filecoin Station build version:', BUILD_VERSION) +log.info('Filecoin Station build version:', BUILD_VERSION, isDev ? '[DEV]' : '', inTest ? '[TEST]' : '') +log.info('Running on %s %s version %s', os.platform(), os.arch(), os.release()) // Expose additional metadata for Electron preload script process.env.STATION_BUILD_VERSION = BUILD_VERSION From fd477431f7e4f5b1ef545fd6d152625cd81251c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 14 Dec 2022 11:54:09 +0100 Subject: [PATCH 4/5] fixup! 881847f MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework another console.log in main/station-config.js to call log.info instead. Signed-off-by: Miroslav Bajtoš --- main/station-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/station-config.js b/main/station-config.js index 2baf119e3..fa48ae39f 100644 --- a/main/station-config.js +++ b/main/station-config.js @@ -28,7 +28,7 @@ const configStore = new Store({ } }, beforeEachMigration: (_, context) => { - console.log(`Migrating station-config from ${context.fromVersion} → ${context.toVersion}`) + log.info(`Migrating station-config from ${context.fromVersion} → ${context.toVersion}`) } }) From f04baca65ca102ba1eacb1317c7fa49c107db812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 14 Dec 2022 15:09:23 +0100 Subject: [PATCH 5/5] fixup! build version & machine spec log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- main/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main/index.js b/main/index.js index e7946da08..8ccf54fdb 100644 --- a/main/index.js +++ b/main/index.js @@ -42,8 +42,12 @@ const { setup: setupDialogs } = require('./dialog') const inTest = (process.env.NODE_ENV === 'test') const isDev = !app.isPackaged && !inTest -log.info('Filecoin Station build version:', BUILD_VERSION, isDev ? '[DEV]' : '', inTest ? '[TEST]' : '') -log.info('Running on %s %s version %s', os.platform(), os.arch(), os.release()) +log.info('Filecoin Station build version: %s %s-%s%s%s', BUILD_VERSION, os.platform(), os.arch(), isDev ? ' [DEV]' : '', inTest ? ' [TEST]' : '') +log.info('Machine spec: %s version %s', os.type(), os.release()) +// TODO(bajtos) print machine architecture after we upgrade to Electron with Node.js 18 +// log.info('Machine spec: %s %s version %s', os.type(), +// os.machine(), +// os.release()) // Expose additional metadata for Electron preload script process.env.STATION_BUILD_VERSION = BUILD_VERSION