2015-09-16 03:48:49 +02:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
|
|
|
*/
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
var MAX_MESSAGES = 1000;
|
|
|
|
var PHONE_REGEX = /\+\d{7,12}(\d{3})/g;
|
|
|
|
var debugLog = [];
|
|
|
|
if (window.console) {
|
|
|
|
console._log = console.log;
|
2015-09-16 20:09:16 +02:00
|
|
|
console.log = function(){
|
|
|
|
console._log.apply(this, arguments);
|
2015-09-16 03:48:49 +02:00
|
|
|
if (debugLog.length > MAX_MESSAGES) {
|
|
|
|
debugLog.shift();
|
|
|
|
}
|
2015-09-16 20:09:16 +02:00
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
var str = args.join(' ').replace(PHONE_REGEX, "+[REDACTED]$1");
|
2015-09-16 03:48:49 +02:00
|
|
|
debugLog.push(str);
|
|
|
|
};
|
|
|
|
console.get = function() {
|
2015-12-29 22:41:43 +01:00
|
|
|
return window.navigator.userAgent + '\n' + debugLog.join('\n');
|
2015-09-16 03:48:49 +02:00
|
|
|
};
|
|
|
|
console.post = function(log) {
|
|
|
|
if (log === undefined) {
|
|
|
|
log = console.get();
|
|
|
|
}
|
|
|
|
return new Promise(function(resolve) {
|
|
|
|
$.post('https://api.github.com/gists', textsecure.utils.jsonThing({
|
|
|
|
"files": { "debugLog.txt": { "content": log } }
|
|
|
|
})).then(function(response) {
|
|
|
|
console._log('Posted debug log to ', response.html_url);
|
|
|
|
resolve(response.html_url);
|
|
|
|
}).fail(resolve);
|
|
|
|
});
|
|
|
|
};
|
2015-12-07 22:42:19 +01:00
|
|
|
|
|
|
|
window.onerror = function(message, script, line, col, error) {
|
|
|
|
console.log(error);
|
|
|
|
};
|
2015-09-16 03:48:49 +02:00
|
|
|
}
|
|
|
|
})();
|