41 const std::string& substring) {
48 const std::vector<std::string> messages =
SplitString(log,
"\n");
49 const size_t count = messages.size();
50 for (
size_t i = 0; i < count; ++i) {
53 const bool check_dcheck = severity_string ==
"DFATAL" &&
54 messages[i].find(
"DCHECK failed") != std::string::npos &&
56 if ((messages[i].find(severity_string) == 0 &&
57 messages[i].find(substring) != std::string::npos) ||
59 messages[i + 1U].find(substring) != std::string::npos)) {
70 const std::string& substring) {
78 const std::vector<std::string> messages =
SplitString(log,
"\n");
79 const size_t count = messages.size();
80 for (
size_t i = 0; i < count; ++i) {
81 if (messages[i].find(severity_string) == 0 &&
82 messages[i].find(substring) != std::string::npos)
bool HasMessage(const std::string &severity, const std::string &substring)
Returns true if exactly one message was logged since the LogChecker was constructed or since the last...
bool HasAnyMessages() const
Returns true if any messages were logged since the instance was constructed or since the last call to...
const std::vector< std::string > GetAllMessages()
This function is useful for testing code that produces more than one log message at a time...
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
void Write(port::LogSeverity severity, const std::string &message) override
LogEntryWriter impl.
void ClearLog()
Clears any messages that may be in the log.
std::vector< std::string > ION_API SplitString(const std::string &str, const std::string &delimiters)
Splits a string into a vector of substrings, given a set of delimiter characters (expressed as a stri...
const std::string GetLogString() const
Returns a string containing all current logged messages.
port::LogEntryWriter * GetLogEntryWriter()
Returns the log-writer that messages are currently logged to.
bool HasNoMessage(const std::string &severity, const std::string &substring)
Returns true if no message of the given severity and containing the given substring was logged since ...
~LogChecker() override
The destructor logs an error if unexpected messages were logged, and unconditionally restores the pre...
const char * GetSeverityName(LogSeverity severity) const
Convenient way to map a severity-code to a printable represenation.
void SetLogEntryWriter(port::LogEntryWriter *w)
Public functions.
LogChecker()
The constructor sets up to trap all log output.