28 #ifdef MERCURY_STACKTRACE_SHOW
34 #ifdef MERCURY_STACKTRACE_DEMANGLE
63 static void printInfo(std::string module, std::string msg)
65 std::cout << msg << std::endl;
71 std::cout <<
"Module " << module <<
":\n" << msg << std::endl;
76 [[noreturn]]
static void printError(std::string module, std::string msg)
78 std::cerr <<
"Module " << module <<
":\n" << msg << std::endl;
79 #ifdef MERCURY_STACKTRACE_SHOW
80 std::cerr <<
"\n-----------------[Stack Trace]-----------------\n";
82 void* stackBuffer[64];
84 int nStackFrames = backtrace(stackBuffer, 64);
85 #ifndef MERCURY_STACKTRACE_DEMANGLE
87 char** functionNames = backtrace_symbols(stackBuffer, nStackFrames);
88 for(
int i = 0; i < nStackFrames; i++ )
90 std::cerr <<
'\t' << functionNames[i] <<
'\n';
92 std::cerr <<
"Exiting.\n" << std::endl;
101 for (
int i = 4; i < nStackFrames; i++)
103 if (dladdr(stackBuffer[i], &infoStruct))
106 char* fnDemangled = abi::__cxa_demangle(infoStruct.dli_sname, NULL, NULL, &demangleStatus);
107 if (infoStruct.dli_sname ==
nullptr)
111 if (demangleStatus == 0)
113 std::cerr << fnDemangled <<
" +" << (
void*) ((
char*) stackBuffer[i] - (
char*) infoStruct.dli_saddr) <<
"\t(" << infoStruct.dli_fname <<
")\n";
118 std::cerr << infoStruct.dli_sname <<
" +" << (
void*) ((
char*) stackBuffer[i] - (
char*) infoStruct.dli_saddr) <<
"\t(" << infoStruct.dli_fname <<
")\n";
123 std::cerr << stackBuffer[i] <<
": ?????" << std::endl;
See How to use the logger for details on how to use the logger.
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.
static void printInfo(std::string module, std::string msg)
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.