Skip to content
Merged
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
6 changes: 3 additions & 3 deletions plugins/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ var logForGivenLevel = function(level) {
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.prototype.bind
.call(originalConsoleLevel, originalConsole)
.apply(originalConsole, args);
Function.prototype.bind
.call(originalConsoleLevel, originalConsole)
.apply(originalConsole, args);
}
};
};
Expand Down
8 changes: 5 additions & 3 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ var _Raven = window.Raven,
},
authQueryString,
isRavenInstalled = false,

objectPrototype = Object.prototype,
// capture a reference to window.console first before
// the console plugin has a chance to monkey patch
originalConsole = window.console || {},
startTime = now();

/*
Expand Down Expand Up @@ -850,10 +852,10 @@ function uuid4() {
}

function logDebug(level) {
if (window.console && console[level] && Raven.debug) {
if (originalConsole[level] && Raven.debug) {
// _slice is coming from vendor/TraceKit/tracekit.js
// so it's accessible globally
console[level].apply(console, _slice.call(arguments, 1));
originalConsole[level].apply(originalConsole, _slice.call(arguments, 1));
}
}

Expand Down
11 changes: 6 additions & 5 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function flushRavenState() {
},
startTime = 0;
ravenNotConfiguredError = undefined;
originalConsole = window.console || {};

Raven.uninstall();
}
Expand Down Expand Up @@ -325,21 +326,21 @@ describe('globals', function() {

it('should not write to console when Raven.debug is false', function() {
Raven.debug = false;
this.sinon.stub(console, level);
this.sinon.stub(originalConsole, level);
logDebug(level, message);
assert.isFalse(console[level].called);
assert.isFalse(originalConsole[level].called);
});

it('should write to console when Raven.debug is true', function() {
Raven.debug = true;
this.sinon.stub(console, level);
this.sinon.stub(originalConsole, level);
logDebug(level, message);
assert.isTrue(console[level].calledOnce);
assert.isTrue(originalConsole[level].calledOnce);
});

it('should handle variadic arguments', function() {
Raven.debug = true;
this.sinon.stub(console, level);
this.sinon.stub(originalConsole, level);
logDebug(level, message, {}, 'foo');
});
});
Expand Down