-
Notifications
You must be signed in to change notification settings - Fork 107
Improved logging #355
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
base: master
Are you sure you want to change the base?
Improved logging #355
Conversation
|
I don't see a strong need for Aside from that I think this is pretty fantastic. |
|
@marshall007 Thanks for the feedback! I would argue that |
1cff41f to
50f3321
Compare
|
Small change: When |
|
A few thoughts
|
|
Overall the first 2 points are the main reason why I think it's a bit wonky to have warn/info for rethinkdbdash. I think it's fine to move the draining messages to debug, but the other messages should all be at the same level. |
- `options.logLevel` can be a string, where its value must be 'debug', 'verbose', 'info', 'warn', or 'error'
- `options.log` can be an object with {debug, verbose, info, warn, error} methods
- When `options.log` is a function, its second argument will be the log level of the given message
- When `options.log` is undefined, the `console` methods are used by default
- When `options.log` is falsy (or `options.silent` is truthy), log messages are silenced
- Some log messages have been tweaked, and log levels attached
- The pool master now emits an 'error' event with the associated `Error` object
|
Good points, @neumino! Here's an updated list of log levels per message:
The |
|
@neumino Are there any blockers on getting this merged? Should I update the docs too? |
This provides improved logging, as requested by #325, #351, and #334 (comment).
Overview
options.logLevelis a string used to silence unwanted logsoptions.logcan be an object with{debug, verbose, info, warn, error}methodsoptions.logis a function, its arguments are(level, message)options.logis undefined, theconsolemethods are used by defaultoptions.logis falsy (oroptions.silentis truthy), log messages are silencedErrorobjectLog levels
The valid values for
options.logLevelare based off winston, minus thesillylevel and custom levels.Log levels are assigned an integer representing their importance. This integer is used to silence logs whose log level has an integer of higher value. As an example, if
options.logLevelequalsverbose, onlydebuglogs are silenced. Likewise, ifoptions.logLevelequalserror, onlyerrorlogs are not silenced.The default value of
options.logLevelisinfo, but you could argue thatdebugis more appropriate so the end user can provide more context when something goes wrong.I made my best guesses on which log level should be used for each log-worthy event. Let me know if the classification of any events should be changed.
server_statuschangefeed returned an errorserver_statusThe
debugevents are always followed by anerrorevent, which emits the stack trace.'error' event
I added an
errorevent to the PoolMaster. This allows the end user to do whatever they like with theErrorobject (as requested in #325). My use case for this is overridingError.prepareStackTraceto preserve the callsite objects, listening to theerrorevent, and logging the error as JSON for easier consumption by logging dashboards.If you would like, I can separate this change into its own PR, but I think it's useful and harmless to anyone who doesn't need it.