diff --git a/libs/log/source/log.cpp b/libs/log/source/log.cpp index 3a213494..3426a960 100644 --- a/libs/log/source/log.cpp +++ b/libs/log/source/log.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -28,8 +29,6 @@ namespace psemek::log std::mutex sinks_mutex; std::vector> sinks; - using signal_handler = void(*)(int); - struct signal_data { int signal; @@ -38,14 +37,17 @@ namespace psemek::log signal_data const signals[] = { - {SIGSEGV, "Aborting due to SIGSEGV"}, + {SIGINT, "Aborting due to SIGINT" }, + {SIGILL, "Aborting due to SIGILL" }, {SIGABRT, "Aborting due to SIGABRT"}, + {SIGFPE, "Aborting due to SIGFPE" }, + {SIGSEGV, "Aborting due to SIGSEGV"}, {SIGTERM, "Aborting due to SIGTERM"}, }; - struct sinks_flusher + struct signal_handler { - sinks_flusher() + signal_handler() { for (auto const & p : signals) std::signal(p.signal, &handler); @@ -58,7 +60,8 @@ namespace psemek::log { if (p.signal == signal) { - put_message(level::error, p.message); + log::error() << p.message; + log::error() << boost::stacktrace::stacktrace(); break; } } @@ -73,7 +76,7 @@ namespace psemek::log std::signal(signal, SIG_DFL); std::raise(signal); } - } flusher; + } signal_handler; void put_message(level l, std::string const & str, std::string const & thread_name) {