mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 05:25:55 +00:00
Fix issues
This commit is contained in:
@@ -584,6 +584,13 @@ public:
|
|||||||
}
|
}
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
static void
|
||||||
|
resetGlobalAttributes()
|
||||||
|
{
|
||||||
|
std::lock_guard lock(globalLogAttributesMutex_);
|
||||||
|
globalLogAttributes_ = std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
addGlobalAttributes(JsonLogAttributes globalLogAttributes)
|
addGlobalAttributes(JsonLogAttributes globalLogAttributes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -203,34 +203,6 @@ Journal::formatLog(
|
|||||||
rapidjson::Value logContext;
|
rapidjson::Value logContext;
|
||||||
logContext.SetObject();
|
logContext.SetObject();
|
||||||
|
|
||||||
if (globalLogAttributes_)
|
|
||||||
{
|
|
||||||
for (auto const& [key, value] :
|
|
||||||
globalLogAttributes_->contextValues().GetObject())
|
|
||||||
{
|
|
||||||
rapidjson::Value jsonValue;
|
|
||||||
jsonValue.CopyFrom(value, currentJsonLogContext_.allocator);
|
|
||||||
|
|
||||||
logContext.AddMember(
|
|
||||||
rapidjson::Value{key, currentJsonLogContext_.allocator},
|
|
||||||
std::move(jsonValue),
|
|
||||||
currentJsonLogContext_.allocator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attributes.has_value())
|
|
||||||
{
|
|
||||||
for (auto const& [key, value] : attributes->contextValues().GetObject())
|
|
||||||
{
|
|
||||||
rapidjson::Value jsonValue;
|
|
||||||
jsonValue.CopyFrom(value, currentJsonLogContext_.allocator);
|
|
||||||
|
|
||||||
logContext.AddMember(
|
|
||||||
rapidjson::Value{key, currentJsonLogContext_.allocator},
|
|
||||||
std::move(jsonValue),
|
|
||||||
currentJsonLogContext_.allocator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logContext.AddMember(
|
logContext.AddMember(
|
||||||
rapidjson::StringRef("Function"),
|
rapidjson::StringRef("Function"),
|
||||||
rapidjson::StringRef(currentJsonLogContext_.location.function_name()),
|
rapidjson::StringRef(currentJsonLogContext_.location.function_name()),
|
||||||
@@ -274,6 +246,39 @@ Journal::formatLog(
|
|||||||
.count(),
|
.count(),
|
||||||
currentJsonLogContext_.allocator);
|
currentJsonLogContext_.allocator);
|
||||||
|
|
||||||
|
if (attributes.has_value())
|
||||||
|
{
|
||||||
|
for (auto const& [key, value] : attributes->contextValues().GetObject())
|
||||||
|
{
|
||||||
|
if (logContext.HasMember(key))
|
||||||
|
continue;
|
||||||
|
rapidjson::Value jsonValue;
|
||||||
|
jsonValue.CopyFrom(value, currentJsonLogContext_.allocator);
|
||||||
|
|
||||||
|
logContext.AddMember(
|
||||||
|
rapidjson::Value{key, currentJsonLogContext_.allocator},
|
||||||
|
std::move(jsonValue),
|
||||||
|
currentJsonLogContext_.allocator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (globalLogAttributes_)
|
||||||
|
{
|
||||||
|
for (auto const& [key, value] :
|
||||||
|
globalLogAttributes_->contextValues().GetObject())
|
||||||
|
{
|
||||||
|
if (logContext.HasMember(key))
|
||||||
|
continue;
|
||||||
|
rapidjson::Value jsonValue;
|
||||||
|
jsonValue.CopyFrom(value, currentJsonLogContext_.allocator);
|
||||||
|
|
||||||
|
logContext.AddMember(
|
||||||
|
rapidjson::Value{key, currentJsonLogContext_.allocator},
|
||||||
|
std::move(jsonValue),
|
||||||
|
currentJsonLogContext_.allocator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
rapidjson::Writer writer(buffer);
|
rapidjson::Writer writer(buffer);
|
||||||
|
|
||||||
@@ -292,6 +297,7 @@ void
|
|||||||
Journal::disableStructuredJournal()
|
Journal::disableStructuredJournal()
|
||||||
{
|
{
|
||||||
m_jsonLogsEnabled = false;
|
m_jsonLogsEnabled = false;
|
||||||
|
resetGlobalAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
Reference in New Issue
Block a user