Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化控制台错误在 sentry BREACRUMBS 中的显示 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 36 additions & 31 deletions build/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,49 @@ module.exports = RavenConfigError;
},{}],2:[function(require,module,exports){
'use strict';

var wrapMethod = function(console, level, callback) {
var originalConsoleLevel = console[level];
var originalConsole = console;
var wrapMethod = function (console, level, callback) {
var originalConsoleLevel = console[level];
var originalConsole = console;

if (!(level in console)) {
return;
}

var sentryLevel = level === 'warn' ? 'warning' : level;
if (!(level in console)) {
return;
}

console[level] = function() {
var args = [].slice.call(arguments);
var sentryLevel = level === 'warn' ? 'warning' : level;

var msg = '' + args.join(' ');
var data = {level: sentryLevel, logger: 'console', extra: {arguments: args}};
console[level] = function () {
var args = [].slice.call(arguments);

if (level === 'assert') {
if (args[0] === false) {
// Default browsers message
msg = 'Assertion failed: ' + (args.slice(1).join(' ') || 'console.assert');
data.extra.arguments = args.slice(1);
callback && callback(msg, data);
}
} else {
callback && callback(msg, data);
}
var msg = '' + args.map(function(arg) {
if (typeof arg === 'object') {
return JSON.stringify(arg);
}
return arg;
}).join(' ');
var data = { level: sentryLevel, logger: 'console', extra: { arguments: args } };

if (level === 'assert') {
if (args[0] === false) {
// Default browsers message
msg = 'Assertion failed: ' + (args.slice(1).join(' ') || 'console.assert');
data.extra.arguments = args.slice(1);
callback && callback(msg, data);
}
} else {
callback && callback(msg, data);
}

// this fails for some browsers. :(
if (originalConsoleLevel) {
// IE9 doesn't allow calling apply on console functions directly
// See: https://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function#answer-5473193
Function.apply.call(originalConsoleLevel, originalConsole, args);
}
};
// this fails for some browsers. :(
if (originalConsoleLevel) {
// IE9 doesn't allow calling apply on console functions directly
// See: https://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function#answer-5473193
Function.apply.call(originalConsoleLevel, originalConsole, args);
}
};
};

module.exports = {
wrapMethod: wrapMethod
wrapMethod: wrapMethod
};

},{}],3:[function(require,module,exports){
Expand Down Expand Up @@ -3121,4 +3126,4 @@ function serializer(replacer, cycleReplacer) {
}

},{}]},{},[4])(4)
});
});
Loading