mirror of
https://github.com/dkgrizzly/GreenSCSI.git
synced 2025-02-10 12:31:17 +00:00
Debug Logging Toggle
Debug Logging disabled by default, On/Off toggle with setvar debug 1/0
This commit is contained in:
parent
0c04852ad8
commit
cf468bcbde
@ -125,6 +125,7 @@ cmdvar_t cmdenv[ENVIRONMENT_SIZE];
|
||||
|
||||
int getvar(const char *varname, int defaultvalue) {
|
||||
if(!strcasecmp(varname, "ERRORLEVEL")) return errorlevel;
|
||||
if(!strcasecmp(varname, "DEBUG")) return debuglog;
|
||||
|
||||
for(int i = 0; i < ENVIRONMENT_SIZE; i++) {
|
||||
if(!strcmp(cmdenv[i].key, varname)) {
|
||||
@ -136,6 +137,7 @@ int getvar(const char *varname, int defaultvalue) {
|
||||
|
||||
char* getvar(const char *varname, char *defaultvalue) {
|
||||
if(!strcasecmp(varname, "ERRORLEVEL")) return NULL;
|
||||
if(!strcasecmp(varname, "DEBUG")) return NULL;
|
||||
|
||||
for(int i = 0; i < ENVIRONMENT_SIZE; i++) {
|
||||
if(!strcasecmp(cmdenv[i].key, varname)) {
|
||||
@ -157,6 +159,7 @@ void setvarcmd(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if(!strcasecmp(argv[1], "ERRORLEVEL")) return;
|
||||
if(!strcasecmp(argv[1], "DEBUG")) { debuglog = strtoul(argv[2], NULL, 0); return; }
|
||||
|
||||
// Find existing variable matching name and replace it
|
||||
for(i = 0; i < ENVIRONMENT_SIZE; i++) {
|
||||
@ -199,6 +202,7 @@ void unsetvarcmd(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if(!strcasecmp(argv[1], "ERRORLEVEL")) return;
|
||||
if(!strcasecmp(argv[1], "DEBUG")) { debuglog = 0; return; }
|
||||
|
||||
// Find existing variable matching name and delete it
|
||||
for(i = 0; i < ENVIRONMENT_SIZE; i++) {
|
||||
@ -229,6 +233,11 @@ void getvarcmd(int argc, char **argv) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!strcasecmp(argv[1], "DEBUG")) {
|
||||
Serial.printf("%d\r\n", debuglog);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0; i < ENVIRONMENT_SIZE; i++) {
|
||||
if(!strcasecmp(cmdenv[i].key, argv[1])) {
|
||||
Serial.printf("%s=%s\r\n", cmdenv[i].key, cmdenv[i].value);
|
||||
|
@ -49,17 +49,19 @@
|
||||
// SDFAT
|
||||
SdFs sd;
|
||||
|
||||
boolean debuglog = 0;
|
||||
|
||||
#if DEBUG == 1
|
||||
#define LOG(XX) Serial.print(XX)
|
||||
#define LOGHEX2(XX) Serial.printf("%02x", XX)
|
||||
#define LOGHEX4(XX) Serial.printf("%04x", XX)
|
||||
#define LOGHEX6(XX) Serial.printf("%06x", XX)
|
||||
#define LOGHEX8(XX) Serial.printf("%08x", XX)
|
||||
#define LOGN(XX) Serial.println(XX)
|
||||
#define LOGHEX2N(XX) Serial.printf("%02x\r\n", XX)
|
||||
#define LOGHEX4N(XX) Serial.printf("%04x\r\n", XX)
|
||||
#define LOGHEX6N(XX) Serial.printf("%06x\r\n", XX)
|
||||
#define LOGHEX8N(XX) Serial.printf("%08x\r\n", XX)
|
||||
#define LOG(XX) if(debuglog) Serial.print(XX)
|
||||
#define LOGHEX2(XX) if(debuglog) Serial.printf("%02x", XX)
|
||||
#define LOGHEX4(XX) if(debuglog) Serial.printf("%04x", XX)
|
||||
#define LOGHEX6(XX) if(debuglog) Serial.printf("%06x", XX)
|
||||
#define LOGHEX8(XX) if(debuglog) Serial.printf("%08x", XX)
|
||||
#define LOGN(XX) if(debuglog) Serial.println(XX)
|
||||
#define LOGHEX2N(XX) if(debuglog) Serial.printf("%02x\r\n", XX)
|
||||
#define LOGHEX4N(XX) if(debuglog) Serial.printf("%04x\r\n", XX)
|
||||
#define LOGHEX6N(XX) if(debuglog) Serial.printf("%06x\r\n", XX)
|
||||
#define LOGHEX8N(XX) if(debuglog) Serial.printf("%08x\r\n", XX)
|
||||
#elif DEBUG == 2
|
||||
#define LOG(XX) LOG_FILE.print(XX); LOG_FILE.sync();
|
||||
#define LOGHEX2(XX) LOG_FILE.printf("%02x", XX); LOG_FILE.sync();
|
||||
|
Loading…
x
Reference in New Issue
Block a user