Add code for submitting debug logs
We keep the last 1000 log messages in memory and dump them to an anonymous public gist if console.post is called. // FREEBIE
This commit is contained in:
parent
fa0e2584f4
commit
f74a7b9621
2 changed files with 38 additions and 0 deletions
|
@ -256,6 +256,7 @@
|
|||
<button class='minimize'>−</button>
|
||||
<button class='close'>×</button>
|
||||
</script>
|
||||
<script type="text/javascript" src="js/debugLog.js"></script>
|
||||
<script type="text/javascript" src="js/components.js"></script>
|
||||
<script type="text/javascript" src="js/database.js"></script>
|
||||
<script type="text/javascript" src="js/storage.js"></script>
|
||||
|
|
37
js/debugLog.js
Normal file
37
js/debugLog.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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;
|
||||
console.log = function(thing){
|
||||
console._log(thing);
|
||||
if (debugLog.length > MAX_MESSAGES) {
|
||||
debugLog.shift();
|
||||
}
|
||||
var str = ('' + thing).replace(PHONE_REGEX, "+[REDACTED]$1");
|
||||
debugLog.push(str);
|
||||
};
|
||||
console.get = function() {
|
||||
return debugLog.join('\n');
|
||||
};
|
||||
console.post = function(log) {
|
||||
if (log === undefined) {
|
||||
log = console.get();
|
||||
}
|
||||
return new Promise(function(resolve) {
|
||||
$.post('https://api.github.com/gists', textsecure.utils.jsonThing({
|
||||
"public": true,
|
||||
"files": { "debugLog.txt": { "content": log } }
|
||||
})).then(function(response) {
|
||||
console._log('Posted debug log to ', response.html_url);
|
||||
resolve(response.html_url);
|
||||
}).fail(resolve);
|
||||
});
|
||||
};
|
||||
}
|
||||
})();
|
Loading…
Reference in a new issue