summaryrefslogtreecommitdiffstats
path: root/library/cpp/logger/init_context/config.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/logger/init_context/config.cpp
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/logger/init_context/config.cpp')
-rw-r--r--library/cpp/logger/init_context/config.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/library/cpp/logger/init_context/config.cpp b/library/cpp/logger/init_context/config.cpp
new file mode 100644
index 00000000000..30efa13333d
--- /dev/null
+++ b/library/cpp/logger/init_context/config.cpp
@@ -0,0 +1,26 @@
+#include "config.h"
+
+TLogBackendCreatorInitContextConfig::TLogBackendCreatorInitContextConfig(const NConfig::TConfig& config)
+ : Config(config)
+{}
+
+bool TLogBackendCreatorInitContextConfig::GetValue(TStringBuf name, TString& var) const {
+ if (Config.Has(name)) {
+ var = Config[name].Get<TString>();
+ return true;
+ }
+ return false;
+}
+
+TVector<THolder<ILogBackendCreator::IInitContext>> TLogBackendCreatorInitContextConfig::GetChildren(TStringBuf name) const {
+ TVector<THolder<IInitContext>> result;
+ const NConfig::TConfig& child = Config[name];
+ if (child.IsA<NConfig::TArray>()) {
+ for (const auto& i: child.Get<NConfig::TArray>()) {
+ result.emplace_back(MakeHolder<TLogBackendCreatorInitContextConfig>(i));
+ }
+ } else if (!child.IsNull()) {
+ result.emplace_back(MakeHolder<TLogBackendCreatorInitContextConfig>(child));
+ }
+ return result;
+}