mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
@@ -30,8 +30,8 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -251,15 +251,15 @@ private:
|
||||
// Wraps a Journal::Stream to skip evaluation of
|
||||
// expensive argument lists if the stream is not active.
|
||||
#ifndef JLOG
|
||||
#define JLOG_JOIN_(a,b) a##b
|
||||
#define JLOG_JOIN(a,b) JLOG_JOIN_(a,b)
|
||||
#define JLOG_UNIQUE(base) JLOG_JOIN(base, __LINE__) // line-based unique name
|
||||
#define JLOG_JOIN_(a, b) a##b
|
||||
#define JLOG_JOIN(a, b) JLOG_JOIN_(a, b)
|
||||
#define JLOG_UNIQUE(base) JLOG_JOIN(base, __LINE__) // line-based unique name
|
||||
|
||||
#define JLOG(x) \
|
||||
#define JLOG(x) \
|
||||
if (auto JLOG_UNIQUE(stream) = (x); !JLOG_UNIQUE(stream)) \
|
||||
{ \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
} \
|
||||
else \
|
||||
std::move(JLOG_UNIQUE(stream))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
|
||||
#include <deque>
|
||||
#include <atomic>
|
||||
#include <charconv>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include <source_location>
|
||||
@@ -96,10 +96,14 @@ public:
|
||||
SimpleJsonWriter() = default;
|
||||
|
||||
SimpleJsonWriter(SimpleJsonWriter const& other) = default;
|
||||
SimpleJsonWriter& operator=(SimpleJsonWriter const& other) = default;
|
||||
SimpleJsonWriter&
|
||||
operator=(SimpleJsonWriter const& other) = default;
|
||||
|
||||
std::string&
|
||||
buffer() { return *buffer_; }
|
||||
buffer()
|
||||
{
|
||||
return *buffer_;
|
||||
}
|
||||
|
||||
void
|
||||
startObject() const
|
||||
@@ -334,16 +338,18 @@ public:
|
||||
detail::SimpleJsonWriter jsonWriter_;
|
||||
bool hasMessageParams_ = false;
|
||||
std::size_t messageOffset_ = 0;
|
||||
public:
|
||||
|
||||
JsonLogContext()
|
||||
: jsonWriter_(&messageBuffer_)
|
||||
public:
|
||||
JsonLogContext() : jsonWriter_(&messageBuffer_)
|
||||
{
|
||||
messageBuffer_.reserve(4 * 1024);
|
||||
}
|
||||
|
||||
std::string&
|
||||
messageBuffer() { return messageBuffer_; }
|
||||
messageBuffer()
|
||||
{
|
||||
return messageBuffer_;
|
||||
}
|
||||
|
||||
void
|
||||
startMessageParams()
|
||||
@@ -610,20 +616,20 @@ public:
|
||||
/** Output stream support. */
|
||||
/** @{ */
|
||||
ScopedStream
|
||||
operator<<(std::ostream& manip(std::ostream&)) const &&
|
||||
operator<<(std::ostream& manip(std::ostream&)) const&&
|
||||
{
|
||||
return {*this, manip};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ScopedStream
|
||||
operator<<(T const& t) const &&
|
||||
operator<<(T const& t) const&&
|
||||
{
|
||||
return {*this, t};
|
||||
}
|
||||
|
||||
ScopedStream
|
||||
operator<<(std::ostream& manip(std::ostream&)) const &
|
||||
operator<<(std::ostream& manip(std::ostream&)) const&
|
||||
{
|
||||
currentJsonLogContext_.reuseJson();
|
||||
return {*this, manip};
|
||||
@@ -631,7 +637,7 @@ public:
|
||||
|
||||
template <typename T>
|
||||
ScopedStream
|
||||
operator<<(T const& t) const &
|
||||
operator<<(T const& t) const&
|
||||
{
|
||||
currentJsonLogContext_.reuseJson();
|
||||
return {*this, t};
|
||||
@@ -956,7 +962,8 @@ setTextValue(
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << value;
|
||||
writer.buffer() += value;;
|
||||
writer.buffer() += value;
|
||||
;
|
||||
}
|
||||
writer.buffer() += " ";
|
||||
}
|
||||
@@ -1136,7 +1143,8 @@ attributes(Pair&&... pairs)
|
||||
return [&](beast::detail::SimpleJsonWriter& writer) {
|
||||
if (beast::Journal::isStructuredJournalEnabled())
|
||||
{
|
||||
(detail::setJsonValue(writer, pairs.first, pairs.second, nullptr), ...);
|
||||
(detail::setJsonValue(writer, pairs.first, pairs.second, nullptr),
|
||||
...);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -196,7 +196,7 @@ Journal::JsonLogContext::start(
|
||||
writer().writeString(severityStr);
|
||||
|
||||
auto nowMs = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch());
|
||||
std::chrono::system_clock::now().time_since_epoch());
|
||||
writer().writeKey("Tm");
|
||||
writer().writeString(date::format("%Y-%b-%d %T %Z", nowMs));
|
||||
|
||||
|
||||
@@ -53,14 +53,17 @@ private:
|
||||
operator=(Sink const&) = delete;
|
||||
|
||||
void
|
||||
write(beast::severities::Severity level, beast::Journal::StringBuffer text) override
|
||||
write(
|
||||
beast::severities::Severity level,
|
||||
beast::Journal::StringBuffer text) override
|
||||
{
|
||||
logs_.write(level, partition_, text, false);
|
||||
}
|
||||
|
||||
void
|
||||
writeAlways(beast::severities::Severity level, beast::Journal::StringBuffer text)
|
||||
override
|
||||
writeAlways(
|
||||
beast::severities::Severity level,
|
||||
beast::Journal::StringBuffer text) override
|
||||
{
|
||||
logs_.write(level, partition_, text, false);
|
||||
}
|
||||
@@ -174,12 +177,10 @@ TEST_CASE("Global attributes")
|
||||
CHECK(jsonLog.as_object().contains("Glb"));
|
||||
CHECK(jsonLog.as_object()["Glb"].is_object());
|
||||
CHECK(jsonLog.as_object()["Glb"].as_object().contains("Field1"));
|
||||
CHECK(jsonLog.as_object()["Glb"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
jsonLog.as_object()["Glb"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
jsonLog.as_object()["Glb"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == "Value1");
|
||||
jsonLog.as_object()["Glb"].as_object()["Field1"].get_string() ==
|
||||
"Value1");
|
||||
beast::Journal::disableStructuredJournal();
|
||||
}
|
||||
|
||||
@@ -206,20 +207,16 @@ TEST_CASE("Global attributes inheritable")
|
||||
|
||||
CHECK(jsonLog.is_object());
|
||||
CHECK(jsonLog.as_object()["Glb"].as_object().contains("Field1"));
|
||||
CHECK(jsonLog.as_object()["Glb"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
jsonLog.as_object()["Glb"].as_object()["Field1"].is_string());
|
||||
jsonLog.as_object()["Glb"].as_object()["Field1"].get_string() ==
|
||||
"Value1");
|
||||
CHECK(
|
||||
jsonLog.as_object()["Glb"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == "Value1");
|
||||
jsonLog.as_object()["Jnl"].as_object()["Field1"].get_string() ==
|
||||
"Value3");
|
||||
CHECK(
|
||||
jsonLog.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == "Value3");
|
||||
CHECK(
|
||||
jsonLog.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.get_string() == "Value2");
|
||||
jsonLog.as_object()["Jnl"].as_object()["Field2"].get_string() ==
|
||||
"Value2");
|
||||
beast::Journal::disableStructuredJournal();
|
||||
}
|
||||
|
||||
@@ -366,13 +363,16 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
write(beast::severities::Severity level, beast::Journal::StringBuffer text) override
|
||||
write(beast::severities::Severity level, beast::Journal::StringBuffer text)
|
||||
override
|
||||
{
|
||||
strm_ << text.str();
|
||||
}
|
||||
|
||||
void
|
||||
writeAlways(beast::severities::Severity level, beast::Journal::StringBuffer text) override
|
||||
writeAlways(
|
||||
beast::severities::Severity level,
|
||||
beast::Journal::StringBuffer text) override
|
||||
{
|
||||
strm_ << text.str();
|
||||
}
|
||||
@@ -387,7 +387,8 @@ public:
|
||||
{
|
||||
beast::Journal::resetGlobalAttributes();
|
||||
beast::Journal::enableStructuredJournal();
|
||||
j_ = beast::Journal{sink_, "Test", log::attributes(log::attr("Field1", "Value1"))};
|
||||
j_ = beast::Journal{
|
||||
sink_, "Test", log::attributes(log::attr("Field1", "Value1"))};
|
||||
}
|
||||
|
||||
~JsonLogStreamFixture()
|
||||
@@ -461,9 +462,7 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test json log levels")
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(
|
||||
logValue.as_object()["Mtd"]
|
||||
.as_object()["Lv"]
|
||||
.get_string() ==
|
||||
logValue.as_object()["Mtd"].as_object()["Lv"].get_string() ==
|
||||
beast::severities::to_string(beast::severities::kTrace));
|
||||
}
|
||||
|
||||
@@ -476,9 +475,7 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test json log levels")
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(
|
||||
logValue.as_object()["Mtd"]
|
||||
.as_object()["Lv"]
|
||||
.get_string() ==
|
||||
logValue.as_object()["Mtd"].as_object()["Lv"].get_string() ==
|
||||
beast::severities::to_string(beast::severities::kDebug));
|
||||
}
|
||||
|
||||
@@ -491,9 +488,7 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test json log levels")
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(
|
||||
logValue.as_object()["Mtd"]
|
||||
.as_object()["Lv"]
|
||||
.get_string() ==
|
||||
logValue.as_object()["Mtd"].as_object()["Lv"].get_string() ==
|
||||
beast::severities::to_string(beast::severities::kInfo));
|
||||
}
|
||||
|
||||
@@ -506,9 +501,7 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test json log levels")
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(
|
||||
logValue.as_object()["Mtd"]
|
||||
.as_object()["Lv"]
|
||||
.get_string() ==
|
||||
logValue.as_object()["Mtd"].as_object()["Lv"].get_string() ==
|
||||
beast::severities::to_string(beast::severities::kWarning));
|
||||
}
|
||||
|
||||
@@ -521,9 +514,7 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test json log levels")
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(
|
||||
logValue.as_object()["Mtd"]
|
||||
.as_object()["Lv"]
|
||||
.get_string() ==
|
||||
logValue.as_object()["Mtd"].as_object()["Lv"].get_string() ==
|
||||
beast::severities::to_string(beast::severities::kError));
|
||||
}
|
||||
|
||||
@@ -536,9 +527,7 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test json log levels")
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(
|
||||
logValue.as_object()["Mtd"]
|
||||
.as_object()["Lv"]
|
||||
.get_string() ==
|
||||
logValue.as_object()["Mtd"].as_object()["Lv"].get_string() ==
|
||||
beast::severities::to_string(beast::severities::kFatal));
|
||||
}
|
||||
}
|
||||
@@ -569,23 +558,14 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test json log params")
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Dt"].is_object());
|
||||
CHECK(logValue.as_object()["Dt"]
|
||||
.as_object()["Field1"]
|
||||
.is_number());
|
||||
CHECK(logValue.as_object()["Dt"].as_object()["Field1"].is_number());
|
||||
CHECK(logValue.as_object()["Dt"].as_object()["Field1"].get_int64() == 1);
|
||||
CHECK(logValue.as_object()["Dt"].as_object()["Field2"].is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Dt"]
|
||||
.as_object()["Field1"]
|
||||
.get_int64() == 1);
|
||||
CHECK(logValue.as_object()["Dt"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Dt"]
|
||||
.as_object()["Field2"]
|
||||
.get_uint64() == std::numeric_limits<std::uint64_t>::max());
|
||||
auto field3Val = logValue.as_object()["Dt"]
|
||||
.as_object()["Field3"]
|
||||
.get_double();
|
||||
logValue.as_object()["Dt"].as_object()["Field2"].get_uint64() ==
|
||||
std::numeric_limits<std::uint64_t>::max());
|
||||
auto field3Val =
|
||||
logValue.as_object()["Dt"].as_object()["Field3"].get_double();
|
||||
auto difference = std::abs(field3Val - std::numbers::pi);
|
||||
CHECK(difference < 1e-4);
|
||||
CHECK(logValue.as_object()["Msg"].is_string());
|
||||
@@ -606,23 +586,15 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test json log fields")
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Dt"].is_object());
|
||||
CHECK(logValue.as_object()["Dt"]
|
||||
.as_object()["Field1"]
|
||||
.is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Dt"]
|
||||
.as_object()["Field1"]
|
||||
.get_int64() == 1);
|
||||
CHECK(logValue.as_object()["Dt"].as_object()["Field1"].is_number());
|
||||
CHECK(logValue.as_object()["Dt"].as_object()["Field1"].get_int64() == 1);
|
||||
// UInt64 doesn't fit in Json::Value so it should be converted to a string
|
||||
// NOTE: We should expect it to be an int64 after we make the json library
|
||||
// support in64 and uint64
|
||||
CHECK(logValue.as_object()["Dt"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
CHECK(logValue.as_object()["Dt"].as_object()["Field2"].is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Dt"]
|
||||
.as_object()["Field2"]
|
||||
.get_uint64() == std::numeric_limits<std::uint64_t>::max());
|
||||
logValue.as_object()["Dt"].as_object()["Field2"].get_uint64() ==
|
||||
std::numeric_limits<std::uint64_t>::max());
|
||||
CHECK(logValue.as_object()["Msg"].is_string());
|
||||
CHECK(logValue.as_object()["Msg"].get_string() == "Test");
|
||||
}
|
||||
@@ -639,20 +611,12 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test journal attributes")
|
||||
auto logValue = boost::json::parse(stream().str(), ec);
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.is_string());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.get_int64() == 2);
|
||||
logValue.as_object()["Jnl"].as_object()["Field1"].get_string() ==
|
||||
std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].is_number());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].get_int64() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test journal attributes inheritable")
|
||||
@@ -668,27 +632,16 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test journal attributes inheritable")
|
||||
auto logValue = boost::json::parse(stream().str(), ec);
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.is_string());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field3"]
|
||||
.is_string());
|
||||
logValue.as_object()["Jnl"].as_object()["Field1"].get_string() ==
|
||||
std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field3"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field3"]
|
||||
.get_string() == std::string{"Value3"});
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.get_int64() == 2);
|
||||
logValue.as_object()["Jnl"].as_object()["Field3"].get_string() ==
|
||||
std::string{"Value3"});
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].is_number());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].get_int64() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test copying journal")
|
||||
@@ -706,20 +659,13 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test copying journal")
|
||||
auto logValue = boost::json::parse(stream().str(), ec);
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.is_string());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
logValue.as_object()["Jnl"].as_object()["Field1"].get_string() ==
|
||||
std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.get_int64() == 2);
|
||||
logValue.as_object()["Jnl"].as_object()["Field2"].get_int64() == 2);
|
||||
}
|
||||
{
|
||||
stream().str("");
|
||||
@@ -735,20 +681,13 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "Test copying journal")
|
||||
auto logValue = boost::json::parse(stream().str(), ec);
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.is_string());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
logValue.as_object()["Jnl"].as_object()["Field1"].get_string() ==
|
||||
std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.get_int64() == 2);
|
||||
logValue.as_object()["Jnl"].as_object()["Field2"].get_int64() == 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,28 +706,17 @@ TEST_CASE_FIXTURE(
|
||||
auto logValue = boost::json::parse(stream().str(), ec);
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.is_string());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field3"]
|
||||
.is_string());
|
||||
logValue.as_object()["Jnl"].as_object()["Field1"].get_string() ==
|
||||
std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field3"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field3"]
|
||||
.get_string() == std::string{"Value3"});
|
||||
logValue.as_object()["Jnl"].as_object()["Field3"].get_string() ==
|
||||
std::string{"Value3"});
|
||||
// Field2 should be overwritten to 0
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.get_int64() == 2);
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].is_number());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].get_int64() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(
|
||||
@@ -809,20 +737,12 @@ TEST_CASE_FIXTURE(
|
||||
auto logValue = boost::json::parse(stream().str(), ec);
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.is_string());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.get_int64() == 2);
|
||||
logValue.as_object()["Jnl"].as_object()["Field1"].get_string() ==
|
||||
std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].is_number());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].get_int64() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(
|
||||
@@ -843,18 +763,10 @@ TEST_CASE_FIXTURE(
|
||||
auto logValue = boost::json::parse(stream().str(), ec);
|
||||
CHECK(ec == boost::system::errc::success);
|
||||
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.is_string());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field1"].is_string());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field1"]
|
||||
.get_string() == std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.is_number());
|
||||
CHECK(
|
||||
logValue.as_object()["Jnl"]
|
||||
.as_object()["Field2"]
|
||||
.get_int64() == 2);
|
||||
logValue.as_object()["Jnl"].as_object()["Field1"].get_string() ==
|
||||
std::string{"Value1"});
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].is_number());
|
||||
CHECK(logValue.as_object()["Jnl"].as_object()["Field2"].get_int64() == 2);
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ flow(
|
||||
if (auto stream = j.trace())
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "\nsrc: " << src << "\ndst: " << dst
|
||||
<< "\nsrcIssue: " << srcIssue << "\ndstIssue: " << dstIssue;
|
||||
ss << "\nsrc: " << src << "\ndst: " << dst << "\nsrcIssue: " << srcIssue
|
||||
<< "\ndstIssue: " << dstIssue;
|
||||
ss << "\nNumStrands: " << strands.size();
|
||||
for (auto const& curStrand : strands)
|
||||
{
|
||||
|
||||
@@ -986,9 +986,9 @@ PeerImp::onReadMessage(error_code ec, std::size_t bytes_transferred)
|
||||
if (auto stream = journal_.trace())
|
||||
{
|
||||
std::move(stream) << "onReadMessage: "
|
||||
<< (bytes_transferred > 0
|
||||
? to_string(bytes_transferred) + " bytes"
|
||||
: "");
|
||||
<< (bytes_transferred > 0
|
||||
? to_string(bytes_transferred) + " bytes"
|
||||
: "");
|
||||
}
|
||||
|
||||
metrics_.recv.add_message(bytes_transferred);
|
||||
@@ -1068,9 +1068,9 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred)
|
||||
if (auto stream = journal_.trace())
|
||||
{
|
||||
std::move(stream) << "onWriteMessage: "
|
||||
<< (bytes_transferred > 0
|
||||
? to_string(bytes_transferred) + " bytes"
|
||||
: "");
|
||||
<< (bytes_transferred > 0
|
||||
? to_string(bytes_transferred) + " bytes"
|
||||
: "");
|
||||
}
|
||||
|
||||
metrics_.sent.add_message(bytes_transferred);
|
||||
|
||||
@@ -832,15 +832,17 @@ PeerImp::PeerImp(
|
||||
log::attributes(
|
||||
log::attr("NodeID", id),
|
||||
log::attr("RemoteAddress", to_string(slot->remote_endpoint())),
|
||||
log::attr("PublicKey", toBase58(TokenType::NodePublic, publicKey))
|
||||
))
|
||||
log::attr(
|
||||
"PublicKey",
|
||||
toBase58(TokenType::NodePublic, publicKey))))
|
||||
, p_journal_(
|
||||
app_.journal("Protocol"),
|
||||
log::attributes(
|
||||
log::attr("NodeID", id),
|
||||
log::attr("RemoteAddress", to_string(slot->remote_endpoint())),
|
||||
log::attr("PublicKey", toBase58(TokenType::NodePublic, publicKey))
|
||||
))
|
||||
log::attr(
|
||||
"PublicKey",
|
||||
toBase58(TokenType::NodePublic, publicKey))))
|
||||
, stream_ptr_(std::move(stream_ptr))
|
||||
, socket_(stream_ptr_->next_layer().socket())
|
||||
, stream_(*stream_ptr_)
|
||||
|
||||
Reference in New Issue
Block a user