From fe480f5e29f212efd5b933475cc6e71fc5937f4d Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Tue, 6 Jul 2021 19:57:09 -0400 Subject: Add CHECK macro to logging framework Reviewed-by: Alex Chernyakhovsky --- log.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'log.h') diff --git a/log.h b/log.h index e0d3963..d588b8f 100644 --- a/log.h +++ b/log.h @@ -111,6 +111,14 @@ void Log::Message(Level level, Args... args) { out_->write(message.data(), message.size()); } +// If condition is false, logs an internal error and exits the program. +void Check(Log& log, bool condition, const char* condition_str, + const char* file, int line); + } // namespace gsrsup +// A convenience macro to invoke the Check function. +#define CHECK(log, condition) \ + ::gsrsup::Check((log), (condition), #condition, __FILE__, __LINE__) + #endif // GSRSUP_LOG_H_ -- cgit v1.2.3