|
| cDBG (bool flag=false, char const *color="red", std::ostream *fd=&std::cerr) |
|
std::ostream & | flush () |
|
bool | GetFlag (void) const |
|
*output<< debug_color<< buffer<< normal_color<< std::flush;}char const *GetColor(char const *c){char *sdh_no_color=getenv("SDH_NO_COLOR");if(sdh_no_color!=NULL) return"";char *os=getenv("OS");char *ostype=getenv("OSTYPE");if(os &&(!strncmp(os,"WIN", 3)||!strncmp(os,"Win", 3))&&(!ostype||(ostype &&strcmp(ostype,"cygwin")))) return"";if(!strcmp(c,"normal")) return"\x1b[0m";if(!strcmp(c,"bold")) return"\x1b[1m";if(!strcmp(c,"red")) return"\x1b[31m";if(!strcmp(c,"green")) return"\x1b[32m";if(!strcmp(c,"yellow")) return"\x1b[33m";if(!strcmp(c,"blue")) return"\x1b[34m";if(!strcmp(c,"magenta")) return"\x1b[35m";if(!strcmp(c,"cyan")) return"\x1b[36m";if(!strcmp(c,"white")) return"\x1b[37m";if(!strcmp(c,"black")) return"\x1b[39m";if(!strcmp(c,"black_back")) return"\x1b[40m";if(!strcmp(c,"red_back")) return"\x1b[41m";if(!strcmp(c,"green_back")) return"\x1b[42m";if(!strcmp(c,"yellow_back")) return"\x1b[43m";if(!strcmp(c,"blue_back")) return"\x1b[44m";if(!strcmp(c,"cyan_back")) return"\x1b[45m";if(!strcmp(c,"magenta_back")) return"\x1b[46m";if(!strcmp(c,"white_back")) return"\x1b[47m";return"";}template< typename T > cDBG & | operator<< (T const &v) |
|
void | PDM (char const *fmt,...) SDH__attribute__((format(printf |
|
void | SetColor (char const *color) |
|
void | SetFlag (bool flag) |
|
void | SetOutput (std::ostream *fd) |
|
| va_end (arglist) |
|
| va_start (arglist, fmt) |
|
| vsnprintf (buffer, 256, fmt, arglist) |
|
| ~cDBG () |
|
A class to print colored debug messages.
- The printing can be switched on or off so the debug code can remain in the code. (default is off)
- The messages can be colorized (default is red).
- The output can be redirected. (default is sys.stderr)
- Debug messages can be printed in a functional way or in C++ stream like way
If the environment variable "SDH_NO_COLOR" is defined then the messages are printed without coloring (usefull for logging or if your terminal does not support colors.
Example:
g =
cDBG(
true,
"green" );
d.PDM( "This message is printed in default color red" );
g << "and this one in a nice green ";
g << "of course you can debug print any objects that have a string representation: " << 08 << 15 << true;
g << "Messages can be turned of and on, e.g. selected by command line options";
g.SetFlag(false);
g << "This messages is not printed";
Definition at line 113 of file dbg.h.