Added traceback on remote error logging.

This commit is contained in:
Martin Edenhofer 2016-05-17 19:02:40 +02:00
parent f9c20e582e
commit 7f39927506
2 changed files with 25 additions and 14 deletions

View file

@ -150,12 +150,7 @@ class _trackSingleton
log: newDataNew
)
crossDomain: true
# success: (data, status, xhr) =>
# @data = []
# console.log('done')
error: =>
# queue all data
for item in newDataNew
@data.push item
)
@ -174,35 +169,51 @@ class _trackSingleton
`
(function() {
window.getStackTrace = function() {
var stack
try {
throw new Error('')
}
catch (error) {
stack = error.stack || ''
}
stack = stack.split('\n').map(function (line) { return line.trim() })
return stack.splice(stack[0] == 'Error' ? 2 : 1)
}
window.onerrorOld = window.onerror
window.onerror = function(errorMsg, url, lineNumber) {
console.error(errorMsg + " - in " + url + ", line " + lineNumber);
console.error(errorMsg + " - in " + url + ", line " + lineNumber + "\n" + window.getStackTrace().join('\n'));
if (window.onerrorOld) {
window.onerrorOld(errorMsg, url, lineNumber);
window.onerrorOld(errorMsg, url, lineNumber)
}
return true
}
}).call(this);
(function() {
var console = window.console
if (!console) return
function intercept(method){
var original = console[method]
console[method] = function(){
//alert('new m' + method)
App.Track.log(
'console.' + method,
method,
arguments
)
if (method == 'error') {
App.Track.log(
'traceback',
method,
window.getStackTrace().join('\n')
)
}
// do sneaky stuff
if (original.apply){
// Do this for normal browsers
original.apply(console, arguments)
}
else{
else {
// Do this for IE
var message = Array.prototype.slice.apply(arguments).join(' ')
original(message)

View file

@ -154,11 +154,11 @@ function clone(item, full) {
}
// taken from https://github.com/epeli/underscore.string/blob/master/underscored.js
function underscored (str) {
function underscored(str) {
return str.trim().replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
}
function toCamelCase (str) {
function toCamelCase(str) {
return str
.replace(/\s(.)/g, function($1) { return $1.toUpperCase(); })
.replace(/\s/g, '')