13 #ifndef HTGS_DEBUG_MESSAGE_HPP 14 #define HTGS_DEBUG_MESSAGE_HPP 25 #define HTGS_ASSERT(condition, message) \ 27 if (! (condition)) { \ 28 std::cerr << message << ": Assertion `" #condition "` failed in " << __FILE__ \ 29 << ":" << __LINE__ << ": " << std::endl; \ 34 #define HTGS_ASSERT(condition, message) do { } while (false) 41 #define HTGS_VERBOSE 1 54 #define HTGS_DEBUG_MSG_LEVEL(msg, level) if (!HTGS_DEBUG_ENABLED || HTGS_DEBUG_LEVEL < level) {} \ 55 else htgs_dbglog() << __FILE__ << ":" << __LINE__ << " " << msg 65 #define HTGS_DEBUG(msg) HTGS_DEBUG_MSG_LEVEL(msg, 0) 75 #define HTGS_DEBUG_VERBOSE(msg) HTGS_DEBUG_MSG_LEVEL(msg, HTGS_VERBOSE) 81 #ifdef HTGS_DEBUG_LEVEL_VERBOSE 82 #define HTGS_DEBUG_LEVEL HTGS_VERBOSE 84 #define HTGS_DEBUG_LEVEL 0 91 #ifdef HTGS_DEBUG_FLAG 92 #define HTGS_DEBUG_ENABLED 1 94 #define HTGS_DEBUG_ENABLED 0 103 mutable bool has_endl_;
104 htgs_dbglog(std::ostream &os = std::cerr) : os_(os), has_endl_(
false) {}
105 ~
htgs_dbglog() {
if (!has_endl_) os_ << std::endl; }
107 static bool has_endl(
const T &) {
return false; }
108 static bool has_endl(
char c) {
return (c ==
'\n'); }
109 static bool has_endl(std::string s) {
return has_endl(*s.rbegin()); }
110 static bool has_endl(
const char *s) {
return has_endl(std::string(s)); }
112 static bool same_manip(T &(*m)(T &), T &(*e)(T &)) {
return (m == e); }
113 const htgs_dbglog &operator<<(std::ostream &(*m)(std::ostream &))
const {
114 has_endl_ = same_manip(m, std::endl);
120 has_endl_ = has_endl(v);
127 #endif //HTGS_DEBUG_MESSAGE_HPP Debug logging structure for processing various types of arguments for std::cerr.
Definition: debug_message.hpp:100