Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function logError(...args: unknown[]) {
if (Utils.isDevMode()) ipcRenderer.send('showErrorAlert');
electronLog.error(...args);
}
// override console
Object.assign(console, {
log: electronLog.log,
warn: electronLog.warn,
info: electronLog.info,
error: logError,
});
// catch and log unhandled errors/rejected promises:
electronLog.catchErrors({ onError: () => Utils.isDevMode() && ipcRenderer.send('showErrorAlert') });
(function setupLogger() {
// save logs to the cache directory
electronLog.transports.file.file = path.join(app.getPath('userData'), 'log.log');
electronLog.transports.file.level = 'info';
// Set approximate maximum log size in bytes. When it exceeds,
// the archived log will be saved as the log.old.log file
electronLog.transports.file.maxSize = 5 * 1024 * 1024;
// catch and log unhandled errors/rejected promises
electronLog.catchErrors();
// network logging is disabled by default
if (!process.argv.includes('--network-logging')) return;
app.on('ready', () => {
// ignore fs requests
const filter = { urls: ['https://*', 'http://*'] };
session.defaultSession.webRequest.onBeforeRequest(filter, (details, callback) => {
log('HTTP REQUEST', details.method, details.url);
callback(details);
});
session.defaultSession.webRequest.onErrorOccurred(filter, (details) => {
log('HTTP REQUEST FAILED', details.method, details.url);
});
3600000
);
}
);
autoUpdater.on(
"error",
(): void => {
setTimeout(
(): Promise => autoUpdater.checkForUpdates(),
3600000
);
}
);
log.catchErrors();