From e26be0c9d373228bf78513da0aeba97819fecf2e Mon Sep 17 00:00:00 2001 From: Zaizhuang Cheng Date: Wed, 16 Jul 2014 11:16:37 -0700 Subject: [PATCH 1/2] Only log to console.error when debug is true --- src/raven.js | 4 +++- test/raven.test.js | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/raven.js b/src/raven.js index b1ad67a4e457..4e789bcf0801 100644 --- a/src/raven.js +++ b/src/raven.js @@ -31,6 +31,8 @@ var _Raven = window.Raven, var Raven = { VERSION: '<%= pkg.version %>', + debug: false, + /* * Allow multiple versions of Raven to be installed. * Strip Raven from the global context and returns the instance. @@ -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; diff --git a/test/raven.test.js b/test/raven.test.js index f65fb38bb264..24aa86a98306 100644 --- a/test/raven.test.js +++ b/test/raven.test.js @@ -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; + 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 + Raven.debug = true; + globalServer = undefined; + this.sinon.stub(console, 'error'); + isSetup(); assert.isTrue(console.error.calledOnce); }); From 173ae2c564ba37e3b1ee513df58c9101babb9566 Mon Sep 17 00:00:00 2001 From: Zaizhuang Cheng Date: Wed, 16 Jul 2014 11:39:18 -0700 Subject: [PATCH 2/2] Default debug to true --- src/raven.js | 2 +- test/raven.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/raven.js b/src/raven.js index 4e789bcf0801..e5f8780c3a4e 100644 --- a/src/raven.js +++ b/src/raven.js @@ -31,7 +31,7 @@ var _Raven = window.Raven, var Raven = { VERSION: '<%= pkg.version %>', - debug: false, + debug: true, /* * Allow multiple versions of Raven to be installed. diff --git a/test/raven.test.js b/test/raven.test.js index 24aa86a98306..b5c42496a15e 100644 --- a/test/raven.test.js +++ b/test/raven.test.js @@ -225,6 +225,7 @@ describe('globals', function() { 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); @@ -232,7 +233,6 @@ describe('globals', function() { it('should write to console.error when Raven is not configured and Raven.debug is true', function() { hasJSON = true; // be explicit - Raven.debug = true; globalServer = undefined; this.sinon.stub(console, 'error'); isSetup();