4 #if MERCURY_STACKTRACE_SHOW
10 #if MERCURY_STACKTRACE_DEMANGLE
38 std::cout <<
"Module " << module <<
":\n" << msg << std::endl;
42 static void printError(std::string module, std::string msg) {
43 std::cerr <<
"Module " << module <<
":\n" << msg << std::endl;
44 #if MERCURY_STACKTRACE_SHOW
45 std::cerr <<
"\n-----------------[Stack Trace]-----------------\n";
48 void* stackBuffer[64];
50 int nStackFrames = backtrace(stackBuffer, 64);
51 #if !MERCURY_STACKTRACE_DEMANGLE
53 char** functionNames = backtrace_symbols(stackBuffer, nStackFrames);
54 for(
int i = 0; i < nStackFrames; i++ )
56 std::cerr <<
'\t' << functionNames[i] <<
'\n';
58 std::cerr <<
"Exiting.\n" << std::endl;
67 for (
int i = 4; i < nStackFrames; i++ )
69 if (dladdr(stackBuffer[i], &infoStruct))
72 char* fnDemangled = abi::__cxa_demangle(infoStruct.dli_sname, NULL, NULL, &demangleStatus);
73 if (infoStruct.dli_sname ==
nullptr)
77 if (demangleStatus == 0)
79 std::cerr << fnDemangled <<
" +" << (
void*)((
char*)stackBuffer[i] - (
char*)infoStruct.dli_saddr) <<
"\t("
80 << infoStruct.dli_fname <<
")\n";
85 std::cerr << infoStruct.dli_sname <<
" +" << (
void*)((
char*)stackBuffer[i] - (
char*)infoStruct.dli_saddr) <<
"\t("
86 << infoStruct.dli_fname <<
")\n";
91 std::cerr << stackBuffer[i] <<
": ?????" << std::endl;
static void printError(std::string module, std::string msg)
LL< Log::DEBUG > DEBUG
Debug information.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
LL< Log::INFO > INFO
Info log level.
LoggerOutput loggerOutputDefaultImpl
LL< Log::ERROR > ERROR
Error log level.
LL< Log::WARN > WARN
Warning log level.
static void printMessage(std::string module, std::string msg)
Default functions for output generation.
LL< Log::DEFAULT > DEFAULT
Default log level.
LL< Log::FATAL > FATAL
Fatal log level.
LL< Log::VERBOSE > VERBOSE
Verbose information.
LoggerOutput * loggerOutput
Declaration of the output functions. If the output needs to be redirected, please swap the loggerOutp...
Tag for template metaprogramming.