From d471fe2d9e726150af7366e4fbf6cc3395797a90 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 feb972de355..7af7c8c7d83 100644 --- a/iceoryx_hoofs/testing/testing_logger.cpp +++ b/iceoryx_hoofs/testing/testing_logger.cpp @@ -107,6 +107,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