mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-15 17:53:44 +08:00
Add new verbose logging option for easier debugging
This commit is contained in:
parent
eaae6ff197
commit
9014e60b80
4 changed files with 57 additions and 5 deletions
|
@ -2,6 +2,16 @@ export default {
|
|||
core: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
sync: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
verboseUntil: {
|
||||
type: 'number',
|
||||
default: 0,
|
||||
title: 'Enable verbose IMAP / SMTP logging',
|
||||
},
|
||||
},
|
||||
},
|
||||
workspace: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { ipcRenderer, remote } from 'electron';
|
||||
import _ from 'underscore';
|
||||
|
||||
import Task from './tasks/task';
|
||||
|
@ -21,6 +21,8 @@ import Utils from './models/utils';
|
|||
const MAX_CRASH_HISTORY = 10;
|
||||
const REPORTED_CRASH_STACKS = {};
|
||||
|
||||
const VERBOSE_UNTIL_KEY = 'core.sync.verboseUntil';
|
||||
|
||||
/*
|
||||
This class keeps track of how often Mailsync workers crash. If a mailsync
|
||||
worker exits more than 5 times in <5 minutes, we consider it "too many failures"
|
||||
|
@ -163,6 +165,30 @@ export default class MailsyncBridge {
|
|||
require('electron').shell.showItemInFolder(configDirItem); // eslint-disable-line
|
||||
}
|
||||
|
||||
toggleVerboseLogging() {
|
||||
const { configDirPath } = AppEnv.getLoadSettings();
|
||||
let message = 'Thank you for helping debug Mailspring. Mailspring will now restart.';
|
||||
let phrase = 'disabled';
|
||||
|
||||
if (AppEnv.config.get(VERBOSE_UNTIL_KEY)) {
|
||||
AppEnv.config.set(VERBOSE_UNTIL_KEY, 0);
|
||||
} else {
|
||||
AppEnv.config.set(VERBOSE_UNTIL_KEY, Date.now() + 30 * 60 * 1000);
|
||||
phrase = 'enabled';
|
||||
message =
|
||||
`Verbose logging will be enabled for the next thirty minutes. This records ` +
|
||||
`all network traffic to your mail providers and will be quite slow. Restart Mailspring ` +
|
||||
`and wait for your problem to occur, and then submit mailsync-***.log files located ` +
|
||||
`in the directory: \n\n${configDirPath}.\n\nMailspring will now restart.`;
|
||||
}
|
||||
AppEnv.showErrorDialog({
|
||||
title: `Verbose logging is now ${phrase}`,
|
||||
message,
|
||||
});
|
||||
remote.app.relaunch();
|
||||
remote.app.quit();
|
||||
}
|
||||
|
||||
clients() {
|
||||
return this._clients;
|
||||
}
|
||||
|
@ -223,7 +249,18 @@ export default class MailsyncBridge {
|
|||
return;
|
||||
}
|
||||
|
||||
const client = new MailsyncProcess(AppEnv.getLoadSettings(), identity, fullAccountJSON);
|
||||
const { configDirPath, resourcePath } = AppEnv.getLoadSettings();
|
||||
const verboseUntil = AppEnv.config.get(VERBOSE_UNTIL_KEY) || 0;
|
||||
const verbose = verboseUntil && verboseUntil / 1 > Date.now();
|
||||
if (verbose) {
|
||||
console.warn(`Verbose mailsync logging is enabled until ${new Date(verboseUntil)}`);
|
||||
}
|
||||
|
||||
const client = new MailsyncProcess(
|
||||
{ configDirPath, resourcePath, verbose },
|
||||
identity,
|
||||
fullAccountJSON
|
||||
);
|
||||
client.sync();
|
||||
client.on('deltas', this._onIncomingMessages);
|
||||
client.on('close', ({ code, error, signal }) => {
|
||||
|
|
|
@ -49,8 +49,9 @@ export const LocalizedErrorStrings = {
|
|||
};
|
||||
|
||||
export default class MailsyncProcess extends EventEmitter {
|
||||
constructor({ configDirPath, resourcePath }, identity, account) {
|
||||
constructor({ configDirPath, resourcePath, verbose }, identity, account) {
|
||||
super();
|
||||
this.verbose = verbose;
|
||||
this.configDirPath = configDirPath;
|
||||
this.account = account;
|
||||
this.identity = identity;
|
||||
|
@ -68,7 +69,11 @@ export default class MailsyncProcess extends EventEmitter {
|
|||
env.IDENTITY_SERVER = rootURLForServer('identity');
|
||||
}
|
||||
|
||||
this._proc = spawn(this.binaryPath, [`--mode`, mode], { env });
|
||||
const args = [`--mode`, mode];
|
||||
if (this.verbose) {
|
||||
args.push('--verbose');
|
||||
}
|
||||
this._proc = spawn(this.binaryPath, args, { env });
|
||||
|
||||
// stdout may not be present if an error occurred. Error handler hasn't been
|
||||
// attached yet, but will be by the caller of spawnProcess.
|
||||
|
|
2
mailsync
2
mailsync
|
@ -1 +1 @@
|
|||
Subproject commit 3f218566aea0232a5e10ee25a4a2a7e4aa147f33
|
||||
Subproject commit c610c8dbcd58ba979474e5792ce8fbb8da72f402
|
Loading…
Reference in a new issue