18 #include <flecsi-config.h> 22 #include "flecsi/log/utils.hh" 57 : file_(file), line_(line), clean_color_(false) {
58 #if defined(FLOG_ENABLE_DEBUG) 59 std::cerr << FLOG_COLOR_LTGRAY <<
"FLOG: log_message_t constructor " << file
60 <<
" " << line << FLOG_COLOR_PLAIN << std::endl;
65 #if defined(FLOG_ENABLE_DEBUG) 66 std::cerr << FLOG_COLOR_LTGRAY <<
"FLOG: log_message_t destructor " 67 << FLOG_COLOR_PLAIN << std::endl;
70 #if defined(FLOG_ENABLE_MPI) 76 #if defined(FLOG_ENABLE_EXTERNAL) 86 #endif // FLOG_ENABLE_MPI 111 #define severity_message_t(severity, format) \ 112 struct severity##_log_message_t : public log_message_t { \ 113 severity##_log_message_t(const char * file, int line, bool devel = false) \ 114 : log_message_t(file, line), devel_(devel) {} \ 116 ~severity##_log_message_t() { \ 118 if(clean_color_ && !flog_t::instance().buffer_stream().str().empty()) { \ 119 auto str = flog_t::instance().buffer_stream().str(); \ 120 if(str.back() == '\n') { \ 121 str = str.substr(0, str.size() - 1); \ 122 str += FLOG_COLOR_PLAIN; \ 124 flog_t::instance().buffer_stream().str(std::string{}); \ 125 flog_t::instance().buffer_stream() << str; \ 128 flog_t::instance().buffer_stream() << FLOG_COLOR_PLAIN; \ 137 private : bool devel_; \ 140 #define verbose_stamp \ 141 timestamp() << " " << rstrip<'/'>(file_) << ":" << line_ << " " 143 #if defined(FLOG_ENABLE_MPI) 144 #define process_stamp " p" << flog_t::instance().process() 146 #define process_stamp "" 155 severity_message_t(utility, {
166 severity_message_t(trace, {
170 std::string devel = devel_ ?
"(devel)" :
"";
177 stream << FLOG_OUTPUT_CYAN(
"[trace ") << FLOG_OUTPUT_PURPLE(devel);
178 stream << FLOG_OUTPUT_LTGRAY(verbose_stamp);
179 stream << FLOG_OUTPUT_CYAN(active_tag);
180 stream << FLOG_OUTPUT_GREEN(process_stamp);
181 stream << FLOG_OUTPUT_CYAN(
"] ");
186 stream << FLOG_OUTPUT_CYAN(
"[trace ") << FLOG_OUTPUT_PURPLE(devel);
187 stream << FLOG_OUTPUT_CYAN(active_tag);
188 stream << FLOG_OUTPUT_GREEN(process_stamp);
189 stream << FLOG_OUTPUT_CYAN(
"] ");
204 severity_message_t(info, {
208 std::string devel = devel_ ?
"devel " :
"";
215 stream << FLOG_OUTPUT_GREEN(
"[info ") << FLOG_OUTPUT_PURPLE(devel);
216 stream << FLOG_OUTPUT_LTGRAY(verbose_stamp);
217 stream << FLOG_OUTPUT_CYAN(active_tag);
218 stream << FLOG_OUTPUT_GREEN(process_stamp);
219 stream << FLOG_OUTPUT_GREEN(
"] ");
224 stream << FLOG_OUTPUT_GREEN(
"[info ") << FLOG_OUTPUT_PURPLE(devel);
225 stream << FLOG_OUTPUT_CYAN(active_tag);
226 stream << FLOG_OUTPUT_GREEN(process_stamp);
227 stream << FLOG_OUTPUT_GREEN(
"] ");
242 severity_message_t(warn, {
246 std::string devel = devel_ ?
"(devel)" :
"";
253 stream << FLOG_OUTPUT_BROWN(
"[Warn ") << FLOG_OUTPUT_PURPLE(devel);
254 stream << FLOG_OUTPUT_LTGRAY(verbose_stamp);
255 stream << FLOG_OUTPUT_CYAN(active_tag);
256 stream << FLOG_OUTPUT_GREEN(process_stamp);
257 stream << FLOG_OUTPUT_BROWN(
"] ") << FLOG_COLOR_YELLOW;
262 stream << FLOG_OUTPUT_BROWN(
"[Warn ") << FLOG_OUTPUT_PURPLE(devel);
263 stream << FLOG_OUTPUT_CYAN(active_tag);
264 stream << FLOG_OUTPUT_GREEN(process_stamp);
265 stream << FLOG_OUTPUT_BROWN(
"] ") << FLOG_COLOR_YELLOW;
281 severity_message_t(error, {
285 std::string devel = devel_ ?
"(devel)" :
"";
292 stream << FLOG_OUTPUT_RED(
"[ERROR ") << FLOG_OUTPUT_PURPLE(devel);
293 stream << FLOG_OUTPUT_LTGRAY(verbose_stamp);
294 stream << FLOG_OUTPUT_CYAN(active_tag);
295 stream << FLOG_OUTPUT_GREEN(process_stamp);
296 stream << FLOG_OUTPUT_RED(
"] ") << FLOG_COLOR_LTRED;
301 stream << FLOG_OUTPUT_RED(
"[ERROR ") << FLOG_OUTPUT_PURPLE(devel);
302 stream << FLOG_OUTPUT_CYAN(active_tag);
303 stream << FLOG_OUTPUT_GREEN(process_stamp);
304 stream << FLOG_OUTPUT_RED(
"] ") << FLOG_COLOR_LTRED;
316 #undef severity_message_t std::ostream & severity_stream(bool active=true)
Definition: state.hh:219
Definition: message.hh:43
std::stringstream & buffer_stream()
Definition: state.hh:201
virtual std::ostream & stream()
Definition: message.hh:96
bool true_state()
Definition: message.hh:34
static flog_t & instance()
Definition: state.hh:73
std::string active_tag_name()
Definition: state.hh:291
std::ostream & stream()
Definition: state.hh:209
log_message_t(const char *file, int line)
Definition: message.hh:56
Definition: control.hh:31