rippled
Loading...
Searching...
No Matches
CheckMessageLogs.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2020 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <xrpl/basics/Log.h>
21
22namespace ripple {
23namespace test {
24
27class CheckMessageLogs : public Logs
28{
30 bool* pFound_;
31
33 {
35
36 public:
39 CheckMessageLogs& owner)
40 : beast::Journal::Sink(threshold, false), owner_(owner)
41 {
42 }
43
44 void
46 override
47 {
48 if (text.find(owner_.msg_) != std::string::npos)
49 *owner_.pFound_ = true;
50 }
51 };
52
53public:
60 CheckMessageLogs(std::string msg, bool* pFound)
61 : Logs{beast::severities::kDebug}, msg_{std::move(msg)}, pFound_{pFound}
62 {
63 }
64
67 std::string const& partition,
69 {
70 return std::make_unique<CheckMessageSink>(threshold, *this);
71 }
72};
73
74} // namespace test
75} // namespace ripple
Abstraction for the underlying message destination.
Definition: Journal.h:75
virtual Severity threshold() const
Returns the minimum severity level this sink will report.
Manages partitions for logging.
Definition: Log.h:49
beast::severities::Severity threshold() const
Definition: Log.cpp:150
CheckMessageSink(beast::severities::Severity threshold, CheckMessageLogs &owner)
void write(beast::severities::Severity level, std::string const &text) override
Write text to the sink at the specified severity.
Log manager that searches for a specific message substring.
CheckMessageLogs(std::string msg, bool *pFound)
Constructor.
std::unique_ptr< beast::Journal::Sink > makeSink(std::string const &partition, beast::severities::Severity threshold) override
T find(T... args)
Severity
Severity level / threshold of a Journal message.
Definition: Journal.h:31
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
STL namespace.