#include "backend.h" #include #include #include #include namespace { class TGlobalLogsStorage { private: TVector Backends; TMutex Mutex; public: void Register(TLogBackend* backend) { TGuard g(Mutex); Backends.push_back(backend); } void UnRegister(TLogBackend* backend) { TGuard g(Mutex); for (ui32 i = 0; i < Backends.size(); ++i) { if (Backends[i] == backend) { Backends.erase(Backends.begin() + i); return; } } Y_ABORT("Incorrect pointer for log backend"); } void Reopen(bool flush) { TGuard g(Mutex); for (auto& b : Backends) { if (typeid(*b) == typeid(TLogBackend)) { continue; } if (flush) { b->ReopenLog(); } else { b->ReopenLogNoFlush(); } } } }; } template <> class TSingletonTraits { public: static const size_t Priority = 50; }; ELogPriority TLogBackend::FiltrationLevel() const { return LOG_MAX_PRIORITY; } TLogBackend::TLogBackend() noexcept { Singleton()->Register(this); } TLogBackend::~TLogBackend() { Singleton()->UnRegister(this); } void TLogBackend::ReopenLogNoFlush() { ReopenLog(); } void TLogBackend::ReopenAllBackends(bool flush) { Singleton()->Reopen(flush); } size_t TLogBackend::QueueSize() const { ythrow yexception() << "Not implemented."; }