Created
July 9, 2014 06:14
-
-
Save gruzovator/7c6e5e5e63988b26894f to your computer and use it in GitHub Desktop.
primitive logging in c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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