diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-07-15 12:58:52 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-08-12 16:18:07 +0000 |
commit | bc8cbdb25d397a568ac39982a348ad2abab82508 (patch) | |
tree | f6a38421dfc6436d7df980dabaa42b60ac197b54 | |
parent | easylogging++: make the logger handle early/late logging (diff) | |
download | monero-bc8cbdb25d397a568ac39982a348ad2abab82508.tar.xz |
stack_trace: print stack traces on stdout if the logger isn't live
-rw-r--r-- | src/common/stack_trace.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/stack_trace.cpp b/src/common/stack_trace.cpp index 9c2bf4b53..551597833 100644 --- a/src/common/stack_trace.cpp +++ b/src/common/stack_trace.cpp @@ -49,7 +49,16 @@ #undef MONERO_DEFAULT_LOG_CATEGORY #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 |