From d8281e69fd9a8ca8cb719b40e13ab97ce58d56df Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 21 Feb 2018 19:00:42 +0100 Subject: [PATCH] chg: skip printing debug statements when not debugging. chg: started with a coloring of messages. Didn't work super well.. --- client/cmddata.c | 2 +- client/ui.c | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/client/cmddata.c b/client/cmddata.c index 21bc334e8..16a1c9f10 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -1283,7 +1283,7 @@ int CmdRawDemod(const char *Cmd) void setClockGrid(int clk, int offset) { g_DemodStartIdx = offset; g_DemodClock = clk; - PrintAndLogEx(DEBUG, "DBEUG: (setClockGrid) demodoffset %d, clk %d",offset,clk); + PrintAndLogEx(DEBUG, "DEBUG: (setClockGrid) demodoffset %d, clk %d", offset, clk); if (offset > clk) offset %= clk; if (offset < 0) offset += clk; diff --git a/client/ui.c b/client/ui.c index d5d808a22..0d176862c 100644 --- a/client/ui.c +++ b/client/ui.c @@ -23,16 +23,33 @@ pthread_mutex_t print_lock = PTHREAD_MUTEX_INITIALIZER; static char *logfilename = "proxmark3.log"; void PrintAndLogEx(logLevel_t level, char *fmt, ...) { + + // skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG 0' + if (g_debugMode == 0 && level == DEBUG) + return; + char buffer[MAX_PRINT_BUFFER] = {0}; int size = 0; + // {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG} static char *prefix[7] = { "", "[+] ", "[=] ", "[-] ", "[!] ", "[!!] ", "[#] "}; - if (g_debugMode == 0 && level == DEBUG) { - // skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG 0' - } - else { - size = strlen(prefix[level]); - strncpy(buffer, prefix[level], sizeof buffer); + switch( level ) { + case FAILED: + size = strlen( _RED_([-] ) ); + strncpy(buffer,_RED_([-] ), size); + break; + case DEBUG: + size = strlen( _BLUE_([#] ) ); + strncpy(buffer,_BLUE_([#] ), size); + break; + case SUCCESS: + size = strlen( _GREEN_([+] ) ); + strncpy(buffer,_GREEN_([+] ), size); + break; + default: + size = strlen(prefix[level]); + strncpy(buffer, prefix[level], sizeof buffer); + break; } va_list args;