Use these patterns together with CaptureFD and EXPECT_PCRE_MATCH() to test for the presence (or absence) of log lines at a particular level:
Declared in <folly/testing/TestUtil.h>
std::string
glogErrorPattern();
CaptureFD stderr(2); LOG(INFO) << "All is well"; EXPECT_NO_PCRE_MATCH(glogErrOrWarnPattern(), stderr.readIncremental()); LOG(ERROR) << "Uh-oh"; EXPECT_PCRE_MATCH(glogErrorPattern(), stderr.readIncremental());
A PCRE pattern matching an error-level glog line.