Guest User

Untitled

a guest
May 12th, 2016
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #ifndef LOG_H
  2. #define LOG_H
  3.  
  4. #include <iostream>
  5.  
  6. #ifdef DEBUG
  7.   class VariadicLog
  8.   {
  9.     public:
  10.       template<typename T> VariadicLog& operator , (const T& value)
  11.       {
  12.           std::cout<<value;
  13.           return *this;
  14.       }
  15.       ~VariadicLog()
  16.       {
  17.           std::cout<<std::endl;
  18.       }
  19.   };
  20.  
  21.   #define log(...) VariadicLog(),__VA_ARGS__
  22. #else
  23.   #define log(...)
  24. #endif
  25.  
  26. #ifdef VERBOSE
  27.   #define verbose_log(...) VariadicLog(),__VA_ARGS__
  28. #else
  29.   #define verbose_log(...)
  30. #endif
  31.  
  32. #endif
  33.  
  34. // example use: log("Entering method xxx with x: ", x, ", y: ", y);
  35. // (evaluates to nothing when DEBUG is not defined)
Advertisement
Add Comment
Please, Sign In to add comment