mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-22 14:50:54 +00:00
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com> Co-authored-by: Bart <bthomee@users.noreply.github.com>
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <xrpl/basics/Log.h>
|
|
|
|
namespace xrpl::test {
|
|
|
|
/** Log manager that searches for a specific message substring
|
|
*/
|
|
class CheckMessageLogs : public Logs
|
|
{
|
|
std::string msg_;
|
|
bool* pFound_;
|
|
|
|
class CheckMessageSink : public beast::Journal::Sink
|
|
{
|
|
CheckMessageLogs& owner_;
|
|
|
|
public:
|
|
CheckMessageSink(beast::severities::Severity threshold, CheckMessageLogs& owner)
|
|
: beast::Journal::Sink(threshold, false), owner_(owner)
|
|
{
|
|
}
|
|
|
|
void
|
|
write(beast::severities::Severity level, std::string const& text) override
|
|
{
|
|
if (text.find(owner_.msg_) != std::string::npos)
|
|
*owner_.pFound_ = true;
|
|
}
|
|
|
|
void
|
|
writeAlways(beast::severities::Severity level, std::string const& text) override
|
|
{
|
|
write(level, text);
|
|
}
|
|
};
|
|
|
|
public:
|
|
/** Constructor
|
|
|
|
@param msg The message string to search for
|
|
@param pFound Pointer to the variable to set to true if the message is
|
|
found
|
|
*/
|
|
CheckMessageLogs(std::string msg, bool* pFound)
|
|
: Logs{beast::severities::kDebug}, msg_{std::move(msg)}, pFound_{pFound}
|
|
{
|
|
}
|
|
|
|
std::unique_ptr<beast::Journal::Sink>
|
|
makeSink(std::string const& partition, beast::severities::Severity threshold) override
|
|
{
|
|
return std::make_unique<CheckMessageSink>(threshold, *this);
|
|
}
|
|
};
|
|
|
|
} // namespace xrpl::test
|