Mercurial > hg > vampy
comparison Debug.h @ 67:146d14ab15e7
Debug output: off by default, on with VAMPY_VERBOSE environment variable
author | Chris Cannam |
---|---|
date | Mon, 17 Nov 2014 10:03:44 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
66:5664fe298af2 | 67:146d14ab15e7 |
---|---|
1 | |
2 #ifndef DEBUG_H_INCLUDED | |
3 #define DEBUG_H_INCLUDED | |
4 | |
5 #include <iostream> | |
6 #include <cstdlib> | |
7 | |
8 class MyDebug | |
9 { | |
10 public: | |
11 MyDebug() : want(std::getenv("VAMPY_VERBOSE") != 0) { } | |
12 | |
13 template <typename T> | |
14 MyDebug &operator<<(const T &t) { | |
15 if (want) std::cerr << t; | |
16 return *this; | |
17 } | |
18 | |
19 MyDebug &operator<<(std::ostream &(*o)(std::ostream &)) { | |
20 if (want) std::cerr << o; | |
21 return *this; | |
22 } | |
23 | |
24 private: | |
25 bool want; | |
26 }; | |
27 | |
28 #define DSTREAM (MyDebug()) | |
29 | |
30 #endif |