Cleanups in beast::Journal:

The Journal API is affected.  There are two uses for the
Journal::Severity enum:

 o It is used to declare a threshold which log messages must meet
   in order to be logged.

 o It declares the current logging level which will be compared
   to the threshold.

Those uses that affect the threshold are now named threshold()
rather than severity() to make the uses easier to distinguish.

Additionally, Journal no longer carries a Severity variable.
All handling of the threshold() is now delegated to the
Journal::Sink.

Sinks are no longer constructed with a default threshold of
kWarning; their threshold must be passed in on construction.
This commit is contained in:
Scott Schurr
2016-02-17 18:34:42 -08:00
committed by seelabs
parent f846b1a88f
commit 6366f62f11
17 changed files with 149 additions and 291 deletions

View File

@@ -2548,8 +2548,6 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\peerfinder\sim\Predicates.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\peerfinder\sim\WrappedSink.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\peerfinder\Slot.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\peerfinder\tests\Livecache.test.cpp">

View File

@@ -3096,9 +3096,6 @@
<ClInclude Include="..\..\src\ripple\peerfinder\sim\Predicates.h">
<Filter>ripple\peerfinder\sim</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\peerfinder\sim\WrappedSink.h">
<Filter>ripple\peerfinder\sim</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\peerfinder\Slot.h">
<Filter>ripple\peerfinder</Filter>
</ClInclude>

View File

@@ -24,7 +24,18 @@
namespace beast {
/** A generic endpoint for log messages. */
/** A generic endpoint for log messages.
The Journal has a few simple goals:
* To be light-weight and copied by value.
* To allow logging statements to be left in source code.
* The logging is controlled at run-time based on a logging threshold.
It is advisable to check Journal::active(level) prior to formatting log
text. Doing so sidesteps expensive text formatting when the results
will not be sent to the log.
*/
class Journal
{
public:
@@ -47,10 +58,7 @@ public:
class Sink;
private:
Journal& operator= (Journal const& other); // disallowed
Sink* m_sink;
Severity m_level;
public:
//--------------------------------------------------------------------------
@@ -58,9 +66,12 @@ public:
/** Abstraction for the underlying message destination. */
class Sink
{
public:
Sink ();
protected:
Sink () = delete;
explicit Sink(Sink const& sink) = default;
Sink (Severity thresh, bool console);
public:
virtual ~Sink () = 0;
/** Returns `true` if text at the passed severity produces output. */
@@ -73,19 +84,19 @@ public:
virtual void console (bool output);
/** Returns the minimum severity level this sink will report. */
virtual Severity severity() const;
virtual Severity threshold() const;
/** Set the minimum severity this sink will report. */
virtual void severity (Severity level);
virtual void threshold (Severity thresh);
/** Write text to the sink at the specified severity.
The caller is responsible for checking the minimum severity level
before using this function.
A conforming implementation will not write the text if the passed
level is below the current threshold().
*/
virtual void write (Severity level, std::string const& text) = 0;
private:
Severity m_level;
Severity thresh_;
bool m_console;
};
@@ -107,9 +118,7 @@ public:
ScopedStream (Stream const& stream, T const& t)
: m_sink (stream.sink())
, m_level (stream.severity())
, m_active (stream.active ())
{
if (active ())
m_ostream << t;
}
@@ -118,9 +127,6 @@ public:
~ScopedStream ();
bool active () const
{ return m_active; }
std::ostringstream& ostream () const;
std::ostream& operator<< (
@@ -129,7 +135,6 @@ public:
template <typename T>
std::ostream& operator<< (T const& t) const
{
if (active ())
m_ostream << t;
return m_ostream;
}
@@ -140,10 +145,8 @@ public:
ScopedStream& operator= (ScopedStream const&); // disallowed
Sink& m_sink;
Severity const m_level;
bool const m_active;
Severity const m_level; // cached from Stream for call to m_sink.write
std::ostringstream mutable m_ostream;
bool m_toOutputWindow;
};
//--------------------------------------------------------------------------
@@ -155,10 +158,7 @@ public:
Stream ();
/** Create stream that writes at the given level. */
/** @{ */
Stream (Sink& sink, Severity level, bool active = true);
Stream (Stream const& stream, bool active);
/** @} */
Stream (Sink& sink, Severity level);
/** Construct or copy another Stream. */
/** @{ */
@@ -174,7 +174,10 @@ public:
/** Returns `true` if sink logs anything at this stream's severity. */
/** @{ */
bool active() const;
bool active() const
{
return m_sink->active (m_level);
}
explicit
operator bool() const
@@ -197,7 +200,6 @@ public:
private:
Sink* m_sink;
Severity m_level;
bool m_disabled;
};
//--------------------------------------------------------------------------
@@ -206,17 +208,13 @@ public:
Journal ();
/** Create a journal that writes to the specified sink. */
/** @{ */
explicit Journal (Sink& sink, Severity level = kAll);
explicit Journal (Sink& sink);
/** Create a journal from another journal.
When specifying a new minimum severity level, the effective minimum
level will be the higher of the other journal and the specified value.
*/
/** @{ */
/** Create a journal from another journal. */
Journal (Journal const& other);
Journal (Journal const& other, Severity level);
/** @} */
// Disallowed.
Journal& operator= (Journal const& other) = delete;
/** Destroy the journal. */
~Journal ();
@@ -228,17 +226,11 @@ public:
Stream stream (Severity level) const;
/** Returns `true` if any message would be logged at this severity level.
For a message to be logged, the severity must be at or above both
the journal's severity level and the sink's severity level.
For a message to be logged, the severity must be at or above the
sink's severity threshold.
*/
bool active (Severity level) const;
/** Returns this Journal's minimum severity level.
If the underlying sink has a higher threshold, there will still
be no output at that level.
*/
Severity severity () const;
/** Convenience sink streams for each severity level. */
Stream const trace;
Stream const debug;

View File

@@ -25,6 +25,11 @@
namespace beast {
/** Wraps a Journal::Sink to prefix its output with a string. */
// A WrappedSink both is a Sink and has a Sink:
// o It inherits from Sink so it has the correct interface.
// o It has a sink (reference) so it preserves the passed write() behavior.
// The data inherited from the base class is ignored.
class WrappedSink : public beast::Journal::Sink
{
private:
@@ -34,15 +39,15 @@ private:
public:
explicit
WrappedSink (beast::Journal::Sink& sink, std::string const& prefix = "")
: sink_(sink)
: Sink (sink)
, sink_(sink)
, prefix_(prefix)
{
}
explicit
WrappedSink (beast::Journal const& journal, std::string const& prefix = "")
: sink_(journal.sink())
, prefix_(prefix)
: WrappedSink (journal.sink(), prefix)
{
}
@@ -69,14 +74,14 @@ public:
}
beast::Journal::Severity
severity() const override
threshold() const override
{
return sink_.severity();
return sink_.threshold();
}
void severity (beast::Journal::Severity level) override
void threshold (beast::Journal::Severity thresh) override
{
sink_.severity (level);
sink_.threshold (thresh);
}
void write (beast::Journal::Severity level, std::string const& text) override

View File

@@ -28,30 +28,36 @@ namespace beast {
class NullJournalSink : public Journal::Sink
{
public:
bool active (Journal::Severity) const
NullJournalSink ()
: Sink (Journal::kDisabled, false)
{ }
~NullJournalSink() override = default;
bool active (Journal::Severity) const override
{
return false;
}
bool console() const
bool console() const override
{
return false;
}
void console (bool)
void console (bool) override
{
}
Journal::Severity severity() const
Journal::Severity threshold() const override
{
return Journal::kDisabled;
}
void severity (Journal::Severity)
void threshold (Journal::Severity) override
{
}
void write (Journal::Severity, std::string const&)
void write (Journal::Severity, std::string const&) override
{
}
};
@@ -66,9 +72,9 @@ Journal::Sink& Journal::getNullSink ()
//------------------------------------------------------------------------------
Journal::Sink::Sink ()
: m_level (kWarning)
, m_console (false)
Journal::Sink::Sink (Severity thresh, bool console)
: thresh_ (thresh)
, m_console (console)
{
}
@@ -78,7 +84,7 @@ Journal::Sink::~Sink ()
bool Journal::Sink::active (Severity level) const
{
return level >= m_level;
return level >= thresh_;
}
bool Journal::Sink::console () const
@@ -91,14 +97,14 @@ void Journal::Sink::console (bool output)
m_console = output;
}
Journal::Severity Journal::Sink::severity () const
Journal::Severity Journal::Sink::threshold () const
{
return m_level;
return thresh_;
}
void Journal::Sink::severity (Severity level)
void Journal::Sink::threshold (Severity thresh)
{
m_level = level;
thresh_ = thresh;
}
//------------------------------------------------------------------------------
@@ -106,7 +112,6 @@ void Journal::Sink::severity (Severity level)
Journal::ScopedStream::ScopedStream (Stream const& stream)
: m_sink (stream.sink ())
, m_level (stream.severity ())
, m_active (stream.active ())
{
init ();
}
@@ -114,7 +119,6 @@ Journal::ScopedStream::ScopedStream (Stream const& stream)
Journal::ScopedStream::ScopedStream (ScopedStream const& other)
: m_sink (other.m_sink)
, m_level (other.m_level)
, m_active (other.m_active)
{
init ();
}
@@ -123,16 +127,12 @@ Journal::ScopedStream::ScopedStream (
Stream const& stream, std::ostream& manip (std::ostream&))
: m_sink (stream.sink ())
, m_level (stream.severity ())
, m_active (stream.active ())
{
init ();
if (active ())
m_ostream << manip;
}
Journal::ScopedStream::~ScopedStream ()
{
if (active ())
{
std::string const& s (m_ostream.str());
if (! s.empty ())
@@ -143,17 +143,13 @@ Journal::ScopedStream::~ScopedStream ()
m_sink.write (m_level, s);
}
}
}
void Journal::ScopedStream::init ()
{
// Modifiers applied from all ctors
m_ostream
<< std::boolalpha
<< std::showbase
//<< std::hex
;
<< std::showbase;
}
std::ostream& Journal::ScopedStream::operator<< (std::ostream& manip (std::ostream&)) const
@@ -171,29 +167,19 @@ std::ostringstream& Journal::ScopedStream::ostream () const
Journal::Stream::Stream ()
: m_sink (&getNullSink ())
, m_level (kDisabled)
, m_disabled (true)
{
}
Journal::Stream::Stream (Sink& sink, Severity level, bool active)
Journal::Stream::Stream (Sink& sink, Severity level)
: m_sink (&sink)
, m_level (level)
, m_disabled (! active)
{
assert (level != kDisabled);
}
Journal::Stream::Stream (Stream const& stream, bool active)
: m_sink (&stream.sink ())
, m_level (stream.severity ())
, m_disabled (! active)
{
}
Journal::Stream::Stream (Stream const& other)
: m_sink (other.m_sink)
, m_level (other.m_level)
, m_disabled (other.m_disabled)
{
}
@@ -207,11 +193,6 @@ Journal::Severity Journal::Stream::severity () const
return m_level;
}
bool Journal::Stream::active () const
{
return ! m_disabled && m_sink->active (m_level);
}
Journal::Stream& Journal::Stream::operator= (Stream const& other)
{
m_sink = other.m_sink;
@@ -229,7 +210,6 @@ Journal::ScopedStream Journal::Stream::operator<< (
Journal::Journal ()
: m_sink (&getNullSink())
, m_level (kDisabled)
, trace (stream (kTrace))
, debug (stream (kDebug))
, info (stream (kInfo))
@@ -239,9 +219,8 @@ Journal::Journal ()
{
}
Journal::Journal (Sink& sink, Severity level)
Journal::Journal (Sink& sink)
: m_sink (&sink)
, m_level (level)
, trace (stream (kTrace))
, debug (stream (kDebug))
, info (stream (kInfo))
@@ -252,26 +231,7 @@ Journal::Journal (Sink& sink, Severity level)
}
Journal::Journal (Journal const& other)
: m_sink (other.m_sink)
, m_level (other.m_level)
, trace (stream (kTrace))
, debug (stream (kDebug))
, info (stream (kInfo))
, warning (stream (kWarning))
, error (stream (kError))
, fatal (stream (kFatal))
{
}
Journal::Journal (Journal const& other, Severity level)
: m_sink (other.m_sink)
, m_level (std::max (other.m_level, level))
, trace (stream (kTrace))
, debug (stream (kDebug))
, info (stream (kInfo))
, warning (stream (kWarning))
, error (stream (kError))
, fatal (stream (kFatal))
: Journal (*other.m_sink)
{
}
@@ -286,21 +246,12 @@ Journal::Sink& Journal::sink() const
Journal::Stream Journal::stream (Severity level) const
{
return Stream (*m_sink, level, level >= m_level);
return Stream (*m_sink, level);
}
bool Journal::active (Severity level) const
{
if (level == kDisabled)
return false;
if (level < m_level)
return false;
return m_sink->active (level);
}
Journal::Severity Journal::severity () const
{
return m_level;
}
}

View File

@@ -32,7 +32,8 @@ public:
public:
TestSink()
: m_count(0)
: Sink (Journal::kWarning, false)
, m_count(0)
{
}
@@ -49,8 +50,9 @@ public:
}
void
write (Journal::Severity, std::string const&)
write (Journal::Severity level, std::string const&) override
{
if (level >= threshold())
++m_count;
}
};
@@ -59,7 +61,7 @@ public:
{
TestSink sink;
sink.severity(Journal::kInfo);
sink.threshold(Journal::kInfo);
Journal j(sink);
@@ -78,7 +80,7 @@ public:
sink.reset();
sink.severity(Journal::kDebug);
sink.threshold(Journal::kDebug);
j.trace << " ";
expect(sink.count() == 0);

View File

@@ -958,8 +958,8 @@ void ApplicationImp::setup()
if (!logs_->open(debug_log))
std::cerr << "Can't open log file " << debug_log << '\n';
if (logs_->severity() > beast::Journal::kDebug)
logs_->severity (beast::Journal::kDebug);
if (logs_->threshold() > beast::Journal::kDebug)
logs_->threshold (beast::Journal::kDebug);
}
logs_->silent (config_->SILENT);

View File

@@ -425,11 +425,11 @@ int run (int argc, char** argv)
auto logs = std::make_unique<Logs>();
if (vm.count ("quiet"))
logs->severity (beast::Journal::kFatal);
logs->threshold (beast::Journal::kFatal);
else if (vm.count ("verbose"))
logs->severity (beast::Journal::kTrace);
logs->threshold (beast::Journal::kTrace);
else
logs->severity (beast::Journal::kInfo);
logs->threshold (beast::Journal::kInfo);
if (vm.count ("debug"))
setDebugJournalSink (logs->get("Debug"));

View File

@@ -57,7 +57,7 @@ private:
public:
Sink (std::string const& partition,
beast::Journal::Severity severity, Logs& logs);
beast::Journal::Severity thresh, Logs& logs);
Sink (Sink const&) = delete;
Sink& operator= (Sink const&) = delete;
@@ -149,7 +149,7 @@ private:
std::map <std::string,
std::unique_ptr<beast::Journal::Sink>,
beast::ci_less> sinks_;
beast::Journal::Severity level_;
beast::Journal::Severity thresh_;
File file_;
bool silent_ = false;
@@ -174,10 +174,10 @@ public:
journal (std::string const& name);
beast::Journal::Severity
severity() const;
threshold() const;
void
severity (beast::Journal::Severity level);
threshold (beast::Journal::Severity thresh);
std::vector<std::pair<std::string, std::string>>
partition_severities() const;
@@ -276,19 +276,19 @@ class LogSquelcher
{
public:
LogSquelcher()
: severity_(deprecatedLogs().severity())
: thresh_(deprecatedLogs().threshold())
{
deprecatedLogs().severity(
deprecatedLogs().threshold(
beast::Journal::Severity::kNone);
}
~LogSquelcher()
{
deprecatedLogs().severity(severity_);
deprecatedLogs().threshold(thresh_);
}
private:
beast::Journal::Severity const severity_;
beast::Journal::Severity const thresh_;
};
} // ripple

View File

@@ -28,16 +28,19 @@
namespace ripple {
Logs::Sink::Sink (std::string const& partition,
beast::Journal::Severity severity, Logs& logs)
: logs_(logs)
beast::Journal::Severity thresh, Logs& logs)
: beast::Journal::Sink (thresh, false)
, logs_(logs)
, partition_(partition)
{
beast::Journal::Sink::severity (severity);
}
void
Logs::Sink::write (beast::Journal::Severity level, std::string const& text)
{
if (level < threshold())
return;
logs_.write (level, partition_, text, console());
}
@@ -109,7 +112,7 @@ void Logs::File::writeln (char const* text)
//------------------------------------------------------------------------------
Logs::Logs()
: level_ (beast::Journal::kWarning) // default severity
: thresh_ (beast::Journal::kWarning) // default severity
{
}
@@ -124,7 +127,7 @@ Logs::get (std::string const& name)
{
std::lock_guard <std::mutex> lock (mutex_);
auto const result =
sinks_.emplace(name, makeSink(name, level_));
sinks_.emplace(name, makeSink(name, thresh_));
return *result.first->second;
}
@@ -141,18 +144,18 @@ Logs::journal (std::string const& name)
}
beast::Journal::Severity
Logs::severity() const
Logs::threshold() const
{
return level_;
return thresh_;
}
void
Logs::severity (beast::Journal::Severity level)
Logs::threshold (beast::Journal::Severity thresh)
{
std::lock_guard <std::mutex> lock (mutex_);
level_ = level;
thresh_ = thresh;
for (auto& sink : sinks_)
sink.second->severity (level);
sink.second->threshold (thresh);
}
std::vector<std::pair<std::string, std::string>>
@@ -163,7 +166,7 @@ Logs::partition_severities() const
list.reserve (sinks_.size());
for (auto const& e : sinks_)
list.push_back(std::make_pair(e.first,
toString(fromSeverity(e.second->severity()))));
toString(fromSeverity(e.second->threshold()))));
return list;
}
@@ -194,10 +197,10 @@ Logs::rotate()
std::unique_ptr<beast::Journal::Sink>
Logs::makeSink(std::string const& name,
beast::Journal::Severity startingLevel)
beast::Journal::Severity threshold)
{
return std::make_unique<Sink>(
name, startingLevel, *this);
name, threshold, *this);
}
LogSeverity

View File

@@ -107,14 +107,12 @@ public:
Logic (clock_type& clock, Store& store,
Checker& checker, beast::Journal journal)
: m_journal (journal, Reporting::logic)
: m_journal (journal)
, m_clock (clock)
, m_store (store)
, m_checker (checker)
, livecache_ (m_clock,
beast::Journal (journal, Reporting::livecache))
, bootcache_ (store, m_clock,
beast::Journal (journal, Reporting::bootcache))
, livecache_ (m_clock, journal)
, bootcache_ (store, m_clock, journal)
, m_whenBroadcast (m_clock.now())
, m_squelches (m_clock)
{

View File

@@ -39,29 +39,6 @@ struct Reporting
// Report nodes detailed information
static bool const dump_nodes = false;
//
//
//
// Reports from Network (and children)
static beast::Journal::Severity const network = beast::Journal::kWarning;
// Reports from simulation Node (and children)
static beast::Journal::Severity const node = beast::Journal::kAll;
//
//
//
// Reports from Logic
static beast::Journal::Severity const logic = beast::Journal::kAll;
// Reports from Livecache
static beast::Journal::Severity const livecache = beast::Journal::kAll;
// Reports from Bootcache
static beast::Journal::Severity const bootcache = beast::Journal::kAll;
};
}

View File

@@ -1,78 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_PEERFINDER_SIM_WRAPPEDSINK_H_INCLUDED
#define RIPPLE_PEERFINDER_SIM_WRAPPEDSINK_H_INCLUDED
namespace ripple {
namespace PeerFinder {
/** Wraps a Journal::Sink to prefix its output. */
class WrappedSink : public beast::Journal::Sink
{
public:
WrappedSink (std::string const& prefix, beast::Journal::Sink& sink)
: m_prefix (prefix)
, m_sink (sink)
{
}
bool active (beast::Journal::Severity level) const
{ return m_sink.active (level); }
bool console () const
{ return m_sink.console (); }
void console (bool output)
{ m_sink.console (output); }
beast::Journal::Severity severity() const
{ return m_sink.severity(); }
void severity (beast::Journal::Severity level)
{ m_sink.severity (level); }
void write (beast::Journal::Severity level, std::string const& text)
{
using beast::Journal;
std::string s (m_prefix);
switch (level)
{
case Journal::kTrace: s += "Trace: "; break;
case Journal::kDebug: s += "Debug: "; break;
case Journal::kInfo: s += "Info : "; break;
case Journal::kWarning: s += "Warn : "; break;
case Journal::kError: s += "Error: "; break;
default:
case Journal::kFatal: s += "Fatal: "; break;
};
s+= text;
m_sink.write (level, s);
}
private:
std::string const m_prefix;
beast::Journal::Sink& m_sink;
};
}
}
#endif

View File

@@ -39,7 +39,7 @@ Json::Value doLogLevel (RPC::Context& context)
Json::Value lev (Json::objectValue);
lev[jss::base] =
Logs::toString(Logs::fromSeverity(context.app.logs().severity()));
Logs::toString(Logs::fromSeverity(context.app.logs().threshold()));
std::vector< std::pair<std::string, std::string> > logTable (
context.app.logs().partition_severities());
using stringPair = std::map<std::string, std::string>::value_type;
@@ -60,21 +60,21 @@ Json::Value doLogLevel (RPC::Context& context)
// log_level severity
if (!context.params.isMember (jss::partition))
{
// set base log severity
context.app.logs().severity(severity);
// set base log threshold
context.app.logs().threshold(severity);
return Json::objectValue;
}
// log_level partition severity base?
if (context.params.isMember (jss::partition))
{
// set partition severity
// set partition threshold
std::string partition (context.params[jss::partition].asString ());
if (boost::iequals (partition, "base"))
context.app.logs().severity (severity);
context.app.logs().threshold (severity);
else
context.app.logs().get(partition).severity(severity);
context.app.logs().get(partition).threshold(severity);
return Json::objectValue;
}

View File

@@ -77,7 +77,8 @@ public:
public:
TestSink (beast::unit_test::suite& suite)
: suite_ (suite)
: Sink (beast::Journal::kWarning, false)
, suite_ (suite)
{
}
@@ -85,6 +86,9 @@ public:
write (beast::Journal::Severity level,
std::string const& text) override
{
if (level < threshold())
return;
suite_.log << text;
}
};
@@ -275,7 +279,7 @@ public:
{
TestSink sink {*this};
TestThread thread;
sink.severity (beast::Journal::Severity::kAll);
sink.threshold (beast::Journal::Severity::kAll);
beast::Journal journal {sink};
TestHandler handler;
auto s = make_Server (handler,

View File

@@ -92,12 +92,20 @@ class SuiteSink : public beast::Journal::Sink
public:
SuiteSink(std::string const& partition,
beast::Journal::Severity threshold,
beast::unit_test::suite& suite)
: partition_(partition + " ")
: Sink (threshold, false)
, partition_(partition + " ")
, suite_ (suite)
{
}
// For unit testing, always generate logging text.
bool active(beast::Journal::Severity level) const override
{
return true;
}
void
write(beast::Journal::Severity level,
std::string const& text) override
@@ -113,6 +121,9 @@ public:
default:
case beast::Journal::kFatal: s = "FTL:"; break;
}
// Only write the string if the level at least equals the threshold.
if (level >= threshold())
suite_.log << s << partition_ << text;
}
};
@@ -132,9 +143,9 @@ public:
std::unique_ptr<beast::Journal::Sink>
makeSink(std::string const& partition,
beast::Journal::Severity startingLevel) override
beast::Journal::Severity threshold) override
{
return std::make_unique<SuiteSink>(partition, suite_);
return std::make_unique<SuiteSink>(partition, threshold, suite_);
}
};
@@ -153,14 +164,13 @@ Env::AppBundle::AppBundle(beast::unit_test::suite& suite,
auto timeKeeper_ =
std::make_unique<ManualTimeKeeper>();
timeKeeper = timeKeeper_.get();
// Hack so we dont have to call Config::setup
// Hack so we don't have to call Config::setup
HTTPClient::initializeSSLContext(*config);
owned = make_Application(std::move(config),
std::move(logs), std::move(timeKeeper_));
app = owned.get();
app->logs().severity(beast::Journal::kError);
app->logs().threshold(beast::Journal::kError);
app->setup();
app->logs().severity(beast::Journal::kError);
timeKeeper->set(
app->getLedgerMaster().getClosedLedger()->info().closeTime);
app->doStart();

View File

@@ -27,7 +27,6 @@
#include <ripple/peerfinder/impl/SourceStrings.cpp>
#include <ripple/peerfinder/sim/GraphAlgorithms.h>
#include <ripple/peerfinder/sim/WrappedSink.h>
#include <ripple/peerfinder/sim/Predicates.h>
#include <ripple/peerfinder/sim/FunctionQueue.h>
#include <ripple/peerfinder/sim/Message.h>