Override console.log in main process, handle non-strings (#1536)

This should allow us to get an insight into auto-update behavior and
other low-level behaviors happening in the Electron process which would
be useful for debugging.

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-10-04 14:03:59 -07:00 committed by GitHub
parent 0b7543b0f6
commit fb674529f4
2 changed files with 48 additions and 2 deletions

View file

@ -43,8 +43,21 @@ function log() {
const consoleArgs = ['INFO ', now()].concat(args);
console._log.apply(console, consoleArgs);
const str = redactGroup(redactPhone(args.join(' ')));
ipc.send('log-info', str);
// To avoid [Object object] in our log since console.log handles non-strings smoothly
const str = args.map(function(item) {
if (typeof item !== 'string') {
try {
return JSON.stringify(item);
}
catch (e) {
return item;
}
}
return item;
});
const toSend = redactGroup(redactPhone(str.join(' ')));
ipc.send('log-info', toSend);
}
if (window.console) {