Hi list, I created a library for debugging/logging. I released the code under GPL license at my site: http://www.riunx.com Please fill free to use it and give feedback.
Sincerely, Meir (falafel)
Hi list, I created a library for debugging/logging. I released the code under GPL license at my site: http://www.riunx.com Please fill free to use it and give feedback.
Sincerely, Meir (falafel)
A few suggestions:
#define
macros for triggering the logging, because then you won't get an overhead when the logging is offPrint
object in the constructor, so the user can choose which Print
er he wants to dedicate to logging.I threw some code together:
#define LOG(logsetup,level,text) if (logsetup.logLevel>=level){logsetup.printer->println(text);}
enum LogLevel {
LOG_DISABLED,
LOG_CRITICAL,
LOG_ERROR,
LOG_WARNING,
LOG_INFO
};
struct LogSetup {
LogSetup(Print &print, LogLevel level) {
printer = &print;
logLevel = level;
}
Print* printer;
LogLevel logLevel;
};
void setup() {
Serial.begin(9600);
LogSetup logSetup(Serial,LOG_ERROR);
LOG(logSetup,LOG_CRITICAL,"test");
}
void loop() { /*no loop*/ }
This will add an if check, so a bit overhead is introduced.
Thanks, I will see how to implement the things you pointed out.
I would like to avoid the overhead on the users .pde file an I also prefer short commands with minimum arguments.
I see the need for both approaches.
I would try to use conditional loading in order to reduce the footprint of the code.
Cool!
Good luck, and report back when you want some more feedback?
BTW: Sorry for highjacking your thread with that Logthingy :)