Skip to content

Only log to console.error when Raven.debug is true #229

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

Merged
merged 2 commits into from
Jul 16, 2014
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
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