Skip to content

Commit 9d893e1

Browse files
committed
Support structured logs
Signed-off-by: JCW <[email protected]>
1 parent f847e32 commit 9d893e1

File tree

35 files changed

+1938
-197
lines changed

35 files changed

+1938
-197
lines changed

cmake/RippledCore.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ target_link_libraries(xrpl.libxrpl.basics PUBLIC xrpl.libxrpl.beast)
8585
add_module(xrpl json)
8686
target_link_libraries(xrpl.libxrpl.json PUBLIC xrpl.libxrpl.basics)
8787

88+
add_module(xrpl telemetry)
89+
target_link_libraries(xrpl.libxrpl.telemetry PUBLIC xrpl.libxrpl.json)
90+
8891
add_module(xrpl crypto)
89-
target_link_libraries(xrpl.libxrpl.crypto PUBLIC xrpl.libxrpl.basics)
92+
target_link_libraries(xrpl.libxrpl.crypto PUBLIC
93+
xrpl.libxrpl.basics
94+
xrpl.libxrpl.telemetry
95+
)
9096

9197
# Level 04
9298
add_module(xrpl protocol)
@@ -127,6 +133,7 @@ target_link_modules(xrpl PUBLIC
127133
beast
128134
crypto
129135
json
136+
telemetry
130137
protocol
131138
resource
132139
server

cmake/RippledInstall.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ install (
1616
xrpl.libxrpl.beast
1717
xrpl.libxrpl.crypto
1818
xrpl.libxrpl.json
19+
xrpl.libxrpl.telemetry
1920
xrpl.libxrpl.protocol
2021
xrpl.libxrpl.resource
2122
xrpl.libxrpl.server

include/xrpl/basics/Log.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class Logs
167167
beast::severities::Severity thresh_;
168168
File file_;
169169
bool silent_ = false;
170+
static std::unique_ptr<beast::Journal::StructuredLogAttributes>
171+
globalLogAttributes_;
170172

171173
public:
172174
Logs(beast::severities::Severity level);
@@ -187,7 +189,10 @@ class Logs
187189
operator[](std::string const& name);
188190

189191
beast::Journal
190-
journal(std::string const& name);
192+
journal(
193+
std::string const& name,
194+
std::unique_ptr<beast::Journal::StructuredLogAttributes> attributes =
195+
{});
191196

192197
beast::severities::Severity
193198
threshold() const;
@@ -224,6 +229,20 @@ class Logs
224229
std::string const& partition,
225230
beast::severities::Severity startingLevel);
226231

232+
static void
233+
setGlobalAttributes(std::unique_ptr<beast::Journal::StructuredLogAttributes>
234+
globalLogAttributes)
235+
{
236+
if (!globalLogAttributes_)
237+
{
238+
globalLogAttributes_ = std::move(globalLogAttributes);
239+
}
240+
else
241+
{
242+
globalLogAttributes_->combine(std::move(globalLogAttributes_));
243+
}
244+
}
245+
227246
public:
228247
static LogSeverity
229248
fromSeverity(beast::severities::Severity level);

0 commit comments

Comments
 (0)