19 namespace logging_details {
38 const bool checkPassed,
39 const char* checkString,
47 nullStream_.emplace();
49 traceAndLogStreamPair_ = std::make_unique<StringStreamPair>();
51 traceAndLogStreamPair_->second << checkString;
56 return nullStream_.value();
58 return traceAndLogStreamPair_->second;
62 google::LogMessage(file_, line_, logLevel_).stream()
63 << traceAndLogStreamPair_->second.str()
65 << traceAndLogStreamPair_->first;
66 throw T(traceAndLogStreamPair_->second.str());
82 #define CHECK_LOG_AND_THROW(CONDITION, LOG_LEVEL, EXCEPTION) \ 83 (StackTracePrinterWithException<EXCEPTION>( \ 85 "Check failed \"" #CONDITION "\": ", \ 88 google::GLOG_##LOG_LEVEL)).stream() 90 #define CHECK_LOG_AND_THROW_LT(X, Y, LOG_LEVEL, EXCEPTION) \ 91 CHECK_LOG_AND_THROW((X) < (Y), LOG_LEVEL, EXCEPTION) 93 #define CHECK_LOG_AND_THROW_LE(X, Y, LOG_LEVEL, EXCEPTION) \ 94 CHECK_LOG_AND_THROW((X) <= (Y), LOG_LEVEL, EXCEPTION) 96 #define CHECK_LOG_AND_THROW_GT(X, Y, LOG_LEVEL, EXCEPTION) \ 97 CHECK_LOG_AND_THROW((X) > (Y), LOG_LEVEL, EXCEPTION) 99 #define CHECK_LOG_AND_THROW_GE(X, Y, LOG_LEVEL, EXCEPTION) \ 100 CHECK_LOG_AND_THROW((X) >= (Y), LOG_LEVEL, EXCEPTION) 102 #define CHECK_LOG_AND_THROW_EQ(X, Y, LOG_LEVEL, EXCEPTION) \ 103 CHECK_LOG_AND_THROW((X) == (Y), LOG_LEVEL, EXCEPTION) 105 #define CHECK_LOG_AND_THROW_NE(X, Y, LOG_LEVEL, EXCEPTION) \ 106 CHECK_LOG_AND_THROW((X) != (Y), LOG_LEVEL, EXCEPTION) 108 #define CHECK_LOG_AND_THROW_NOT_NULL(X, LOG_LEVEL, EXCEPTION) \ 109 CHECK_LOG_AND_THROW((X) != nullptr, LOG_LEVEL, EXCEPTION) 111 #define CHECK_LOG_AND_THROW_NULL(X, LOG_LEVEL, EXCEPTION) \ 112 CHECK_LOG_AND_THROW((X) == nullptr, LOG_LEVEL, EXCEPTION) 128 bool coalesce=
false) {
129 return printChain(buf, Format::HEX_FOLLY, coalesce);
133 return printChain(buf, Format::HEX_16, coalesce);
137 return printChain(buf, Format::CHAIN_INFO,
false);
141 return printChain(buf, Format::BIN, coalesce);
folly::Optional< NullStream > nullStream_
~StackTracePrinterWithException() noexcept(false)
void dumpBinToFile(const string &filename, const IOBuf *buf)
static std::string printHexFolly(const folly::IOBuf *buf, bool coalesce=false)
std::ostream & operator<<(std::ostream &os, const HeaderTable &table)
string hexStr(StringPiece sp)
static std::string printHex16(const folly::IOBuf *buf, bool coalesce=false)
std::string getStackTrace()
static std::string printBin(const folly::IOBuf *buf, bool coalesce=false)
requires E e noexcept(noexcept(s.error(std::move(e))))
std::unique_ptr< StringStreamPair > traceAndLogStreamPair_
StackTracePrinterWithException(const bool checkPassed, const char *checkString, const char *file, const int line, const int logLevel)
NullStream & operator=(NullStream &&)
static std::string printChainInfo(const folly::IOBuf *buf)
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
std::pair< std::string, std::ostringstream > StringStreamPair