Skip to content

Why not add jsDebug as jsWarn when RELEASE is not set #1877

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

Closed
MaBecker opened this issue Jul 12, 2020 · 4 comments
Closed

Why not add jsDebug as jsWarn when RELEASE is not set #1877

MaBecker opened this issue Jul 12, 2020 · 4 comments

Comments

@MaBecker
Copy link
Contributor

MaBecker commented Jul 12, 2020

This implementation in a central point allows to use jsDebug during development and if RELEASE it is gone.

#ifndef RELEASE
#define jsDebug(format, ...) jsWarn(format, ## __VA_ARGS__)
#else
#define jsDebug(format, ...) do { } while(0)
#endif

  • So no more #ifndef RELASE ..... #endif to get ride of warnings.

  • It is still possible to use jsWarn() if wanted.

Would /src/jsutils.h be the correct place to add this?

@MaBecker
Copy link
Contributor Author

Or call it jsDevInfo() because this is really what it is.

@gfwilliams
Copy link
Member

That sounds like a great idea - maybe stick it up in jsutils.h near jsAssertFail - and I'd use jsiConsolePrintf (unless jsWarn is there just for ESP8266 memory issues).

What about something like:

#if defined(DEBUG) || __FILE__==DEBUG_FILE
   #define jsDebug(format, ...) jsiConsolePrintf("[" __FILE__ "]:" format, ## __VA_ARGS__) 
 #else 
   #define jsDebug(format, ...) do { } while(0) 
 #endif 

Untested but the idea is:

  • Debug statements only in there if you compile with DEBUG=1 (which you'd do for debugging)
  • OR if you do DEBUG_FILE="src/jsflash.c" make then you can get a build with just the debug prints in that file.

The big chunk of work is really just changing all the prints all over the code to jsDebug though :)

One final suggestion: Is it worth actually having a first argument:

jsDebug(DBG_INFO, format, ...) and jsDebug(DBG_VERBOSE, format, ...)

Even if we ignore it for now, just so that we don't spam the console unless it's absolutely required.

@MaBecker
Copy link
Contributor Author

Cool, so let's give it a try.

@MaBecker
Copy link
Contributor Author

implemented with #1880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants