aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/logger/init_context/config.cpp
blob: 30efa13333d187f20321df9899f33aff33015b17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}