xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
beast
utility
WrappedSink.h
1
#pragma once
2
3
#include <xrpl/beast/utility/Journal.h>
4
5
#include <
string
>
6
#include <
utility
>
7
8
namespace
beast
{
9
13
14
// A WrappedSink both is a Sink and has a Sink:
15
// o It inherits from Sink so it has the correct interface.
16
// o It has a sink (reference) so it preserves the passed write() behavior.
17
// The data inherited from the base class is ignored.
18
class
WrappedSink
:
public
beast::Journal::Sink
19
{
20
private
:
21
beast::Journal::Sink
&
sink_
;
22
std::string
prefix_
;
23
24
public
:
25
explicit
WrappedSink
(
beast::Journal::Sink
& sink,
std::string
prefix
=
""
)
26
:
Sink
(sink),
sink_
(sink),
prefix_
(
std
::move(
prefix
))
27
{
28
}
29
30
explicit
WrappedSink
(
beast::Journal
const
& journal,
std::string
const
&
prefix
=
""
)
31
:
WrappedSink
(journal.sink(),
prefix
)
32
{
33
}
34
35
void
36
prefix
(
std::string
const
& s)
37
{
38
prefix_
= s;
39
}
40
41
[[nodiscard]]
bool
42
active
(
beast::Severity
level)
const override
43
{
44
return
sink_
.active(level);
45
}
46
47
[[nodiscard]]
bool
48
console
()
const override
49
{
50
return
sink_
.console();
51
}
52
53
void
54
console
(
bool
output)
override
55
{
56
sink_
.console(output);
57
}
58
59
[[nodiscard]]
beast::Severity
60
threshold
()
const override
61
{
62
return
sink_
.threshold();
63
}
64
65
void
66
threshold
(
beast::Severity
thresh)
override
67
{
68
sink_
.threshold(thresh);
69
}
70
71
void
72
write
(
beast::Severity
level,
std::string
const
& text)
override
73
{
74
using
beast::Journal
;
75
sink_
.write(level,
prefix_
+ text);
76
}
77
78
void
79
writeAlways
(
Severity
level,
std::string
const
& text)
override
80
{
81
using
beast::Journal
;
82
sink_
.writeAlways(level,
prefix_
+ text);
83
}
84
};
85
86
}
// namespace beast
std::string
beast::Journal::Sink
Abstraction for the underlying message destination.
Definition
Journal.h:59
beast::Journal::Sink::Sink
Sink(Sink const &sink)=default
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::WrappedSink::console
void console(bool output) override
Set whether messages are also written to the Output Window (MSVC).
Definition
WrappedSink.h:54
beast::WrappedSink::WrappedSink
WrappedSink(beast::Journal const &journal, std::string const &prefix="")
Definition
WrappedSink.h:30
beast::WrappedSink::console
bool console() const override
Returns true if a message is also written to the Output Window (MSVC).
Definition
WrappedSink.h:48
beast::WrappedSink::active
bool active(beast::Severity level) const override
Returns true if text at the passed severity produces output.
Definition
WrappedSink.h:42
beast::WrappedSink::writeAlways
void writeAlways(Severity level, std::string const &text) override
Bypass filter and write text to the sink at the specified severity.
Definition
WrappedSink.h:79
beast::WrappedSink::sink_
beast::Journal::Sink & sink_
Definition
WrappedSink.h:21
beast::WrappedSink::threshold
void threshold(beast::Severity thresh) override
Set the minimum severity this sink will report.
Definition
WrappedSink.h:66
beast::WrappedSink::prefix
void prefix(std::string const &s)
Definition
WrappedSink.h:36
beast::WrappedSink::prefix_
std::string prefix_
Definition
WrappedSink.h:22
beast::WrappedSink::write
void write(beast::Severity level, std::string const &text) override
Write text to the sink at the specified severity.
Definition
WrappedSink.h:72
beast::WrappedSink::threshold
beast::Severity threshold() const override
Returns the minimum severity level this sink will report.
Definition
WrappedSink.h:60
beast::WrappedSink::WrappedSink
WrappedSink(beast::Journal::Sink &sink, std::string prefix="")
Definition
WrappedSink.h:25
beast
Definition
base_uint.h:697
beast::Severity
Severity
Severity level / threshold of a Journal message.
Definition
Journal.h:16
std
STL namespace.
string
utility
Generated by
1.17.0