diff --git a/src/KDSpdSetup/kdspdsetup.cpp b/src/KDSpdSetup/kdspdsetup.cpp index c0fa19e..bf5f5bb 100644 --- a/src/KDSpdSetup/kdspdsetup.cpp +++ b/src/KDSpdSetup/kdspdsetup.cpp @@ -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); } diff --git a/src/KDSpdSetup/setup.cpp b/src/KDSpdSetup/setup.cpp index 605c2b2..dff33a1 100644 --- a/src/KDSpdSetup/setup.cpp +++ b/src/KDSpdSetup/setup.cpp @@ -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); @@ -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)); }