-
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
Use logging library instead of logging to console.error #325
Comments
This is already available. You can just listen to the |
You completely ignored most of my comments. |
See inline:
I strongly disagree with that. The default should be a good one that covers the most common use case.
Node has a micro libraries ecosystem. I don't see a good reason to make rethinkdbdash depends on other libraries that it doesn't need.
You can do that. There's no reason to change the default for that.
This is already available. I'm not sure to understand what's your point? That the default is bad? |
The common use case should for a library to be silent regarding the console. When you build an express app, express doesn't automatically log to the console that it's listening for requests (especially to STDERR). The programmer does that herself in the listen callback if she wants to. In fact, there isn't even an option for express to do that automatically. The messages that rethinkdbdash outputs to the console are really debugging messages. They're only suitable for when you are debugging your app or maybe logging to a file or syslog. (By the way, express uses the debug module, too.) If rethinkdbdash was a CLI application, then it would be completely fine to write to the console, and that's what users would expect it to do. Writing to the console belongs to the domain of applications, not libraries. It's very strange for a library to start writing error messages to the console. That should only happen if the DEBUG environment variable is set. I can't even think of any other library that writes to the console (unless it has a CLI). A So, yes. The default is bad, and logging to the console really shouldn't be an option, and certainly writing to STDERR when there wasn't really an error is bad too, and emitting a |
Can you propose an API first? I feel like we won't be able to make much progress without that. |
@neumino : What I'm struggling with is the coarseness of doing something like Currently, afaik, there's really no way to discern between logging messages (e.g.: entering slow grow mode) or actual errors. Part of the beauty of using logging libraries like Winston is that you can redirect certain log messages based on their loglevel (debug, info, warn, error, etc.) Encoding logs including a loglevel would go a long way in being able to at least work on top of that. E.g.: something like
Thoughts? |
That's fine for me, but the hard part is figuring out what's INFO, WARN and ERROR. |
Follow those guidelines and you should be good. |
Please do a pass on all error messages such that we can discuss a precise API. |
It's generally bad practice for a module to log to the console by default, especially if it is logging information as errors.
Consider using logging modules like debug and winston and make
{silent: true}
the default.Errors don't need to be logged, instead they should be thrown or sent as a callback parameter. It's up to the programmer who is using your library to handle and log errors. If your library encounters an error that it can gracefully handle and does not 'break' the application, consider logging it as a warning. (#316)
Allow users to configure the logging options by exposing a
log
property on theoptions
object. This could be passed towinston.configure
for example. This will give users the option to log to the console, or to a file, or to syslog, and even choose what logging levels they want (e.g. info, warn, error, debug, etc.).See also #292, #320.
The text was updated successfully, but these errors were encountered: