aboutsummaryrefslogtreecommitdiff
path: root/src/common/stack_trace.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-08-15 17:19:04 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-08-15 17:19:04 -0500
commit88369c6685d17e2d5bc3a1dc195b2fd84af8e596 (patch)
tree0827908eda16ab9d8abb02df9e5a1cd4aa971a9a /src/common/stack_trace.cpp
parentMerge pull request #4137 (diff)
parentstack_trace: print stack traces on stdout if the logger isn't live (diff)
downloadmonero-88369c6685d17e2d5bc3a1dc195b2fd84af8e596.tar.xz
Merge pull request #4138
7f8bdeb easylogging++: make the logger handle early/late logging (moneromooo-monero) bc8cbdb stack_trace: print stack traces on stdout if the logger isn't live (moneromooo-monero)
Diffstat (limited to 'src/common/stack_trace.cpp')
-rw-r--r--src/common/stack_trace.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/stack_trace.cpp b/src/common/stack_trace.cpp
index d6dc4d7cc..141621427 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 https://stackoverflow.com/questions/11665829/how-can-i-print-stack-trace-for-caught-exceptions-in-c-code-injection-in-c