Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
JCW
2025-08-29 22:31:43 +01:00
parent 59b5a1a26c
commit 7cec53e248
2 changed files with 8 additions and 20 deletions

View File

@@ -147,8 +147,8 @@ public:
void
setModuleName(std::string const& name);
[[nodiscard]] static JsonLogAttributes
combine(AttributeFields const& a, AttributeFields const& b);
void
combine(AttributeFields const& from);
AttributeFields&
contextValues()
@@ -461,9 +461,7 @@ public:
if (other.m_attributes.has_value())
{
if (m_attributes.has_value())
m_attributes = JsonLogAttributes::combine(
other.m_attributes->contextValues_,
m_attributes->contextValues_);
m_attributes->combine(other.m_attributes->contextValues_);
else
m_attributes = other.m_attributes;
}
@@ -591,9 +589,7 @@ public:
{
globalLogAttributes_ = JsonLogAttributes{};
}
globalLogAttributes_ = JsonLogAttributes::combine(
globalLogAttributes_->contextValues(),
globalLogAttributes.contextValues());
globalLogAttributes_->combine(globalLogAttributes.contextValues());
}
};

View File

@@ -164,21 +164,13 @@ Journal::JsonLogAttributes::setModuleName(std::string const& name)
contextValues_.as_object()["Module"] = name;
}
Journal::JsonLogAttributes
Journal::JsonLogAttributes::combine(
AttributeFields const& a,
AttributeFields const& b)
void
Journal::JsonLogAttributes::combine(AttributeFields const& from)
{
JsonLogAttributes result;
result.contextValues_ = a;
for (auto& [key, value] : b.as_object())
for (auto& [key, value] : from.as_object())
{
result.contextValues_.as_object()[key] = value;
contextValues_.as_object()[key] = value;
}
return result;
}
void