mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
@@ -387,9 +387,9 @@ Logs::format(
|
||||
beast::severities::Severity severity,
|
||||
std::string const& partition)
|
||||
{
|
||||
output = message;
|
||||
output.reserve(output.size() + partition.size() + 100);
|
||||
output += to_string(std::chrono::system_clock::now());
|
||||
output.reserve(message.size() + partition.size() + 100);
|
||||
|
||||
output = to_string(std::chrono::system_clock::now());
|
||||
|
||||
output += " ";
|
||||
if (!partition.empty())
|
||||
@@ -421,6 +421,7 @@ Logs::format(
|
||||
break;
|
||||
}
|
||||
|
||||
output += message;
|
||||
|
||||
// Limit the maximum length of the output
|
||||
if (output.size() > maximumMessageCharacters)
|
||||
|
||||
@@ -90,8 +90,13 @@ public:
|
||||
bool console)
|
||||
{
|
||||
std::string s;
|
||||
format(s, text, level, partition);
|
||||
logStream_.append(s);
|
||||
std::string_view result = text;
|
||||
if (!beast::Journal::isStructuredJournalEnabled())
|
||||
{
|
||||
format(s, text, level, partition);
|
||||
result = s;
|
||||
}
|
||||
logStream_.append(result);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -120,18 +125,6 @@ TEST_CASE("Test format output")
|
||||
CHECK(output != "Message");
|
||||
}
|
||||
|
||||
TEST_CASE("Test format output when structured logs are enabled")
|
||||
{
|
||||
beast::Journal::enableStructuredJournal();
|
||||
|
||||
std::string output;
|
||||
Logs::format(output, "Message", beast::severities::kDebug, "Test");
|
||||
|
||||
CHECK(output == "Message");
|
||||
|
||||
beast::Journal::disableStructuredJournal();
|
||||
}
|
||||
|
||||
TEST_CASE("Enable json logs")
|
||||
{
|
||||
std::string logStream;
|
||||
|
||||
Reference in New Issue
Block a user