blob: 706514109f93e8b8b87aa8a82384b00c832aa4db [file] [log] [blame]
#ifndef AOS_UTIL_DEATH_TEST_LOG_IMPLEMENTATION_H_
#define AOS_UTIL_DEATH_TEST_LOG_IMPLEMENTATION_H_
#include <cstdlib>
#include "aos/logging/implementations.h"
namespace aos {
namespace util {
// Prints all FATAL messages to stderr and then abort(3)s before the regular
// stuff can print out anything else. Ignores all other messages.
// This is useful in death tests that expect a LOG(FATAL) to cause the death.
class DeathTestLogImplementation
: public logging::HandleMessageLogImplementation {
public:
virtual void HandleMessage(const logging::LogMessage &message) override {
if (message.level == FATAL) {
logging::internal::PrintMessage(stderr, message);
abort();
}
}
};
} // namespace util
} // namespace aos
#endif // AOS_UTIL_DEATH_TEST_LOG_IMPLEMENTATION_H_