-
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
Alternative fix for #1501 #1539
Conversation
I guess we can prevent multiple return by
IMHO problem with direct log without a msg
can be omitted, cause we have msg as a required parameter in the method declaration |
Glad you agree with me about W.r.t. your comment regarding multiple returns – returning early is faster than appending to an array. Performance is the most important aspect of these helper methods. If the code is slightly more verbose that's not as much of an issue. These methods will get invoked dozens or hundreds of times per second in a typical web server so every nanosecond counts. |
@indexzero thanks for your explaining about performance. Waiting for your fix in the published to npm version. |
Once we get a test for this we can land it and publish. |
@indexzero any updates? |
Sorry this got overlooked in |
…s are invoked with no arguments.
* [wip fix] Assume message is the empty string when level-helper methods are invoked with no arguments. * [fix] Add test for winstonjs#1501.
@pahan35 interested in your thoughts. Your fix could also work, but this one is more performant.
Assuming implicit argument values is also quite dangerous, but since the level helper methods (e.g.
logger.silly('wat ok')
) were created to be a little magical it seems reasonable to assume that these two statements are equivalent:Where our fixes differ is that this behavior will still crash someone's program:
It would crash because the
log
method is not being invoked with the correct number of arguments – which avoids having to add additional variable-arity or type checking into the corelog
method hot path.If there are no objections will add some tests for this and push it out in the next release.