13 #ifndef HTGS_LOG_MESSAGE_HPP 14 #define HTGS_LOG_MESSAGE_HPP 23 #define HTGS_VERBOSE 1 34 #define HTGS_LG_MSG_LEVEL(msg, level) if (!HTGS_LOG_ENABLED || HTGS_LOG_LEVEL < level) {} \ 35 else htgs_lglog() << " " << msg 44 #define HTGS_LG(msg) HTGS_LG_MSG_LEVEL(msg, 0) 53 #define HTGS_LG_VERBOSE(msg) HTGS_LG_MSG_LEVEL(msg, HTGS_VERBOSE) 59 #ifdef HTGS_LOG_LEVEL_VERBOSE 60 #define HTGS_LOG_LEVEL HTGS_VERBOSE 62 #define HTGS_LOG_LEVEL 0 70 #define HTGS_LOG_ENABLED 1 72 #define HTGS_LOG_ENABLED 0 81 mutable bool has_endl_;
82 htgs_lglog(std::ostream &os = std::cout) : os_(os), has_endl_(
false) {}
83 ~
htgs_lglog() {
if (!has_endl_) os_ << std::endl; }
85 static bool has_endl(
const T &) {
return false; }
86 static bool has_endl(
char c) {
return (c ==
'\n'); }
87 static bool has_endl(std::string s) {
return has_endl(*s.rbegin()); }
88 static bool has_endl(
const char *s) {
return has_endl(std::string(s)); }
90 static bool same_manip(T &(*m)(T &), T &(*e)(T &)) {
return (m == e); }
91 const htgs_lglog &operator<<(std::ostream &(*m)(std::ostream &))
const {
92 has_endl_ = same_manip(m, std::endl);
97 const htgs_lglog &operator<<(
const T &v)
const {
98 has_endl_ = has_endl(v);
105 #endif //HTGS_LOG_MESSAGE_HPP Log structure for processing various types of arguments for std::cout.
Definition: log_message.hpp:78