From 5ae6d7d47b72e0d53872605199c9e51803409222 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 8 Apr 2024 14:17:02 +0530 Subject: [PATCH] Don't wait for ready before logging startup banner > The only hint is to call the code in main.ts without waiting for the ready event. > > https://github.com/megahertz/electron-log/issues/408 --- desktop/src/main.ts | 19 +++++++++++++++++-- desktop/src/main/init.ts | 15 --------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/desktop/src/main.ts b/desktop/src/main.ts index 4383fa73f..787f4b4d0 100644 --- a/desktop/src/main.ts +++ b/desktop/src/main.ts @@ -12,6 +12,7 @@ import { app, BrowserWindow, Menu } from "electron/main"; import serveNextAt from "next-electron-server"; import { existsSync } from "node:fs"; import fs from "node:fs/promises"; +import os from "node:os"; import path from "node:path"; import { addAllowOriginHeader, @@ -19,7 +20,6 @@ import { handleDockIconHideOnAutoLaunch, handleDownloads, handleExternalLinks, - logStartupBanner, setupMacWindowOnDockIconClick, setupTrayItem, } from "./main/init"; @@ -72,6 +72,21 @@ const setupRendererServer = () => { serveNextAt(rendererURL); }; +/** + * Log a standard startup banner. + * + * This helps us identify app starts and other environment details in the logs. + */ +const logStartupBanner = () => { + const version = isDev ? "dev" : app.getVersion(); + log.info(`Starting ente-photos-desktop ${version}`); + + const platform = process.platform; + const osRelease = os.release(); + const systemVersion = process.getSystemVersion(); + log.info("Running on", { platform, osRelease, systemVersion }); +}; + function enableSharedArrayBufferSupport() { app.commandLine.appendSwitch("enable-features", "SharedArrayBuffer"); } @@ -144,6 +159,7 @@ const main = () => { initLogging(); setupRendererServer(); + logStartupBanner(); handleDockIconHideOnAutoLaunch(); increaseDiskCache(); enableSharedArrayBufferSupport(); @@ -163,7 +179,6 @@ const main = () => { // // Note that some Electron APIs can only be used after this event occurs. app.on("ready", async () => { - logStartupBanner(); mainWindow = await createWindow(); const watcher = initWatcher(mainWindow); setupTrayItem(mainWindow); diff --git a/desktop/src/main/init.ts b/desktop/src/main/init.ts index 22cdabf08..7eb44c599 100644 --- a/desktop/src/main/init.ts +++ b/desktop/src/main/init.ts @@ -149,21 +149,6 @@ export async function handleDockIconHideOnAutoLaunch() { } } -/** - * Log a standard startup banner. - * - * This helps us identify app starts and other environment details in the logs. - */ -export const logStartupBanner = () => { - const version = isDev ? "dev" : app.getVersion(); - log.info(`Starting ente-photos-desktop ${version}`); - - const platform = process.platform; - const osRelease = os.release(); - const systemVersion = process.getSystemVersion(); - log.info("Running on", { platform, osRelease, systemVersion }); -}; - function lowerCaseHeaders(responseHeaders: Record) { const headers: Record = {}; for (const key of Object.keys(responseHeaders)) {