Skip to content

Commit

Permalink
Support inline sink patterns
Browse files Browse the repository at this point in the history
Change-Id: I3da32c5b7cc7f00fea29c612b0b5e5a8a2fa5881
  • Loading branch information
mattkdab committed May 24, 2024
1 parent cb731ae commit 9e9ac67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/KDSpdSetup/kdspdsetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void setupFrom(std::string const &file)
{
auto const data = toml::parse(file);

setup::setupSinks(data);
setup::setupPatterns(data);
setup::setupSinks(data);
setup::setupThreadPools(data);
setup::setupLoggers(data);
}
Expand Down
14 changes: 14 additions & 0 deletions src/KDSpdSetup/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ void setupSink(toml::table &&sinkTable)
throw std::out_of_range("KDSPDSetup: sink type "s + typeStr.str + " is not valid"s);

toml::string level = "";
toml::string pattern = "";

if (sinkTable.contains("level")) {
level = sinkTable.at("level").as_string();
}

if (sinkTable.contains("pattern")) {
pattern = sinkTable.at("pattern").as_string();
}

if (details::inTypelist(typeStr, details::fileStrs) || details::inTypelist(typeStr, details::rotateStrs) ||
details::inTypelist(typeStr, details::dailyStrs)) {
handleTruncatableSink(std::move(typeStr), std::move(sinkTable), sinkPtr);
Expand Down Expand Up @@ -93,6 +99,14 @@ void setupSink(toml::table &&sinkTable)
sinkPtr->set_level(details::levelMap.at(level));
}

if (pattern != "") {
if (details::SPDMaps::patternMap().contains(pattern)) {
sinkPtr->set_pattern(details::SPDMaps::patternMap().at(pattern));
} else {
sinkPtr->set_pattern(pattern);
}
}

details::SPDMaps::emplaceSinkMap(std::make_pair(name, sinkPtr));
}

Expand Down

0 comments on commit 9e9ac67

Please sign in to comment.