-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Ability to pass in multiple arguments to logging calls? #9
Comments
@pigmej What's your use case for this? Just trying it out to see how it works? The correct way to do this is: var winston = require('winston');
winston.log('info', 'Hello distributed log files!', { 'foo': 'bar', 'list': ['123', '456'] }); I'm trying not to go crazy with the flexibility of the arguments parsing in the core Going to close this. Feel free to reopen it if you can provide a valid usecase. Thanks. |
@indexzero - The issue is that there is a disconnect between winston's logging method and the standard It's pretty standard in JS land to do something like:
I think it's pretty reasonable to emulate this API. There is already code out there for doing the arguments parsing. I would think all we have to do is determine if the last method is a FN or not, if it is, then thats the callback. |
@Marak emulating |
The thing is for example
or Then you don't need to do:
Even if by default winston formats {foo: 'bar'} as foo=bar. |
Errr printf style? No. console.log style? Maybe. |
I am writing server and client side javascript at the same time, and I personally find it really annoying if you have to concatenate everything into one thing. Especially because I forget and stuff disappears from the logs because of it. I already had a factory method to create the logger, and I wrote a wrapper function which first concatenates the arguments before passing it to winston. It seems to work fine. Maybe it's useful to someone... Note that in this example there is only a wrapper for the info function. But the others would work the same way I guess.
|
Just came across this problem as well. Any chance that this will be implemented any time? Or has it maybe already been implemented, hidden behind some secret flag? |
Also just ran into this and it's extremely annoying. Is there any reason why console.log functionality emulation in this area is NOT good? |
Try this
|
I would suggest using ES2015 template literals. For example:
Notice I used back ticks |
@pigmej ran into an issue today in the IRC
I'm assuming this is a simple fix. What do you think indexzero?
The text was updated successfully, but these errors were encountered: