diff options
author | ivanmorozov <ivanmorozov@yandex-team.ru> | 2022-02-10 16:47:33 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:33 +0300 |
commit | cba5d9a444e2cfe105f55ccda66cd21d50440017 (patch) | |
tree | 79983e83d1a91aebeb1999338090eec69e24cc33 /library/cpp/logger/backend.cpp | |
parent | eb540cc7a103419462d0cc870ca403966e2194c6 (diff) | |
download | ydb-cba5d9a444e2cfe105f55ccda66cd21d50440017.tar.gz |
Restoring authorship annotation for <ivanmorozov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/logger/backend.cpp')
-rw-r--r-- | library/cpp/logger/backend.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/library/cpp/logger/backend.cpp b/library/cpp/logger/backend.cpp index b26bf5e88c..e0ea81471d 100644 --- a/library/cpp/logger/backend.cpp +++ b/library/cpp/logger/backend.cpp @@ -1,66 +1,66 @@ #include "backend.h" -#include <util/generic/vector.h> -#include <util/system/mutex.h> -#include <util/generic/singleton.h> +#include <util/generic/vector.h> +#include <util/system/mutex.h> +#include <util/generic/singleton.h> #include <util/generic/yexception.h> -namespace { - class TGlobalLogsStorage { - private: +namespace { + class TGlobalLogsStorage { + private: TVector<TLogBackend*> Backends; - TMutex Mutex; + TMutex Mutex; - public: - void Register(TLogBackend* backend) { - TGuard<TMutex> g(Mutex); - Backends.push_back(backend); - } - - void UnRegister(TLogBackend* backend) { - TGuard<TMutex> g(Mutex); - for (ui32 i = 0; i < Backends.size(); ++i) { - if (Backends[i] == backend) { - Backends.erase(Backends.begin() + i); - return; - } - } + public: + void Register(TLogBackend* backend) { + TGuard<TMutex> g(Mutex); + Backends.push_back(backend); + } + + void UnRegister(TLogBackend* backend) { + TGuard<TMutex> g(Mutex); + for (ui32 i = 0; i < Backends.size(); ++i) { + if (Backends[i] == backend) { + Backends.erase(Backends.begin() + i); + return; + } + } Y_FAIL("Incorrect pointer for log backend"); - } - + } + void Reopen(bool flush) { - TGuard<TMutex> g(Mutex); - for (auto& b : Backends) { + TGuard<TMutex> g(Mutex); + for (auto& b : Backends) { if (flush) { b->ReopenLog(); } else { b->ReopenLogNoFlush(); } - } - } - }; -} - + } + } + }; +} + template <> -class TSingletonTraits<TGlobalLogsStorage> { -public: - static const size_t Priority = 50; -}; - +class TSingletonTraits<TGlobalLogsStorage> { +public: + static const size_t Priority = 50; +}; + ELogPriority TLogBackend::FiltrationLevel() const { - return LOG_MAX_PRIORITY; -} - + return LOG_MAX_PRIORITY; +} + TLogBackend::TLogBackend() noexcept { - Singleton<TGlobalLogsStorage>()->Register(this); + Singleton<TGlobalLogsStorage>()->Register(this); } TLogBackend::~TLogBackend() { - Singleton<TGlobalLogsStorage>()->UnRegister(this); + Singleton<TGlobalLogsStorage>()->UnRegister(this); } - + void TLogBackend::ReopenLogNoFlush() { ReopenLog(); -} +} void TLogBackend::ReopenAllBackends(bool flush) { Singleton<TGlobalLogsStorage>()->Reopen(flush); |