-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Improve util.deprecate #1883
Comments
Why do we need the prefix? Can you include an example where it would be useful? |
Look at line 6 of https://gist.github.com/silverwind/a94589df8e3aae1907e1, do you think an outsider would know what to do based on that message, especially when they happen during something like |
Oh okay. You mean |
No, I mean a prefix that clearly identifies that the line was logged by node. For multiple prints: I want to keep the functionality to only prince once per function call, of course. Multiple messages should be opt-in through the flag. |
👍 |
@silverwind What if other libraries start using |
Can't the existing |
@thefourtheye I think the intention is to move to an internal module eventually, @vkurchatkin had it moved in a recent PR if I recall correctly. |
@cjihrig +1 on incorporating multiple prints into |
@silverwind no, it is just a helper function.
This is already available with
This could be just a part of the message
+0 |
Right, I didn't realize we were exposing this knowingly in the public API, so it's probably best to include the |
People who want a public API should probably just use the |
Right, but that doesn't really defer much from the fact that this already is public API. The goal of what I was originally talking about was to better highlight spots where user code uses deprecated core APIs. However, I had forgotten about |
@dougwilson we gotta live with it being public now, or go through a tedious deprecation process of questionable benefit. @Fishrock123 I didn't know about it either, but I think the default message should at least include the prefix and line number. The case of deprecation messages during |
@silverwind The PR has the prefix change already. As we anyway extract the file name and line number from the stack trace, shall I just print them in normal deprecation warning as well? |
I included a commit in the PR which will be actually printing the location where the deprecated item is used. |
Changes included in this commit are 1. Making the deprecation messages consistent. The messages will be in the following format x is deprecated. Use y instead. If there is no alternative for `x`, then the ` Use y instead.` part will not be there in the message. 2. All the internal deprecation messages are printed with the prefix `(node) `, except when the `--trace-deprecation` flag is set. Fixes: #1883 PR-URL: #1892 Reviewed-By: Roman Reiss <[email protected]>
Fixed by 9cd44bb with what was reasonable to change. |
Changes included in this commit are 1. Making the deprecation messages consistent. The messages will be in the following format x is deprecated. Use y instead. If there is no alternative for `x`, then the ` Use y instead.` part will not be there in the message. 2. All the internal deprecation messages are printed with the prefix `(node) `, except when the `--trace-deprecation` flag is set. Fixes: nodejs#1883 PR-URL: nodejs#1892 Reviewed-By: Roman Reiss <[email protected]>
As discussed in IRC recently with @Fishrock123 it would be nice if the deprecation messages contain a bit more info. Particulary I'd like to see
filename:linenumber
where it happens in userland code. I think this could be parsed off the stack throughnew Error().stack
or similar, suggestions welcome.(node)
to identify where the messages come from.-print-all-deprecations
to allow more than one print per deprecation to track down all places where it's happening.The text was updated successfully, but these errors were encountered: