Simple C++ Debug Helper

USAGE

DEBUG(msg, depth)

prints a debug message if the depth is little than NDEBUG macro.

msg string message

depth depth level

Everybody loves examples

examples/main.cpp

/*
|Simple C++ DEBUG helper|
==================
Author: Gustavo Yudi Bientinezi Matsuzake (Helped by the internet)

Compile with -DDEBUG or define a DEBUG macro (#define DEBUG)
*/
#include <iostream>
#include <string>
#include "debug.hpp"

using namespace std;

namespace functions{
	void func(){
		DEBUG("func{...", 0);

		for(int i=0; i<5; i++)
			DEBUG("i = " << i, 1);
	

		DEBUG("...}", 0);
	}
}

int main(int argc, char* argv[]){
	DEBUG("main{...", 0);
	
	cout << "Hello Debug" << endl;	
	
	functions::func();

	DEBUG("...}", 0);
	return 0;
}
  • Compiled without any macro

"Example 0"

  • Compiled with macro NDEBUG=0

"Example 1"

  • Compiled with macro NDEBUG=1

"Example 2"

  • Compiled with macro NDEBUG=1 and DEBUG_COLOR_ENABLE

"Example 3"

  • Compiled with macro NDEBUG=1 and DEBUG_PREFIX_ENABLE

"Example 4"

  • Compiled with macro N_DEBUG=1 and DEBUG_PREFIX_ENABLE and DEBUG_COLOR_ENABLE

"Example 5"