From 5cf0bdcb723ae4e0cf4e28fefd27c9e79796d43f Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Mon, 14 Nov 2022 14:41:21 +0100 Subject: [PATCH] iox-#1755 Flush TestingLogger on terminate --- iceoryx_hoofs/testing/testing_logger.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iceoryx_hoofs/testing/testing_logger.cpp b/iceoryx_hoofs/testing/testing_logger.cpp index 790dcfc2642..c546ed3640e 100644 --- a/iceoryx_hoofs/testing/testing_logger.cpp +++ b/iceoryx_hoofs/testing/testing_logger.cpp @@ -117,6 +117,12 @@ void LogPrinter::OnTestStart(const ::testing::TestInfo&) dynamic_cast(log::Logger::get()).clearLogBuffer(); TestingLogger::setLogLevel(log::LogLevel::TRACE); + std::set_terminate([]() { + std::cout << "Terminate called\n" << std::flush; + dynamic_cast(log::Logger::get()).printLogBuffer(); + std::abort(); + }); + /// @todo iox-#1755 register signal handler for sigterm to flush to logger; /// there might be tests to register a handler itself and when this is /// done at each start of the test only the tests who use their