logger_init.cpp 765 B

1234567891011121314151617181920212223242526272829303132
  1. #include "logger_init.h"
  2. #include <yql/essentials/utils/log/log.h>
  3. #include <atomic>
  4. namespace NYql {
  5. namespace NPureCalc {
  6. namespace {
  7. std::atomic_bool Initialized;
  8. }
  9. void InitLogging(const TLoggingOptions& options) {
  10. NLog::InitLogger(options.LogDestination);
  11. auto& logger = NLog::YqlLogger();
  12. logger.SetDefaultPriority(options.LogLevel_);
  13. for (int i = 0; i < NLog::EComponentHelpers::ToInt(NLog::EComponent::MaxValue); ++i) {
  14. logger.SetComponentLevel((NLog::EComponent) i, (NLog::ELevel) options.LogLevel_);
  15. }
  16. Initialized = true;
  17. }
  18. void EnsureLoggingInitialized() {
  19. if (Initialized.load()) {
  20. return;
  21. }
  22. InitLogging(TLoggingOptions());
  23. }
  24. }
  25. }