global.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "global.h"
  2. static void DoInitGlobalLog(THolder<TGlobalLog> logger, THolder<ILoggerFormatter> formatter) {
  3. TLoggerOperator<TGlobalLog>::Set(logger.Release());
  4. if (!formatter) {
  5. formatter.Reset(CreateRtyLoggerFormatter());
  6. }
  7. TLoggerFormatterOperator::Set(formatter.Release());
  8. }
  9. void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter, bool threaded) {
  10. DoInitGlobalLog(
  11. MakeHolder<TGlobalLog>(
  12. CreateLogBackend(
  13. NLoggingImpl::PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon),
  14. (ELogPriority)logLevel,
  15. threaded)),
  16. std::move(formatter));
  17. }
  18. void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter) {
  19. DoInitGlobalLog(THolder(new TGlobalLog(std::move(backend))), std::move(formatter));
  20. }
  21. bool GlobalLogInitialized() {
  22. return TLoggerOperator<TGlobalLog>::Usage();
  23. }
  24. template <>
  25. TGlobalLog* CreateDefaultLogger<TGlobalLog>() {
  26. return new TGlobalLog("console", TLOG_INFO);
  27. }
  28. template <>
  29. TNullLog* CreateDefaultLogger<TNullLog>() {
  30. return new TNullLog("null");
  31. }
  32. NPrivateGlobalLogger::TVerifyEvent::~TVerifyEvent() {
  33. const TString info = Str();
  34. FATAL_LOG << info << Endl;
  35. Y_ABORT("%s", info.data());
  36. }