-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Public log tracing functionality #4361
Conversation
Should they be exported in debug build only? |
Ideally not, for the same reason as Debug.setTrace is enabled in all builds. from outside, people should be able to have code like
in both builds, but it should be a no cost at release. I don't want them to have to comment out the code to run using release. |
Right, yes of course. Could be confusing for devs that attempt to use this API and don't realise it only works in debug build. |
Just checking I actually think all the Debug function implementations should have |
This part of the build process is responsible for removing the functions, and calls to the functions, from the code base, so there is no need to wrap them using Lines 129 to 144 in d7884b0
setTrace are done differently as we don't want to remove them from non-debug builds. |
Looking at the built |
(strip removes the call sites, not the functions themselves). |
Hey you're right. I've just tested it .. it strips the functions themselves if I don't export Debug module from the index.js. But as soon as I do that, they're no longer stripped - which kinda makes sense. |
For example, class DebugHelper in the same file is not exported from index, and is completely stripped. |
What I'm thinking is .. keep class Debug not exported by index, so that it gets completely stripped without ifdefs.
@slimbuck @willeastcott - what do you think? |
TBH in general I don't think we should expose empty/non-functional API. I actually think we should either:
|
we only export Debug API set/getTrace, nothing else. Its purpose is to allow them to 'see' under the hood of the engine, to help them understand what happens. It does not give them a logging API they can use to log from their scripts at all. And I think it's very convenient to be able to use those functions in any build (even though in non-debug build they are ignored). Even I use them in the engine when I work on things (that way they work with any example I run), and the code does not fail to run in release build. |
Surely enabling trace in an application is a something temporary you do when developing and not something you'd wish to keep in application code? |
It is, but having it in the code should not stop you running the build with the release engine. Having to go and comment it out is not user friendly, especially if you have few in different places. So far all the APIs we have work with any engine build. For example even the profiling stats classes exist .. but their members (timings) are simply not updated. |
I've made changes I suggested. Opinions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely. ❤️
changes:
new API: