Merge pull request #2001 from warrickct/debug-log-qol

Debug log - Save to desktop
pull/2029/head
Audric Ackermann 4 years ago committed by GitHub
commit 49b70f49d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -140,6 +140,7 @@
"copySessionID": "Copy Session ID", "copySessionID": "Copy Session ID",
"copyOpenGroupURL": "Copy Group's URL", "copyOpenGroupURL": "Copy Group's URL",
"save": "Save", "save": "Save",
"saveLogToDesktop": "Save log to desktop",
"saved": "Saved", "saved": "Saved",
"permissions": "Permissions", "permissions": "Permissions",
"general": "General", "general": "General",

@ -28,3 +28,5 @@ window.getOSRelease = () => `${os.type()} ${os.release} ${os.platform()}`;
window.getCommitHash = () => config.commitHash; window.getCommitHash = () => config.commitHash;
window.closeDebugLog = () => ipcRenderer.send('close-debug-log'); window.closeDebugLog = () => ipcRenderer.send('close-debug-log');
window.saveLog = logText => ipcRenderer.send('save-debug-log', logText);

@ -44,7 +44,7 @@
render_attributes: { render_attributes: {
title: i18n('submitDebugLog'), title: i18n('submitDebugLog'),
cancel: i18n('cancel'), cancel: i18n('cancel'),
submit: i18n('submit'), submit: i18n('saveLogToDesktop'),
close: i18n('gotIt'), close: i18n('gotIt'),
debugLogExplanation: i18n('debugLogExplanation'), debugLogExplanation: i18n('debugLogExplanation'),
}, },
@ -57,26 +57,7 @@
if (text.length === 0) { if (text.length === 0) {
return; return;
} }
window.saveLog(text);
this.$('.buttons, textarea').remove();
this.$('.result').addClass('loading');
try {
const publishedLogURL = await window.log.publish(text);
const view = new Whisper.DebugLogLinkView({
url: publishedLogURL,
el: this.$('.result'),
});
this.$('.loading').removeClass('loading');
view.render();
this.$('.link')
.focus()
.select();
} catch (error) {
window.log.error('DebugLogView error:', error && error.stack ? error.stack : error);
this.$('.loading').removeClass('loading');
this.$('.result').text(i18n('debugLogError'));
}
}, },
}); });
})(); })();

@ -946,6 +946,15 @@ ipc.on('close-debug-log', () => {
debugLogWindow.close(); debugLogWindow.close();
} }
}); });
ipc.on('save-debug-log', (event, logText) => {
const outputPath = path.join(app.getPath('desktop'), `session_debug_${new Date()}.log`);
fs.writeFile(outputPath, logText, err => {
if (err) {
console.error('Error saving debug log');
}
console.error(`Saved log - ${outputPath}`);
});
});
// This should be called with an ipc sendSync // This should be called with an ipc sendSync
ipc.on('get-media-permissions', event => { ipc.on('get-media-permissions', event => {

Loading…
Cancel
Save