Skip to content

Commit 49f9832

Browse files
Tommy MeiselThomsonTan
authored andcommitted
merge given config into static log configuration
1 parent 80f0a79 commit 49f9832

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

lib/api/LogConfiguration.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,13 @@ namespace MAT_NS_BEGIN {
6868
return result;
6969
}
7070

71-
ILogConfiguration FromJSON(const char* configuration)
71+
void MergeFromJSON(ILogConfiguration &config, const char* configuration)
7272
{
73-
ILogConfiguration result;
7473
#ifdef HAVE_MAT_JSONHPP
75-
auto src = json::parse(configuration);
76-
std::function<void(json &src, VariantMap &dst)> parse;
77-
parse = [&parse](json &src, VariantMap &dst)->void {
78-
for (json::iterator it = src.begin(); it != src.end(); ++it) {
74+
auto jsonRoot = json::parse(configuration);
75+
std::function<void(json &node, VariantMap &dst)> parse;
76+
parse = [&parse](json &node, VariantMap &dst)->void {
77+
for (json::iterator it = node.begin(); it != node.end(); ++it) {
7978
auto t = it.value().type();
8079
switch (t)
8180
{
@@ -119,11 +118,17 @@ namespace MAT_NS_BEGIN {
119118
}
120119
}
121120
};
122-
parse(src, *result);
121+
parse(jsonRoot, *config);
123122
#else
124123
(void)(configuration);
125124
assert(false /* json.hpp support is not enabled! */);
126125
#endif
126+
}
127+
128+
ILogConfiguration FromJSON(const char* configuration)
129+
{
130+
ILogConfiguration result;
131+
MergeFromJSON(result, configuration);
127132
return result;
128133
}
129134

lib/include/public/LogConfiguration.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ namespace MAT_NS_BEGIN {
106106

107107
MATSDK_LIBABI ILogConfiguration FromJSON(const char* json);
108108

109+
MATSDK_LIBABI void MergeFromJSON(ILogConfiguration &config, const char* json);
110+
109111
} MAT_NS_END
110112

111113
#endif

wrappers/obj-c/ODWLogManager.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ +(nullable ILogger *)initializeLogManager:(nonnull NSString *)tenantToken withCo
135135
if (jsonData)
136136
{
137137
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
138-
logManagerConfig = MAT::FromJSON([jsonString UTF8String]);
138+
MAT::MergeFromJSON(logManagerConfig, [jsonString UTF8String]);
139139
}
140140
else
141141
{

0 commit comments

Comments
 (0)