Introduce buffered console logger

This commit is contained in:
Fedor Indutny 2023-03-28 15:22:06 -07:00 committed by GitHub
parent 6dab8c70a1
commit d1791ff6be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 47 deletions

View file

@ -26,7 +26,6 @@ import { CircularBuffer } from 'cirbuf';
import type { LoggerType } from '../types/Logging';
import * as Errors from '../types/errors';
import * as durations from '../util/durations';
import { createRotatingPinoDest } from '../util/rotatingPinoDest';
import * as log from './log';
@ -64,13 +63,6 @@ export async function initialize(
const logPath = join(basePath, 'logs');
mkdirSync(logPath, { recursive: true });
let appMetrics = app.getAppMetrics();
setInterval(() => {
// CPU stats are computed since the last call to `getAppMetrics`.
appMetrics = app.getAppMetrics();
}, 30 * durations.SECOND).unref();
try {
await cleanupLogs(logPath);
} catch (error) {
@ -141,7 +133,6 @@ export async function initialize(
]);
data = {
logEntries,
appMetrics,
...rest,
};
} catch (error) {
@ -340,7 +331,7 @@ export function fetchLogs(logPath: string): Promise<Array<LogEntryType>> {
export const fetchAdditionalLogData = (
mainWindow: BrowserWindow
): Promise<Omit<FetchLogIpcData, 'logEntries' | 'appMetrics'>> =>
): Promise<Omit<FetchLogIpcData, 'logEntries'>> =>
new Promise(resolve => {
mainWindow.webContents.send('additional-log-data-request');
ipc.once('additional-log-data-response', (_event, data) => {