Skip to content

Instantly share code, notes, and snippets.

@gruzovator
Created July 9, 2014 06:14
Show Gist options
  • Save gruzovator/7c6e5e5e63988b26894f to your computer and use it in GitHub Desktop.
Save gruzovator/7c6e5e5e63988b26894f to your computer and use it in GitHub Desktop.
primitive logging in c++
// debug.h
#include <iostream>
#define NDEBUG 1
#ifdef NDEBUG
#define debug if(1); else std::cout
#else
#define debug std::cout
#endif
using namespace std;
int main(int argc, char const *argv[])
{
// 'debug' may be switched off at compile time
debug << "debug1";
debug << "debug2" << endl;
// standard streams
cout << "info" << endl;
cout << "warning" << endl;
cerr << "error" << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment