xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
beast
utility
beast_Journal.cpp
1
#include <xrpl/beast/utility/Journal.h>
2
3
#include <
ios
>
4
#include <
ostream
>
5
#include <
string
>
6
7
namespace
beast
{
8
9
//------------------------------------------------------------------------------
10
11
// A Sink that does nothing.
12
class
NullJournalSink
:
public
Journal::Sink
13
{
14
public
:
15
NullJournalSink
() :
Sink
(
Severity
::
Disabled
, false)
16
{
17
}
18
19
~NullJournalSink
()
override
=
default
;
20
21
[[nodiscard]]
bool
22
active
(
Severity
)
const override
23
{
24
return
false
;
25
}
26
27
[[nodiscard]]
bool
28
console
()
const override
29
{
30
return
false
;
31
}
32
33
void
34
console
(
bool
)
override
35
{
36
}
37
38
[[nodiscard]]
Severity
39
threshold
()
const override
40
{
41
return
Severity::Disabled
;
42
}
43
44
void
45
threshold
(
Severity
)
override
46
{
47
}
48
49
void
50
write
(
Severity
,
std::string
const
&)
override
51
{
52
}
53
54
void
55
writeAlways
(
Severity
,
std::string
const
&)
override
56
{
57
}
58
};
59
60
//------------------------------------------------------------------------------
61
62
Journal::Sink&
63
Journal::getNullSink
()
64
{
65
static
NullJournalSink
kSink;
66
return
kSink;
67
}
68
69
//------------------------------------------------------------------------------
70
71
Journal::Sink::Sink
(
Severity
thresh,
bool
console
) :
thresh_
(thresh),
console_
(
console
)
72
{
73
}
74
75
Journal::Sink::~Sink
() =
default
;
76
77
bool
78
Journal::Sink::active
(
Severity
level)
const
79
{
80
return
level >=
thresh_
;
81
}
82
83
bool
84
Journal::Sink::console
()
const
85
{
86
return
console_
;
87
}
88
89
void
90
Journal::Sink::console
(
bool
output)
91
{
92
console_
= output;
93
}
94
95
Severity
96
Journal::Sink::threshold
()
const
97
{
98
return
thresh_
;
99
}
100
101
void
102
Journal::Sink::threshold
(
Severity
thresh)
103
{
104
thresh_
= thresh;
105
}
106
107
//------------------------------------------------------------------------------
108
109
Journal::ScopedStream::ScopedStream
(
Sink
&
sink
,
Severity
level) :
sink_
(
sink
),
level_
(level)
110
{
111
// Modifiers applied from all ctors
112
ostream_
<<
std::boolalpha
<<
std::showbase
;
113
}
114
115
Journal::ScopedStream::ScopedStream
(
Stream
const
&
stream
,
std::ostream
& manip(
std::ostream
&))
116
:
ScopedStream
(
stream
.
sink
(),
stream
.level())
117
{
118
ostream_
<< manip;
119
}
120
121
Journal::ScopedStream::~ScopedStream
()
122
{
123
std::string
const
& s(
ostream_
.str());
124
if
(!s.
empty
())
125
{
126
if
(s ==
"\n"
)
127
{
128
sink_
.write(
level_
,
""
);
129
}
130
else
131
{
132
sink_
.write(
level_
, s);
133
}
134
}
135
}
136
137
std::ostream
&
138
Journal::ScopedStream::operator<<
(
std::ostream
& manip(
std::ostream
&))
const
139
{
140
return
ostream_
<< manip;
141
}
142
143
//------------------------------------------------------------------------------
144
145
Journal::ScopedStream
146
Journal::Stream::operator<<
(
std::ostream
& manip(
std::ostream
&))
const
147
{
148
return
ScopedStream
(*
this
, manip);
149
}
150
151
}
// namespace beast
std::ostream
std::string
std::boolalpha
T boolalpha(T... args)
beast::Journal::ScopedStream
Definition
Journal.h:147
beast::Journal::ScopedStream::operator<<
std::ostream & operator<<(std::ostream &manip(std::ostream &)) const
Definition
beast_Journal.cpp:138
beast::Journal::ScopedStream::~ScopedStream
~ScopedStream()
Definition
beast_Journal.cpp:121
beast::Journal::ScopedStream::ostream_
std::ostringstream ostream_
Definition
Journal.h:181
beast::Journal::ScopedStream::sink_
Sink & sink_
Definition
Journal.h:179
beast::Journal::ScopedStream::ScopedStream
ScopedStream(ScopedStream const &other)
Definition
Journal.h:149
beast::Journal::ScopedStream::level_
Severity const level_
Definition
Journal.h:180
beast::Journal::Sink
Abstraction for the underlying message destination.
Definition
Journal.h:59
beast::Journal::Sink::console_
bool console_
Definition
Journal.h:123
beast::Journal::Sink::thresh_
Severity thresh_
Definition
Journal.h:122
beast::Journal::Sink::threshold
virtual Severity threshold() const
Returns the minimum severity level this sink will report.
Definition
beast_Journal.cpp:96
beast::Journal::Sink::Sink
Sink(Sink const &sink)=default
beast::Journal::Sink::active
virtual bool active(Severity level) const
Returns true if text at the passed severity produces output.
Definition
beast_Journal.cpp:78
beast::Journal::Sink::console
virtual bool console() const
Returns true if a message is also written to the Output Window (MSVC).
Definition
beast_Journal.cpp:84
beast::Journal::Sink::Sink
Sink()=delete
beast::Journal::Sink::~Sink
virtual ~Sink()=0
beast::Journal::Stream
Provide a light-weight way to check active() before string formatting.
Definition
Journal.h:199
beast::Journal::Stream::operator<<
ScopedStream operator<<(std::ostream &manip(std::ostream &)) const
Output stream support.
Definition
beast_Journal.cpp:146
beast::Journal::sink
Sink & sink() const
Returns the Sink associated with this Journal.
Definition
Journal.h:308
beast::Journal::stream
Stream stream(Severity level) const
Returns a stream for this sink, with the specified severity level.
Definition
Journal.h:317
beast::Journal::getNullSink
static Sink & getNullSink()
Returns a Sink which does nothing.
Definition
beast_Journal.cpp:63
beast::NullJournalSink
Definition
beast_Journal.cpp:13
beast::NullJournalSink::threshold
Severity threshold() const override
Returns the minimum severity level this sink will report.
Definition
beast_Journal.cpp:39
beast::NullJournalSink::console
bool console() const override
Returns true if a message is also written to the Output Window (MSVC).
Definition
beast_Journal.cpp:28
beast::NullJournalSink::NullJournalSink
NullJournalSink()
Definition
beast_Journal.cpp:15
beast::NullJournalSink::active
bool active(Severity) const override
Returns true if text at the passed severity produces output.
Definition
beast_Journal.cpp:22
beast::NullJournalSink::threshold
void threshold(Severity) override
Set the minimum severity this sink will report.
Definition
beast_Journal.cpp:45
beast::NullJournalSink::writeAlways
void writeAlways(Severity, std::string const &) override
Bypass filter and write text to the sink at the specified severity.
Definition
beast_Journal.cpp:55
beast::NullJournalSink::~NullJournalSink
~NullJournalSink() override=default
beast::NullJournalSink::console
void console(bool) override
Set whether messages are also written to the Output Window (MSVC).
Definition
beast_Journal.cpp:34
beast::NullJournalSink::write
void write(Severity, std::string const &) override
Write text to the sink at the specified severity.
Definition
beast_Journal.cpp:50
std::string::empty
T empty(T... args)
ios
beast
Definition
base_uint.h:697
beast::Severity
Severity
Severity level / threshold of a Journal message.
Definition
Journal.h:16
beast::Severity::Disabled
@ Disabled
Definition
Journal.h:26
ostream
std::showbase
T showbase(T... args)
string
Generated by
1.17.0