-
Notifications
You must be signed in to change notification settings - Fork 212
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
Changing _ESPLOGLEVEL_ requires editing debug.h #88
Comments
Fix committed |
This is incorrect. The debug macros are used by a different compilation unit from the sketch. The macro defined in the sketch will not be defined in EspDrv.cpp and so I think it would be a huge improvement to this library to allow the user to control debug output from the sketch. There is a way to do this. You need to put all the code that uses the debug macros in the header file where the macro defined in the sketch will take effect. |
per1234- you are right, of course. The various .cpp files of the library are separate compilation units and thus won't see the #define in the sketch. However, it's not clear to me the cure is any better than the disease. Because the various debug/logging macros are used extensively in the code, large fractions of the code will have to be moved to the .h file. For example, nearly the entire EspDrv.cpp file will have to be moved to EspDrv.h. While this would be valid (ie, compilable) code, it is unusual to see so much code in a header file. A better solution would be for the IDE to standardize the use of debug/logging flags, as this is almost certainly not the only library where this capability would be useful. The IDE would then provide a means to set the flag and pass the value to the compiler. A general means to pass -D options to the compiler would be powerful, but risks confusing novice users of the IDE. |
Well I see four options:
The best option seems quite clear to me. I regularly recommend this library to people on the Arduino forum but always must go into a long explanation of this debug output issue so I would like to see it fixed. |
if
|
Sure, or you can even add a custom Tools menu to change the level if you like but this is not a reasonable thing to expect from the average user who's just trying to use the library with their ESP8266 shield. |
To make this work by moving code into the header file will require moving the entire code into a single header file. As long as there are multiple compilation units, the problem will remain, just in a different form. Of the choices in per1234's message, I favor option 3 with |
+1 to enable/disable the debug level from the sketch |
Of course, this is not the end of the world, but if debug.h contained
then if the user defines ESPLOGLEVEL before
#include "WiFiEsp.h"
then the user value will be used.
(Or so I think unless I'm having brain spasm.)
The text was updated successfully, but these errors were encountered: