Permalink
Browse files

print stack trace on error and warning messages

  • Loading branch information...
1 parent 9895090 commit c553be4e7845fe727055118b45ff3f22526bb142 @Neverlord Neverlord committed Apr 19, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 cppa/logging.hpp
View
@@ -33,6 +33,7 @@
#include <sstream>
#include <iostream>
+#include <execinfo.h>
#include "cppa/singletons.hpp"
#include "cppa/detail/demangle.hpp"
@@ -109,9 +110,13 @@ class logging {
#define CPPA_LIF(stmt, logstmt) if (stmt) { logstmt ; } CPPA_VOID_STMT
#ifndef CPPA_LOG_LEVEL
-# define CPPA_LOG(classname, funname, level, message) \
+# define CPPA_LOG(classname, funname, level, message) { \
std::cerr << level << " [" << classname << "::" << funname << "]: " \
- << message << std::endl;
+ << message << "\nStack trace:\n"; \
+ void *array[10]; \
+ size_t size = backtrace(array, 10); \
+ backtrace_symbols_fd(array, size, 2); \
+ } CPPA_VOID_STMT
#else
# define CPPA_LOG(classname, funname, level, message) { \
std::ostringstream scoped_oss; scoped_oss << message; \

0 comments on commit c553be4

Please sign in to comment.