aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/public/purecalc/common/logger_init.cpp
blob: a7da19d9f101053da5dd0f8bba0102e8076fe102 (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
27
28
29
30
31
32
#include "logger_init.h"

#include <yql/essentials/utils/log/log.h>

#include <atomic>

namespace NYql {
namespace NPureCalc {

namespace {
    std::atomic_bool Initialized;
}

    void InitLogging(const TLoggingOptions& options) {
        NLog::InitLogger(options.LogDestination);
        auto& logger = NLog::YqlLogger();
        logger.SetDefaultPriority(options.LogLevel_);
        for (int i = 0; i < NLog::EComponentHelpers::ToInt(NLog::EComponent::MaxValue); ++i) {
            logger.SetComponentLevel((NLog::EComponent) i, (NLog::ELevel) options.LogLevel_);
        }
        Initialized = true;
    }

    void EnsureLoggingInitialized() {
        if (Initialized.load()) {
            return;
        }
        InitLogging(TLoggingOptions());
    }

}
}