rippled
Loading...
Searching...
No Matches
CaptureLogs.h
1#pragma once
2
3#include <xrpl/basics/Log.h>
4
5namespace xrpl {
6namespace test {
7
14class CaptureLogs : public Logs
15{
19
24 {
27
28 public:
31 std::mutex& mutex,
33 : beast::Journal::Sink(threshold, false), strmMutex_(mutex), strm_(strm)
34 {
35 }
36
37 void
38 write(beast::severities::Severity level, std::string const& text) override
39 {
40 std::lock_guard const lock(strmMutex_);
41 strm_ << text;
42 }
43
44 void
46 {
47 std::lock_guard const lock(strmMutex_);
48 strm_ << text;
49 }
50 };
51
52public:
53 explicit CaptureLogs(std::string* pResult) : Logs(beast::severities::kInfo), pResult_(pResult)
54 {
55 }
56
57 ~CaptureLogs() override
58 {
59 *pResult_ = strm_.str();
60 }
61
67};
68
69} // namespace test
70} // namespace xrpl
Abstraction for the underlying message destination.
Definition Journal.h:56
virtual Severity threshold() const
Returns the minimum severity level this sink will report.
Manages partitions for logging.
Definition Log.h:32
beast::severities::Severity threshold() const
Definition Log.cpp:140
sink for writing all log messages to a stringstream
Definition CaptureLogs.h:24
void write(beast::severities::Severity level, std::string const &text) override
Write text to the sink at the specified severity.
Definition CaptureLogs.h:38
CaptureSink(beast::severities::Severity threshold, std::mutex &mutex, std::stringstream &strm)
Definition CaptureLogs.h:29
void writeAlways(beast::severities::Severity level, std::string const &text) override
Bypass filter and write text to the sink at the specified severity.
Definition CaptureLogs.h:45
Log manager for CaptureSinks.
Definition CaptureLogs.h:15
std::stringstream strm_
Definition CaptureLogs.h:17
std::string * pResult_
Definition CaptureLogs.h:18
CaptureLogs(std::string *pResult)
Definition CaptureLogs.h:53
std::unique_ptr< beast::Journal::Sink > makeSink(std::string const &partition, beast::severities::Severity threshold) override
Definition CaptureLogs.h:63
T is_same_v
Severity
Severity level / threshold of a Journal message.
Definition Journal.h:12
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
T str(T... args)