composite_creator.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #include "composite_creator.h"
  2. #include "composite.h"
  3. #include "uninitialized_creator.h"
  4. THolder<TLogBackend> TCompositeBackendCreator::DoCreateLogBackend() const {
  5. auto res = MakeHolder<TCompositeLogBackend>();
  6. for (const auto& child : Children) {
  7. res->AddLogBackend(child->CreateLogBackend());
  8. }
  9. return std::move(res);
  10. }
  11. TCompositeBackendCreator::TCompositeBackendCreator()
  12. : TLogBackendCreatorBase("composite")
  13. {}
  14. bool TCompositeBackendCreator::Init(const IInitContext& ctx) {
  15. for (const auto& child : ctx.GetChildren("SubLogger")) {
  16. Children.emplace_back(MakeHolder<TLogBackendCreatorUninitialized>());
  17. if (!Children.back()->Init(*child)) {
  18. return false;
  19. }
  20. }
  21. return true;
  22. }
  23. ILogBackendCreator::TFactory::TRegistrator<TCompositeBackendCreator> TCompositeBackendCreator::Registrar("composite");
  24. void TCompositeBackendCreator::DoToJson(NJson::TJsonValue& value) const {
  25. for (const auto& child: Children) {
  26. child->ToJson(value["SubLogger"].AppendValue(NJson::JSON_MAP));
  27. }
  28. }