mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-15 08:35:51 +00:00
Fix issues
This commit is contained in:
@@ -21,13 +21,14 @@
|
||||
#define BEAST_UTILITY_JOURNAL_H_INCLUDED
|
||||
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
#include <deque>
|
||||
#include <utility>
|
||||
#include <optional>
|
||||
#include <source_location>
|
||||
#include <sstream>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ripple::log {
|
||||
template <typename T>
|
||||
@@ -75,7 +76,7 @@ operator<<(std::ostream& os, LogField<T> const& param);
|
||||
template <typename T>
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, LogParameter<T> const& param);
|
||||
}
|
||||
} // namespace ripple::log
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -117,7 +118,9 @@ class Journal
|
||||
public:
|
||||
template <typename T>
|
||||
friend std::ostream&
|
||||
ripple::log::operator<<(std::ostream& os, ripple::log::LogField<T> const& param);
|
||||
ripple::log::operator<<(
|
||||
std::ostream& os,
|
||||
ripple::log::LogField<T> const& param);
|
||||
|
||||
template <typename T>
|
||||
friend std::ostream&
|
||||
@@ -198,7 +201,6 @@ private:
|
||||
|
||||
static thread_local JsonLogContext currentJsonLogContext_;
|
||||
|
||||
|
||||
// Invariant: m_sink always points to a valid Sink
|
||||
Sink* m_sink = nullptr;
|
||||
|
||||
@@ -206,9 +208,11 @@ private:
|
||||
initMessageContext(std::source_location location);
|
||||
|
||||
static std::string
|
||||
formatLog(std::string const& message,
|
||||
formatLog(
|
||||
std::string const& message,
|
||||
severities::Severity severity,
|
||||
std::optional<JsonLogAttributes> const& attributes = std::nullopt);
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -300,10 +304,7 @@ public:
|
||||
{
|
||||
public:
|
||||
ScopedStream(ScopedStream const& other)
|
||||
: ScopedStream(
|
||||
other.m_attributes,
|
||||
other.m_sink,
|
||||
other.m_level)
|
||||
: ScopedStream(other.m_attributes, other.m_sink, other.m_level)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -390,10 +391,7 @@ public:
|
||||
|
||||
/** Construct or copy another Stream. */
|
||||
Stream(Stream const& other)
|
||||
: Stream(
|
||||
other.m_attributes,
|
||||
other.m_sink,
|
||||
other.m_level)
|
||||
: Stream(other.m_attributes, other.m_sink, other.m_level)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -471,8 +469,7 @@ public:
|
||||
if (m_attributes.has_value())
|
||||
m_attributes = JsonLogAttributes::combine(
|
||||
other.m_attributes->contextValues_,
|
||||
m_attributes->contextValues_
|
||||
);
|
||||
m_attributes->contextValues_);
|
||||
else
|
||||
m_attributes = other.m_attributes;
|
||||
}
|
||||
@@ -521,8 +518,7 @@ public:
|
||||
Stream
|
||||
stream(Severity level) const
|
||||
{
|
||||
return Stream(
|
||||
m_attributes, *m_sink, level);
|
||||
return Stream(m_attributes, *m_sink, level);
|
||||
}
|
||||
|
||||
/** Returns `true` if any message would be logged at this severity level.
|
||||
@@ -542,10 +538,7 @@ public:
|
||||
{
|
||||
if (m_jsonLogsEnabled)
|
||||
initMessageContext(location);
|
||||
return {
|
||||
m_attributes,
|
||||
*m_sink,
|
||||
severities::kTrace};
|
||||
return {m_attributes, *m_sink, severities::kTrace};
|
||||
}
|
||||
|
||||
Stream
|
||||
@@ -553,10 +546,7 @@ public:
|
||||
{
|
||||
if (m_jsonLogsEnabled)
|
||||
initMessageContext(location);
|
||||
return {
|
||||
m_attributes,
|
||||
*m_sink,
|
||||
severities::kDebug};
|
||||
return {m_attributes, *m_sink, severities::kDebug};
|
||||
}
|
||||
|
||||
Stream
|
||||
@@ -564,23 +554,17 @@ public:
|
||||
{
|
||||
if (m_jsonLogsEnabled)
|
||||
initMessageContext(location);
|
||||
return {
|
||||
m_attributes,
|
||||
*m_sink,
|
||||
severities::kInfo};
|
||||
return {m_attributes, *m_sink, severities::kInfo};
|
||||
}
|
||||
|
||||
Stream
|
||||
warn(std::source_location location = std::source_location::current()) const
|
||||
{
|
||||
const char* a = "a";
|
||||
char const* a = "a";
|
||||
rapidjson::Value v{a, 1};
|
||||
if (m_jsonLogsEnabled)
|
||||
initMessageContext(location);
|
||||
return {
|
||||
m_attributes,
|
||||
*m_sink,
|
||||
severities::kWarning};
|
||||
return {m_attributes, *m_sink, severities::kWarning};
|
||||
}
|
||||
|
||||
Stream
|
||||
@@ -588,10 +572,7 @@ public:
|
||||
{
|
||||
if (m_jsonLogsEnabled)
|
||||
initMessageContext(location);
|
||||
return {
|
||||
m_attributes,
|
||||
*m_sink,
|
||||
severities::kError};
|
||||
return {m_attributes, *m_sink, severities::kError};
|
||||
}
|
||||
|
||||
Stream
|
||||
@@ -599,10 +580,7 @@ public:
|
||||
{
|
||||
if (m_jsonLogsEnabled)
|
||||
initMessageContext(location);
|
||||
return {
|
||||
m_attributes,
|
||||
*m_sink,
|
||||
severities::kFatal};
|
||||
return {m_attributes, *m_sink, severities::kFatal};
|
||||
}
|
||||
/** @} */
|
||||
|
||||
@@ -614,7 +592,9 @@ public:
|
||||
{
|
||||
globalLogAttributes_ = JsonLogAttributes{};
|
||||
}
|
||||
globalLogAttributes_ = JsonLogAttributes::combine(globalLogAttributes_->contextValues(), globalLogAttributes.contextValues());
|
||||
globalLogAttributes_ = JsonLogAttributes::combine(
|
||||
globalLogAttributes_->contextValues(),
|
||||
globalLogAttributes.contextValues());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -725,12 +705,12 @@ using logwstream = basic_logstream<wchar_t>;
|
||||
|
||||
} // namespace beast
|
||||
|
||||
|
||||
namespace ripple::log {
|
||||
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
void setJsonValue(
|
||||
void
|
||||
setJsonValue(
|
||||
rapidjson::Value& object,
|
||||
rapidjson::MemoryPoolAllocator<>& allocator,
|
||||
char const* name,
|
||||
@@ -739,7 +719,10 @@ void setJsonValue(
|
||||
{
|
||||
using ValueType = std::decay_t<T>;
|
||||
rapidjson::Value jsonValue;
|
||||
if constexpr (std::constructible_from<rapidjson::Value, ValueType, rapidjson::MemoryPoolAllocator<>&>)
|
||||
if constexpr (std::constructible_from<
|
||||
rapidjson::Value,
|
||||
ValueType,
|
||||
rapidjson::MemoryPoolAllocator<>&>)
|
||||
{
|
||||
jsonValue = rapidjson::Value{value, allocator};
|
||||
if (outStream)
|
||||
@@ -777,12 +760,9 @@ void setJsonValue(
|
||||
}
|
||||
|
||||
object.AddMember(
|
||||
rapidjson::StringRef(name),
|
||||
std::move(jsonValue),
|
||||
allocator
|
||||
);
|
||||
}
|
||||
rapidjson::StringRef(name), std::move(jsonValue), allocator);
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename T>
|
||||
std::ostream&
|
||||
@@ -793,7 +773,9 @@ operator<<(std::ostream& os, LogParameter<T> const& param)
|
||||
detail::setJsonValue(
|
||||
beast::Journal::currentJsonLogContext_.messageParams,
|
||||
beast::Journal::currentJsonLogContext_.allocator,
|
||||
param.name_, param.value_, &os);
|
||||
param.name_,
|
||||
param.value_,
|
||||
&os);
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -806,7 +788,9 @@ operator<<(std::ostream& os, LogField<T> const& param)
|
||||
detail::setJsonValue(
|
||||
beast::Journal::currentJsonLogContext_.messageParams,
|
||||
beast::Journal::currentJsonLogContext_.allocator,
|
||||
param.name_, param.value_, nullptr);
|
||||
param.name_,
|
||||
param.value_,
|
||||
nullptr);
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -824,17 +808,19 @@ field(char const* name, T&& value)
|
||||
return LogField<T>{name, std::forward<T>(value)};
|
||||
}
|
||||
|
||||
template<typename... Pair>
|
||||
template <typename... Pair>
|
||||
[[nodiscard]] beast::Journal::JsonLogAttributes
|
||||
attributes(Pair&&... pairs)
|
||||
{
|
||||
beast::Journal::JsonLogAttributes result;
|
||||
|
||||
(detail::setJsonValue(
|
||||
result.contextValues(),
|
||||
result.allocator(),
|
||||
pairs.first,
|
||||
pairs.second, nullptr), ...);
|
||||
result.contextValues(),
|
||||
result.allocator(),
|
||||
pairs.first,
|
||||
pairs.second,
|
||||
nullptr),
|
||||
...);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -846,6 +832,6 @@ attr(char const* name, T&& value)
|
||||
return std::make_pair(name, std::forward<T>(value));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ripple::log
|
||||
|
||||
#endif
|
||||
|
||||
@@ -84,12 +84,12 @@ BasePeer<Handler, Impl>::BasePeer(
|
||||
, handler_(handler)
|
||||
, remote_address_(remote_address)
|
||||
, j_(journal,
|
||||
log::attributes(
|
||||
log::attr("PeerID",
|
||||
[] {
|
||||
static std::atomic<unsigned> id{0};
|
||||
return "##" + std::to_string(++id) + " ";
|
||||
}())))
|
||||
log::attributes(log::attr(
|
||||
"PeerID",
|
||||
[] {
|
||||
static std::atomic<unsigned> id{0};
|
||||
return "##" + std::to_string(++id) + " ";
|
||||
}())))
|
||||
, work_(boost::asio::make_work_guard(executor))
|
||||
, strand_(boost::asio::make_strand(executor))
|
||||
{
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/writer.h>
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
#include <rapidjson/writer.h>
|
||||
|
||||
#include <thread>
|
||||
#include <ranges>
|
||||
#include <ios>
|
||||
#include <ostream>
|
||||
#include <ranges>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -151,8 +151,7 @@ Journal::JsonLogAttributes::setModuleName(std::string const& name)
|
||||
contextValues_.AddMember(
|
||||
rapidjson::StringRef("Module"),
|
||||
rapidjson::Value{name.c_str(), allocator_},
|
||||
allocator_
|
||||
);
|
||||
allocator_);
|
||||
}
|
||||
|
||||
Journal::JsonLogAttributes
|
||||
@@ -166,7 +165,7 @@ Journal::JsonLogAttributes::combine(
|
||||
|
||||
for (auto& member : b.GetObject())
|
||||
{
|
||||
auto val = rapidjson::Value{ member.value, result.allocator_ };
|
||||
auto val = rapidjson::Value{member.value, result.allocator_};
|
||||
if (result.contextValues_.HasMember(member.name))
|
||||
{
|
||||
result.contextValues_[member.name] = std::move(val);
|
||||
@@ -206,7 +205,8 @@ Journal::formatLog(
|
||||
|
||||
if (globalLogAttributes_)
|
||||
{
|
||||
for (auto const& [key, value] : globalLogAttributes_->contextValues().GetObject())
|
||||
for (auto const& [key, value] :
|
||||
globalLogAttributes_->contextValues().GetObject())
|
||||
{
|
||||
rapidjson::Value jsonValue;
|
||||
jsonValue.CopyFrom(value, currentJsonLogContext_.allocator);
|
||||
|
||||
@@ -178,7 +178,6 @@ public:
|
||||
void
|
||||
test_yield_and_stop()
|
||||
{
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace jtx;
|
||||
|
||||
@@ -230,7 +229,10 @@ public:
|
||||
try
|
||||
{
|
||||
th.join();
|
||||
} catch (const std::exception& e) {}
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
}
|
||||
pass();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include <xrpl/basics/Log.h>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
#include <doctest/doctest.h>
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
using namespace ripple;
|
||||
|
||||
@@ -152,14 +152,16 @@ TEST_CASE("Global attributes")
|
||||
MockLogs logs{logStream, beast::severities::kAll};
|
||||
|
||||
beast::Journal::enableStructuredJournal();
|
||||
beast::Journal::addGlobalAttributes(log::attributes(log::attr("Field1", "Value1")));
|
||||
beast::Journal::addGlobalAttributes(
|
||||
log::attributes(log::attr("Field1", "Value1")));
|
||||
|
||||
logs.journal("Test").debug() << "Test";
|
||||
|
||||
rapidjson::Document jsonLog;
|
||||
jsonLog.Parse(logStream.str().c_str());
|
||||
|
||||
CHECK(jsonLog.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
jsonLog.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(jsonLog.IsObject());
|
||||
CHECK(jsonLog.HasMember("Field1"));
|
||||
@@ -175,18 +177,21 @@ TEST_CASE("Global attributes inheritable")
|
||||
MockLogs logs{logStream, beast::severities::kAll};
|
||||
|
||||
beast::Journal::enableStructuredJournal();
|
||||
beast::Journal::addGlobalAttributes(log::attributes(log::attr("Field1", "Value1")));
|
||||
beast::Journal::addGlobalAttributes(
|
||||
log::attributes(log::attr("Field1", "Value1")));
|
||||
|
||||
logs.journal(
|
||||
"Test",
|
||||
log::attributes(log::attr("Field1", "Value3"), log::attr("Field2", "Value2")))
|
||||
log::attributes(
|
||||
log::attr("Field1", "Value3"), log::attr("Field2", "Value2")))
|
||||
.debug()
|
||||
<< "Test";
|
||||
|
||||
rapidjson::Document jsonLog;
|
||||
jsonLog.Parse(logStream.str().c_str());
|
||||
|
||||
CHECK(jsonLog.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
jsonLog.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(jsonLog.IsObject());
|
||||
CHECK(jsonLog.HasMember("Field1"));
|
||||
@@ -265,7 +270,8 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogFields")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(logValue.IsObject());
|
||||
CHECK(logValue.HasMember("Function"));
|
||||
@@ -294,7 +300,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() ==
|
||||
rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue["Level"].GetString() ==
|
||||
@@ -308,8 +316,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue.GetParseError() ==
|
||||
rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue["Level"].GetString() ==
|
||||
@@ -323,8 +332,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue.GetParseError() ==
|
||||
rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue["Level"].GetString() ==
|
||||
@@ -338,8 +348,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue.GetParseError() ==
|
||||
rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue["Level"].GetString() ==
|
||||
@@ -353,8 +364,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue.GetParseError() ==
|
||||
rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue["Level"].GetString() ==
|
||||
@@ -368,7 +380,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() ==
|
||||
rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue["Level"].GetString() ==
|
||||
@@ -383,7 +397,8 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogStream")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue["Level"].GetString() ==
|
||||
@@ -400,7 +415,8 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogParams")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(logValue["Params"].IsObject());
|
||||
CHECK(logValue["Params"]["Field1"].IsNumber());
|
||||
@@ -409,9 +425,13 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogParams")
|
||||
// NOTE: We should expect it to be an int64 after we make the json library
|
||||
// support in64 and uint64
|
||||
CHECK(logValue["Params"]["Field2"].IsNumber());
|
||||
CHECK(logValue["Params"]["Field2"].GetUint64() == std::numeric_limits<std::uint64_t>::max());
|
||||
CHECK(
|
||||
logValue["Params"]["Field2"].GetUint64() ==
|
||||
std::numeric_limits<std::uint64_t>::max());
|
||||
CHECK(logValue["Message"].IsString());
|
||||
CHECK(logValue["Message"].GetString() == std::string{"Test: 1, 18446744073709551615"});
|
||||
CHECK(
|
||||
logValue["Message"].GetString() ==
|
||||
std::string{"Test: 1, 18446744073709551615"});
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogFields")
|
||||
@@ -424,8 +444,8 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogFields")
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(logValue["Params"].IsObject());
|
||||
CHECK(logValue["Params"]["Field1"].IsNumber());
|
||||
@@ -434,7 +454,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogFields")
|
||||
// NOTE: We should expect it to be an int64 after we make the json library
|
||||
// support in64 and uint64
|
||||
CHECK(logValue["Params"]["Field2"].IsNumber());
|
||||
CHECK(logValue["Params"]["Field2"].GetUint64() == std::numeric_limits<std::uint64_t>::max());
|
||||
CHECK(
|
||||
logValue["Params"]["Field2"].GetUint64() ==
|
||||
std::numeric_limits<std::uint64_t>::max());
|
||||
CHECK(logValue["Message"].IsString());
|
||||
CHECK(logValue["Message"].GetString() == std::string{"Test"});
|
||||
}
|
||||
@@ -442,14 +464,16 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogFields")
|
||||
TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJournalAttributes")
|
||||
{
|
||||
beast::Journal j{
|
||||
journal(), log::attributes(log::attr("Field1", "Value1"), log::attr("Field2", 2))};
|
||||
journal(),
|
||||
log::attributes(log::attr("Field1", "Value1"), log::attr("Field2", 2))};
|
||||
|
||||
j.debug() << "Test";
|
||||
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(logValue["Field1"].IsString());
|
||||
CHECK(logValue["Field1"].GetString() == std::string{"Value1"});
|
||||
@@ -460,16 +484,19 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJournalAttributes")
|
||||
TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJournalAttributesInheritable")
|
||||
{
|
||||
beast::Journal j{
|
||||
journal(), log::attributes(log::attr("Field1", "Value1"), log::attr("Field2", 2))};
|
||||
journal(),
|
||||
log::attributes(log::attr("Field1", "Value1"), log::attr("Field2", 2))};
|
||||
beast::Journal j2{
|
||||
j, log::attributes(log::attr("Field3", "Value3"), log::attr("Field2", 0))};
|
||||
j,
|
||||
log::attributes(log::attr("Field3", "Value3"), log::attr("Field2", 0))};
|
||||
|
||||
j2.debug() << "Test";
|
||||
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(logValue["Field1"].IsString());
|
||||
CHECK(logValue["Field1"].GetString() == std::string{"Value1"});
|
||||
@@ -488,14 +515,16 @@ TEST_CASE_FIXTURE(
|
||||
journal(),
|
||||
log::attributes(log::attr("Field1", "Value1"), log::attr("Field2", 2))};
|
||||
beast::Journal j2{
|
||||
j, log::attributes(log::attr("Field3", "Value3"), log::attr("Field2", 0))};
|
||||
j,
|
||||
log::attributes(log::attr("Field3", "Value3"), log::attr("Field2", 0))};
|
||||
|
||||
j2.debug() << "Test";
|
||||
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(logValue["Field1"].IsString());
|
||||
CHECK(logValue["Field1"].GetString() == std::string{"Value1"});
|
||||
@@ -523,7 +552,8 @@ TEST_CASE_FIXTURE(
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(logValue["Field1"].IsString());
|
||||
CHECK(logValue["Field1"].GetString() == std::string{"Value1"});
|
||||
@@ -548,7 +578,8 @@ TEST_CASE_FIXTURE(
|
||||
rapidjson::Document logValue;
|
||||
logValue.Parse(stream().str().c_str());
|
||||
|
||||
CHECK(logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
CHECK(
|
||||
logValue.GetParseError() == rapidjson::ParseErrorCode::kParseErrorNone);
|
||||
|
||||
CHECK(logValue["Field1"].IsString());
|
||||
CHECK(logValue["Field1"].GetString() == std::string{"Value1"});
|
||||
|
||||
@@ -1109,7 +1109,10 @@ RclConsensusLogger::RclConsensusLogger(
|
||||
bool const validating,
|
||||
beast::Journal j,
|
||||
std::source_location location)
|
||||
: j_(j, log::attributes(log::attr("Role", "ConsensusLogger"), log::attr("Label", label)))
|
||||
: j_(j,
|
||||
log::attributes(
|
||||
log::attr("Role", "ConsensusLogger"),
|
||||
log::attr("Label", label)))
|
||||
, location_(location)
|
||||
{
|
||||
if (!validating && !j.info())
|
||||
|
||||
@@ -1260,7 +1260,8 @@ NetworkOPsImp::preProcessTransaction(std::shared_ptr<Transaction>& transaction)
|
||||
{
|
||||
beast::Journal journal{
|
||||
m_journal,
|
||||
log::attributes(log::attr("TransactionID", to_string(transaction->getID())))};
|
||||
log::attributes(
|
||||
log::attr("TransactionID", to_string(transaction->getID())))};
|
||||
auto const newFlags = app_.getHashRouter().getFlags(transaction->getID());
|
||||
|
||||
if ((newFlags & HashRouterFlags::BAD) != HashRouterFlags::UNDEFINED)
|
||||
|
||||
@@ -211,8 +211,7 @@ Transactor::Transactor(ApplyContext& ctx)
|
||||
, j_(ctx.journal,
|
||||
log::attributes(
|
||||
log::attr("TransactionID", to_string(ctx_.tx.getTransactionID())),
|
||||
log::attr("AccountID", to_string(account_))
|
||||
))
|
||||
log::attr("AccountID", to_string(account_))))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,7 @@ public:
|
||||
, j(j_,
|
||||
log::attributes(
|
||||
log::attr("TransactionID", to_string(tx.getTransactionID())),
|
||||
log::attr("AccountID", to_string(tx.getAccountID(sfAccount)))
|
||||
))
|
||||
log::attr("AccountID", to_string(tx.getAccountID(sfAccount)))))
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
(flags_ & tapBATCH) == tapBATCH, "Batch apply flag should be set");
|
||||
@@ -107,8 +106,7 @@ public:
|
||||
, j(j_,
|
||||
log::attributes(
|
||||
log::attr("TransactionID", to_string(tx.getTransactionID())),
|
||||
log::attr("AccountID", to_string(tx.getAccountID(sfAccount)))
|
||||
))
|
||||
log::attr("AccountID", to_string(tx.getAccountID(sfAccount)))))
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
parentBatchId.has_value() == ((flags_ & tapBATCH) == tapBATCH),
|
||||
|
||||
@@ -101,7 +101,8 @@ JobQueue::Coro::resume()
|
||||
|
||||
XRPL_ASSERT(
|
||||
jq_.nSuspend_ > 0,
|
||||
"ripple::JobQueue::Coro::resume jq_.nSuspend_ should be greater than 0");
|
||||
"ripple::JobQueue::Coro::resume jq_.nSuspend_ should be greater "
|
||||
"than 0");
|
||||
--jq_.nSuspend_;
|
||||
}
|
||||
auto saved = detail::getLocalValues().release();
|
||||
@@ -141,7 +142,8 @@ JobQueue::Coro::expectEarlyExit()
|
||||
|
||||
XRPL_ASSERT(
|
||||
jq_.nSuspend_ > 0,
|
||||
"ripple::JobQueue::Coro::expectEarlyExit() jq_.nSuspend_ should be greater than 0");
|
||||
"ripple::JobQueue::Coro::expectEarlyExit() jq_.nSuspend_ should be "
|
||||
"greater than 0");
|
||||
--jq_.nSuspend_;
|
||||
#ifndef NDEBUG
|
||||
finished_ = true;
|
||||
|
||||
@@ -305,8 +305,9 @@ JobQueue::stop()
|
||||
// `Job::doJob` and the return of `JobQueue::processTask`. That is why
|
||||
// we must wait on the condition variable to make these assertions.
|
||||
std::unique_lock lock(m_mutex);
|
||||
cv_.wait(
|
||||
lock, [this] { return m_processCount == 0 && nSuspend_ == 0 && m_jobSet.empty(); });
|
||||
cv_.wait(lock, [this] {
|
||||
return m_processCount == 0 && nSuspend_ == 0 && m_jobSet.empty();
|
||||
});
|
||||
XRPL_ASSERT(
|
||||
m_processCount == 0,
|
||||
"ripple::JobQueue::stop : all processes completed");
|
||||
|
||||
@@ -165,7 +165,8 @@ OverlayImpl::onHandoff(
|
||||
endpoint_type remote_endpoint)
|
||||
{
|
||||
auto const id = next_id_++;
|
||||
auto journal = app_.journal("Peer", log::attributes(log::attr("NodeID", id)));
|
||||
auto journal =
|
||||
app_.journal("Peer", log::attributes(log::attr("NodeID", id)));
|
||||
|
||||
Handoff handoff;
|
||||
if (processRequest(request, handoff))
|
||||
|
||||
@@ -81,14 +81,18 @@ PeerImp::PeerImp(
|
||||
app_.journal("Peer"),
|
||||
log::attributes(
|
||||
log::attr("NodeID", id),
|
||||
log::attr("RemoteAddress", to_string(slot->remote_endpoint())),
|
||||
log::attr("PublicKey", toBase58(TokenType::NodePublic, publicKey))))
|
||||
log::attr("RemoteAddress", to_string(slot->remote_endpoint())),
|
||||
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("RemoteAddress", to_string(slot->remote_endpoint())),
|
||||
log::attr(
|
||||
"PublicKey",
|
||||
toBase58(TokenType::NodePublic, publicKey))))
|
||||
, stream_ptr_(std::move(stream_ptr))
|
||||
, socket_(stream_ptr_->next_layer().socket())
|
||||
, stream_(*stream_ptr_)
|
||||
@@ -1305,8 +1309,7 @@ PeerImp::handleTransaction(
|
||||
p_journal_,
|
||||
log::attributes(
|
||||
log::attr("TransactionID", to_string(txID)),
|
||||
log::attr("RawTransaction", strHex(m->rawtransaction()))
|
||||
)};
|
||||
log::attr("RawTransaction", strHex(m->rawtransaction())))};
|
||||
|
||||
// Charge strongly for attempting to relay a txn with tfInnerBatchTxn
|
||||
// LCOV_EXCL_START
|
||||
|
||||
@@ -661,14 +661,18 @@ PeerImp::PeerImp(
|
||||
app_.journal("Peer"),
|
||||
log::attributes(
|
||||
log::attr("NodeID", id),
|
||||
log::attr("RemoteAddress", to_string(slot->remote_endpoint())),
|
||||
log::attr("PublicKey", toBase58(TokenType::NodePublic, publicKey))))
|
||||
log::attr("RemoteAddress", to_string(slot->remote_endpoint())),
|
||||
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("RemoteAddress", to_string(slot->remote_endpoint())),
|
||||
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