-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Log levels #590
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
Log levels #590
Changes from all commits
bf41bab
a325f24
95c3826
9f76656
f328c33
869b155
b478bb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
"Uint8Array": true | ||
}, | ||
"rules": { | ||
"strict": [2, "global"] | ||
"strict": [2, "global"], | ||
"no-console": [2] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright 2012-2016, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var config = require('../plot_api/plot_config'); | ||
|
||
var loggers = module.exports = {}; | ||
|
||
/** | ||
* ------------------------------------------ | ||
* debugging tools | ||
* ------------------------------------------ | ||
*/ | ||
|
||
/* eslint-disable no-console */ | ||
loggers.log = function() { | ||
if(config.logging > 1) { | ||
var messages = ['LOG:']; | ||
|
||
for(var i = 0; i < arguments.length; i++) { | ||
messages.push(arguments[i]); | ||
} | ||
|
||
if(console.trace) { | ||
console.trace.apply(console, messages); | ||
} else { | ||
console.log.apply(console, messages); | ||
} | ||
} | ||
}; | ||
|
||
loggers.warn = function() { | ||
if(config.logging > 0) { | ||
var messages = ['WARN:']; | ||
|
||
for(var i = 0; i < arguments.length; i++) { | ||
messages.push(arguments[i]); | ||
} | ||
|
||
if(console.trace) { | ||
console.trace.apply(console, messages); | ||
} else { | ||
console.log.apply(console, messages); | ||
} | ||
} | ||
}; | ||
|
||
loggers.error = function() { | ||
if(config.logging > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No prefix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was mainly because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the prefix would be useful for users that want to capture the console and process the messages. |
||
var messages = ['ERROR:']; | ||
|
||
for(var i = 0; i < arguments.length; i++) { | ||
messages.push(arguments[i]); | ||
} | ||
|
||
console.error.apply(console, arguments); | ||
} | ||
}; | ||
/* eslint-enable no-console */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I'd vote for leaving this block up until September and then remove it.