Skip to content

Commit fcad13a

Browse files
committed
Merge pull request #229 from zaizhuang/debugging
Only log to console.error when Raven.debug is true
2 parents 116e12a + 173ae2c commit fcad13a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/raven.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var _Raven = window.Raven,
3131
var Raven = {
3232
VERSION: '<%= pkg.version %>',
3333

34+
debug: true,
35+
3436
/*
3537
* Allow multiple versions of Raven to be installed.
3638
* Strip Raven from the global context and returns the instance.
@@ -679,7 +681,7 @@ function makeRequest(data) {
679681
function isSetup() {
680682
if (!hasJSON) return false; // needs JSON support
681683
if (!globalServer) {
682-
if (window.console && console.error) {
684+
if (window.console && console.error && Raven.debug) {
683685
console.error("Error: Raven has not been configured.");
684686
}
685687
return false;

test/raven.test.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,27 @@ describe('globals', function() {
215215
assert.isFalse(isSetup());
216216
});
217217

218-
it('should return false when Raven is not configured and write to console.error', function() {
218+
it('should return false when Raven is not configured', function() {
219219
hasJSON = true; // be explicit
220220
globalServer = undefined;
221221
this.sinon.stub(console, 'error');
222222
assert.isFalse(isSetup());
223+
});
224+
225+
it('should not write to console.error when Raven is not configured and Raven.debug is false', function() {
226+
hasJSON = true; // be explicit
227+
globalServer = undefined;
228+
Raven.debug = false;
229+
this.sinon.stub(console, 'error');
230+
isSetup();
231+
assert.isFalse(console.error.calledOnce);
232+
});
233+
234+
it('should write to console.error when Raven is not configured and Raven.debug is true', function() {
235+
hasJSON = true; // be explicit
236+
globalServer = undefined;
237+
this.sinon.stub(console, 'error');
238+
isSetup();
223239
assert.isTrue(console.error.calledOnce);
224240
});
225241

0 commit comments

Comments
 (0)