-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
Update logger to build logging function without Eval #2
Conversation
Merged as 679b4a9 |
Why are there separate log functions for each level anyway? Removing that requirement would alleviate the scoping issue with the level variable and such. |
Because I didn't like the design in Qpsmtpd of having ->log(LEVEL, msg) and just prefer separate methods. Just a design decision. |
Optimized and saftety checked log function creation code
OK, so this patch still didn't work. I think it might actually be a bug in v8 though - there may be a premature optimisation of string.splice(0) just returning the same string object. I wonder if doing it via new String() might work though... |
Actually this was from a bug I didn't catch in my patch. It was causing the loglevel to always be compared to a dynamic referenced version of key_copy in such a way that it always compared itself to 0 (and thus always logged everything). I also realized the key.slice(0) wasn't needed as it returns the exact same string, so I factored it out and both commits are now available on my fork. |
Only non-primitive types ("objects", arrays, functions) are handled by reference. However, it is better to just keep the one string around like this last commit does. |
Actually in this case key_copy was specifically being treated as a reference due to it's relation in the built functions. If we add in a log of the value of key_copy to the old code:
and then call the individual log functions:
|
OK, all merged now. |
Updated to use immediate function with state to build logging function for each logging state