mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Log size optimise
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
@@ -324,6 +324,7 @@ public:
|
||||
{
|
||||
std::string buffer_;
|
||||
detail::SimpleJsonWriter messageParamsWriter_;
|
||||
bool hasMessageParams_ = false;
|
||||
|
||||
public:
|
||||
JsonLogContext() : messageParamsWriter_(buffer_)
|
||||
@@ -331,6 +332,26 @@ public:
|
||||
buffer_.reserve(1024 * 5);
|
||||
}
|
||||
|
||||
void
|
||||
startMessageParams()
|
||||
{
|
||||
if (!hasMessageParams_)
|
||||
{
|
||||
writer().writeKey("Data");
|
||||
writer().startObject();
|
||||
hasMessageParams_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
endMessageParams()
|
||||
{
|
||||
if (hasMessageParams_)
|
||||
{
|
||||
writer().endObject();
|
||||
}
|
||||
}
|
||||
|
||||
detail::SimpleJsonWriter&
|
||||
writer()
|
||||
{
|
||||
@@ -1014,6 +1035,7 @@ operator<<(std::ostream& os, LogParameter<T> const& param)
|
||||
os << param.value_;
|
||||
return os;
|
||||
}
|
||||
beast::Journal::currentJsonLogContext_.startMessageParams();
|
||||
detail::setJsonValue(
|
||||
beast::Journal::currentJsonLogContext_.writer(),
|
||||
param.name_,
|
||||
@@ -1028,6 +1050,7 @@ operator<<(std::ostream& os, LogField<T> const& param)
|
||||
{
|
||||
if (!beast::Journal::m_jsonLogsEnabled)
|
||||
return os;
|
||||
beast::Journal::currentJsonLogContext_.startMessageParams();
|
||||
detail::setJsonValue(
|
||||
beast::Journal::currentJsonLogContext_.writer(),
|
||||
param.name_,
|
||||
|
||||
Reference in New Issue
Block a user