Skip to content

Commit

Permalink
Merge pull request #229 from zaizhuang/debugging
Browse files Browse the repository at this point in the history
Only log to console.error when Raven.debug is true
  • Loading branch information
mattrobenolt committed Jul 16, 2014
2 parents 116e12a + 173ae2c commit fcad13a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var _Raven = window.Raven,
var Raven = {
VERSION: '<%= pkg.version %>',

debug: true,

/*
* Allow multiple versions of Raven to be installed.
* Strip Raven from the global context and returns the instance.
Expand Down Expand Up @@ -679,7 +681,7 @@ function makeRequest(data) {
function isSetup() {
if (!hasJSON) return false; // needs JSON support
if (!globalServer) {
if (window.console && console.error) {
if (window.console && console.error && Raven.debug) {
console.error("Error: Raven has not been configured.");
}
return false;
Expand Down
18 changes: 17 additions & 1 deletion test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,27 @@ describe('globals', function() {
assert.isFalse(isSetup());
});

it('should return false when Raven is not configured and write to console.error', function() {
it('should return false when Raven is not configured', function() {
hasJSON = true; // be explicit
globalServer = undefined;
this.sinon.stub(console, 'error');
assert.isFalse(isSetup());
});

it('should not write to console.error when Raven is not configured and Raven.debug is false', function() {
hasJSON = true; // be explicit
globalServer = undefined;
Raven.debug = false;
this.sinon.stub(console, 'error');
isSetup();
assert.isFalse(console.error.calledOnce);
});

it('should write to console.error when Raven is not configured and Raven.debug is true', function() {
hasJSON = true; // be explicit
globalServer = undefined;
this.sinon.stub(console, 'error');
isSetup();
assert.isTrue(console.error.calledOnce);
});

Expand Down

0 comments on commit fcad13a

Please sign in to comment.