stack_trace: print stack traces on stdout if the logger isn't live

This commit is contained in:
moneromooo-monero 2018-07-15 12:58:52 +01:00
parent 7f8bdeb35c
commit bc8cbdb25d
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 10 additions and 1 deletions

View File

@ -49,7 +49,16 @@
#undef MONERO_DEFAULT_LOG_CATEGORY #undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "stacktrace" #define MONERO_DEFAULT_LOG_CATEGORY "stacktrace"
#define ST_LOG(x) CINFO(el::base::Writer,el::base::DispatchAction::FileOnlyLog,MONERO_DEFAULT_LOG_CATEGORY) << x #define ST_LOG(x) \
do { \
auto elpp = ELPP; \
if (elpp) { \
CINFO(el::base::Writer,el::base::DispatchAction::FileOnlyLog,MONERO_DEFAULT_LOG_CATEGORY) << x; \
} \
else { \
std::cout << x << std::endl; \
} \
} while(0)
// from http://stackoverflow.com/questions/11665829/how-can-i-print-stack-trace-for-caught-exceptions-in-c-code-injection-in-c // from http://stackoverflow.com/questions/11665829/how-can-i-print-stack-trace-for-caught-exceptions-in-c-code-injection-in-c