Is there a default logging 'rule' for Arduino projects? In Java for example there are logging functions and regulation to debug code efficiently. There is also the possibility to define logging depths.
In my Arduino projects I usually use "Serial.print(xxx)" wherever I want. This is convenient for a few files, but a pain to uncomment everything when the project is done.
I wrote a simple "Logging" class. The print functions can be deactivated setting the "Debuglog=0". This method needs unnecessary memory and is in my opinion only a quick and dirty solution.
Is there a better way on excluding certain parts of the functions? Similar to
#if defined(DEBUGLOG)
// code
#endif
This is only allowed in header-files and yields no effect in functions (I tried).
My Testcode replaced the function "void Logger::log(char* c)". Also the variable "DEBUGLOG" would be in the "main.cpp" and can be commented/ uncommented if needed.
void Logger::log(char* c) {
#if defined(DEBUGLOG)
Serial.println(c);
#endif
}