-
-
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
Conversation
@@ -9,6 +9,7 @@ | |||
"Uint8Array": true | |||
}, | |||
"rules": { | |||
"strict": [2, "global"] | |||
"strict": [2, "global"], | |||
"no-console": [1] |
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.
let's make this a [2]
.
}; | ||
|
||
loggers.error = function() { | ||
if(config.logging > 0) { |
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.
No prefix 'ERROR:'
?
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.
Was mainly because console.error
marks it red as an error. Should I add it for consistency?
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.
I think the prefix would be useful for users that want to capture the console and process the messages.
💃 |
**It is important to note that logging is turned off by default in v1.13.0 onwards.** | ||
To turn logging on for development, you will want to run | ||
`Plotly.setPlotConfig({ logging: 2 })` before any plotting. | ||
See [this file](https://github.com/plotly/plotly.js/blob/master/src/lib/loggers.js) for more details. |
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.
Resolves #565.
In brief:
Lib.markTime
calls - these can be done usingconsole.time
andconsole.timeEnd
while developing, then should be removed before committing/pushingLib.log
,Lib.warn
, andLib.error
which can be toggled by setting thelogging
config value1
2
There is a downside: the line number when logged shows up as from the
lib/index.js
file. I have somewhat "fixed" this by having stack traces printed with logs, but it is not ideal (in my mind) and the methods for circumventing this aren't very robust and don't work withstrict mode
(usingarguments.caller.callee
or overwritingError.prepareStackTrace
).I think any downsides (i.e. having to click to see the stacktrace on a log message) is worth the benefits of keeping the library quiet in a production setting.