-
Notifications
You must be signed in to change notification settings - Fork 108
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
Improved logging #355
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.logLevel
is a string used to silence unwanted logsoptions.log
can be an object with{debug, verbose, info, warn, error}
methodsoptions.log
is a function, its arguments are(level, message)
options.log
is undefined, theconsole
methods are used by defaultoptions.log
is falsy (oroptions.silent
is truthy), log messages are silencedError
objectLog levels
The valid values for
options.logLevel
are based off winston, minus thesilly
level 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.logLevel
equalsverbose
, onlydebug
logs are silenced. Likewise, ifoptions.logLevel
equalserror
, onlyerror
logs are not silenced.The default value of
options.logLevel
isinfo
, but you could argue thatdebug
is 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_status
changefeed returned an errorserver_status
The
debug
events are always followed by anerror
event, which emits the stack trace.'error' event
I added an
error
event to the PoolMaster. This allows the end user to do whatever they like with theError
object (as requested in #325). My use case for this is overridingError.prepareStackTrace
to preserve the callsite objects, listening to theerror
event, 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.