Upload debug logs to debuglogs.org

pull/1/head
Daniel Gasienica 7 years ago
parent bd5f3bd73a
commit 3ab3e93a28

@ -2,12 +2,10 @@
/* eslint strict: ['error', 'never'] */ /* eslint strict: ['error', 'never'] */
/* global $: false */
/* global textsecure: false */
const electron = require('electron'); const electron = require('electron');
const bunyan = require('bunyan'); const bunyan = require('bunyan');
const _ = require('lodash'); const _ = require('lodash');
const superagent = require('superagent');
const ipc = electron.ipcRenderer; const ipc = electron.ipcRenderer;
@ -110,27 +108,25 @@ function fetch() {
}); });
} }
function publish(rawContent) { const DEBUGLOGS_API_URL = 'https://debuglogs.org';
const content = rawContent || fetch(); const publish = async (content) => {
const credentialsResponse = await superagent.get(DEBUGLOGS_API_URL);
return new Promise((resolve) => { const { fields, url } = credentialsResponse.body;
const payload = textsecure.utils.jsonThing({ const uploadRequest = superagent.post(url);
files: { Object.entries(fields).forEach(([key, value]) => {
'debugLog.txt': { uploadRequest.field(key, value);
content,
},
},
}); });
// eslint-disable-next-line more/no-then const contentBuffer = Buffer.from(content, 'utf8');
$.post('https://api.github.com/gists', payload) uploadRequest.attach('file', contentBuffer, {
.then((response) => { contentType: 'text/plain',
console._log('Posted debug log to ', response.html_url); filename: 'signal-desktop-debug-log.txt',
resolve(response.html_url);
})
.fail(resolve);
}); });
}
await uploadRequest;
return `${DEBUGLOGS_API_URL}/${fields.key}`;
};
// A modern logging interface for the browser // A modern logging interface for the browser

Loading…
Cancel
Save