libcsdbg  1.28
C++ exception (and generic) stack trace debug library
void csdbg::util::header ( std::ostream &  stream,
const i8 tag 
)
static

Print a tagged message header on an output stream.

Parameters
[in]streamthe output stream
[in]tagthe message tag

Definition at line 594 of file util.cpp.

References __D_ASSERT, csdbg::process::current_thread(), ERROR_TAG_FG, INFO_TAG_FG, csdbg::tracer::interface(), likely, csdbg::thread::name(), csdbg::tracer::proc(), unlikely, and WARNING_TAG_FG.

Referenced by csdbg::__cyg_profile_func_enter(), csdbg::__cyg_profile_func_exit(), dbg(), and csdbg::operator<<().

595 {
596  __D_ASSERT(tag != NULL);
597  if ( unlikely(tag == NULL) )
598  return;
599 
600 #ifdef CSDBG_WITH_COLOR_TERM
601  stream << "\e[38;5;" << std::dec;
602 
603  i8 ch = tag[0];
604  if ( likely(ch == 'i') )
605  stream << INFO_TAG_FG;
606 
607  else if ( likely(ch == 'w') )
608  stream << WARNING_TAG_FG;
609 
610  else
611  stream << ERROR_TAG_FG;
612 
613  stream << "m[" << tag << "]\e[0m";
614 #else
615  stream << "[" << tag << "]";
616 #endif
617 
618  stream << " [" << std::dec << getpid() << ", ";
619  stream << "0x" << std::hex << pthread_self();
620 
621  const i8 *thr = NULL;
622  tracer *iface = tracer::interface();
623  if ( likely(iface != NULL) )
624  thr = iface->proc()->current_thread()->name();
625 
626  stream << " (" << ((thr != NULL) ? thr : "anon") << ")] ";
627 }
char i8
8-bit signed integer
Definition: config.hpp:72
static tracer * interface()
Get the interface object.
Definition: tracer.cpp:629
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
#define ERROR_TAG_FG
Tag color for error and exception messages.
Definition: config.hpp:299
#define WARNING_TAG_FG
Tag color for warning messages.
Definition: config.hpp:294
#define INFO_TAG_FG
Tag color for informational messages.
Definition: config.hpp:289
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
#define __D_ASSERT(x)
Assertion macro.
Definition: config.hpp:268

+ Here is the call graph for this function:

+ Here is the caller graph for this function: