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
This commit is contained in:
Manav Rathi 2024-04-08 14:17:02 +05:30
parent 18e47b3d4e
commit 5ae6d7d47b
No known key found for this signature in database
2 changed files with 17 additions and 17 deletions

View file

@ -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);

View file

@ -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<string, string[]>) {
const headers: Record<string, string[]> = {};
for (const key of Object.keys(responseHeaders)) {