xrpld
Loading...
Searching...
No Matches
CaptureLogs.h
1#pragma once
2
3#include <xrpl/basics/Log.h>
4
5namespace xrpl::test {
6
13class CaptureLogs : public Logs
14{
18
23 {
26
27 public:
29 : beast::Journal::Sink(threshold, false), strmMutex_(mutex), strm_(strm)
30 {
31 }
32
33 void
34 write(beast::Severity level, std::string const& text) override
35 {
36 std::scoped_lock const lock(strmMutex_);
37 strm_ << text;
38 }
39
40 void
41 writeAlways(beast::Severity level, std::string const& text) override
42 {
43 std::scoped_lock const lock(strmMutex_);
44 strm_ << text;
45 }
46 };
47
48public:
49 explicit CaptureLogs(std::string* pResult) : Logs(beast::Severity::Info), pResult_(pResult)
50 {
51 }
52
53 ~CaptureLogs() override
54 {
55 *pResult_ = strm_.str();
56 }
57
63};
64
65} // namespace xrpl::test
Abstraction for the underlying message destination.
Definition Journal.h:51
virtual Severity threshold() const
Returns the minimum severity level this sink will report.
Sink(Sink const &sink)=default
beast::Severity threshold() const
Definition Log.cpp:143
Logs(beast::Severity level)
Definition Log.cpp:112
void writeAlways(beast::Severity level, std::string const &text) override
Bypass filter and write text to the sink at the specified severity.
Definition CaptureLogs.h:41
void write(beast::Severity level, std::string const &text) override
Write text to the sink at the specified severity.
Definition CaptureLogs.h:34
CaptureSink(beast::Severity threshold, std::mutex &mutex, std::stringstream &strm)
Definition CaptureLogs.h:28
std::unique_ptr< beast::Journal::Sink > makeSink(std::string const &partition, beast::Severity threshold) override
Definition CaptureLogs.h:59
std::stringstream strm_
Definition CaptureLogs.h:16
std::string * pResult_
Definition CaptureLogs.h:17
CaptureLogs(std::string *pResult)
Definition CaptureLogs.h:49
T make_unique(T... args)
Severity
Severity level / threshold of a Journal message.
Definition Journal.h:11