diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/logger/composite_creator.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/logger/composite_creator.cpp')
-rw-r--r-- | library/cpp/logger/composite_creator.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/library/cpp/logger/composite_creator.cpp b/library/cpp/logger/composite_creator.cpp new file mode 100644 index 0000000000..2064265766 --- /dev/null +++ b/library/cpp/logger/composite_creator.cpp @@ -0,0 +1,34 @@ +#include "composite_creator.h" +#include "composite.h" +#include "uninitialized_creator.h" + +THolder<TLogBackend> TCompositeBackendCreator::DoCreateLogBackend() const { + auto res = MakeHolder<TCompositeLogBackend>(); + for (const auto& child : Children) { + res->AddLogBackend(child->CreateLogBackend()); + } + return std::move(res); +} + + +TCompositeBackendCreator::TCompositeBackendCreator() + : TLogBackendCreatorBase("composite") +{} + +bool TCompositeBackendCreator::Init(const IInitContext& ctx) { + for (const auto& child : ctx.GetChildren("SubLogger")) { + Children.emplace_back(MakeHolder<TLogBackendCreatorUninitialized>()); + if (!Children.back()->Init(*child)) { + return false; + } + } + return true; +} + +ILogBackendCreator::TFactory::TRegistrator<TCompositeBackendCreator> TCompositeBackendCreator::Registrar("composite"); + +void TCompositeBackendCreator::DoToJson(NJson::TJsonValue& value) const { + for (const auto& child: Children) { + child->ToJson(value["SubLogger"].AppendValue(NJson::JSON_MAP)); + } +} |