How to use the electron-log.catchErrors function in electron-log

To help you get started, we’ve selected a few electron-log examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stream-labs / streamlabs-obs / app / app.ts View on Github external
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') });
github stream-labs / streamlabs-obs / main.js View on Github external
(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);
      });
github jie17 / v2ray-electron / src / main / index.ts View on Github external
3600000
    );
  }
);

autoUpdater.on(
  "error",
  (): void => {
    setTimeout(
      (): Promise => autoUpdater.checkForUpdates(),
      3600000
    );
  }
);

log.catchErrors();