diff options
author | varvar4ik <varvar4ik@yandex-team.ru> | 2022-02-10 16:50:13 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:13 +0300 |
commit | c1fc12057772730209766bc9bd09ed842310b1c8 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/logger | |
parent | f5256e2807bd0fc8626a4ce002a83b9b13860269 (diff) | |
download | ydb-c1fc12057772730209766bc9bd09ed842310b1c8.tar.gz |
Restoring authorship annotation for <varvar4ik@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/logger')
-rw-r--r-- | library/cpp/logger/backend.cpp | 24 | ||||
-rw-r--r-- | library/cpp/logger/backend.h | 14 | ||||
-rw-r--r-- | library/cpp/logger/log.cpp | 24 | ||||
-rw-r--r-- | library/cpp/logger/log.h | 2 | ||||
-rw-r--r-- | library/cpp/logger/log_ut.cpp | 40 | ||||
-rw-r--r-- | library/cpp/logger/thread.cpp | 16 | ||||
-rw-r--r-- | library/cpp/logger/thread.h | 2 |
7 files changed, 61 insertions, 61 deletions
diff --git a/library/cpp/logger/backend.cpp b/library/cpp/logger/backend.cpp index 530f938053..b26bf5e88c 100644 --- a/library/cpp/logger/backend.cpp +++ b/library/cpp/logger/backend.cpp @@ -27,14 +27,14 @@ namespace { Y_FAIL("Incorrect pointer for log backend"); } - void Reopen(bool flush) { + void Reopen(bool flush) { TGuard<TMutex> g(Mutex); for (auto& b : Backends) { - if (flush) { - b->ReopenLog(); - } else { - b->ReopenLogNoFlush(); - } + if (flush) { + b->ReopenLog(); + } else { + b->ReopenLogNoFlush(); + } } } }; @@ -58,13 +58,13 @@ TLogBackend::~TLogBackend() { Singleton<TGlobalLogsStorage>()->UnRegister(this); } -void TLogBackend::ReopenLogNoFlush() { - ReopenLog(); +void TLogBackend::ReopenLogNoFlush() { + ReopenLog(); +} + +void TLogBackend::ReopenAllBackends(bool flush) { + Singleton<TGlobalLogsStorage>()->Reopen(flush); } - -void TLogBackend::ReopenAllBackends(bool flush) { - Singleton<TGlobalLogsStorage>()->Reopen(flush); -} size_t TLogBackend::QueueSize() const { ythrow yexception() << "Not implemented."; diff --git a/library/cpp/logger/backend.h b/library/cpp/logger/backend.h index e530fb2774..d088726d6d 100644 --- a/library/cpp/logger/backend.h +++ b/library/cpp/logger/backend.h @@ -16,15 +16,15 @@ public: virtual void WriteData(const TLogRecord& rec) = 0; virtual void ReopenLog() = 0; - - // Does not guarantee consistency with previous WriteData() calls: - // log entries could be written to the new (reopened) log file due to - // buffering effects. - virtual void ReopenLogNoFlush(); - + + // Does not guarantee consistency with previous WriteData() calls: + // log entries could be written to the new (reopened) log file due to + // buffering effects. + virtual void ReopenLogNoFlush(); + virtual ELogPriority FiltrationLevel() const; - static void ReopenAllBackends(bool flush = true); + static void ReopenAllBackends(bool flush = true); virtual size_t QueueSize() const; }; diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp index 23493158c8..e1d70cc3d2 100644 --- a/library/cpp/logger/log.cpp +++ b/library/cpp/logger/log.cpp @@ -58,14 +58,14 @@ public: Backend_->ReopenLog(); } - inline void ReopenLogNoFlush() { - if (!IsOpen()) { - return; - } - + inline void ReopenLogNoFlush() { + if (!IsOpen()) { + return; + } + Backend_->ReopenLogNoFlush(); - } - + } + inline void AddLog(ELogPriority priority, const char* format, va_list args) const { if (!IsOpen()) { return; @@ -182,12 +182,12 @@ void TLog::ReopenLog() { } } -void TLog::ReopenLogNoFlush() { +void TLog::ReopenLogNoFlush() { if (const auto copy = Impl_) { - copy->ReopenLogNoFlush(); - } -} - + copy->ReopenLogNoFlush(); + } +} + void TLog::CloseLog() { Impl_->CloseLog(); } diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h index 4b29ee69a7..8be984ccc8 100644 --- a/library/cpp/logger/log.h +++ b/library/cpp/logger/log.h @@ -73,7 +73,7 @@ public: // Call `ReopenLog()` of the underlying backend. void ReopenLog(); // Call `ReopenLogNoFlush()` of the underlying backend. - void ReopenLogNoFlush(); + void ReopenLogNoFlush(); // Call `QueueSize()` of the underlying backend. size_t BackEndQueueSize() const; diff --git a/library/cpp/logger/log_ut.cpp b/library/cpp/logger/log_ut.cpp index 7456f7273b..8de46f17f5 100644 --- a/library/cpp/logger/log_ut.cpp +++ b/library/cpp/logger/log_ut.cpp @@ -17,7 +17,7 @@ class TLogTest: public TTestBase { UNIT_TEST(TestWrite) UNIT_TEST(TestThreaded) UNIT_TEST(TestThreadedWithOverflow) - UNIT_TEST(TestNoFlush) + UNIT_TEST(TestNoFlush) UNIT_TEST_SUITE_END(); private: @@ -26,7 +26,7 @@ private: void TestWrite(); void TestThreaded(); void TestThreadedWithOverflow(); - void TestNoFlush(); + void TestNoFlush(); void SetUp() override; void TearDown() override; }; @@ -131,25 +131,25 @@ void TLogTest::TestThreadedWithOverflow() { } } -void TLogTest::TestNoFlush() { - { - TFileLogBackend fb(LOGFILE); +void TLogTest::TestNoFlush() { + { + TFileLogBackend fb(LOGFILE); TLog log(THolder(new TThreadedLogBackend(&fb))); - - int v1 = 12; - unsigned v2 = 34; - double v3 = 3.0; - const char* v4 = "qwqwqw"; - - log.ReopenLogNoFlush(); - log.AddLog("some useful data %d, %u, %lf, %s\n", v1, v2, v3, v4); - } - - TBlob data = TBlob::FromFileSingleThreaded(LOGFILE); - - UNIT_ASSERT_EQUAL(TString((const char*)data.Begin(), data.Size()), "some useful data 12, 34, 3.000000, qwqwqw\n"); -} - + + int v1 = 12; + unsigned v2 = 34; + double v3 = 3.0; + const char* v4 = "qwqwqw"; + + log.ReopenLogNoFlush(); + log.AddLog("some useful data %d, %u, %lf, %s\n", v1, v2, v3, v4); + } + + TBlob data = TBlob::FromFileSingleThreaded(LOGFILE); + + UNIT_ASSERT_EQUAL(TString((const char*)data.Begin(), data.Size()), "some useful data 12, 34, 3.000000, qwqwqw\n"); +} + void TLogTest::TestFormat() { TStringStream data; diff --git a/library/cpp/logger/thread.cpp b/library/cpp/logger/thread.cpp index c581b8910a..0ccf9e374b 100644 --- a/library/cpp/logger/thread.cpp +++ b/library/cpp/logger/thread.cpp @@ -102,10 +102,10 @@ public: reopener->Wait(); } - inline void ReopenLogNoFlush() { - Slave_->ReopenLogNoFlush(); - } - + inline void ReopenLogNoFlush() { + Slave_->ReopenLogNoFlush(); + } + inline size_t QueueSize() const { return Queue_.Size(); } @@ -137,10 +137,10 @@ void TThreadedLogBackend::ReopenLog() { Impl_->ReopenLog(); } -void TThreadedLogBackend::ReopenLogNoFlush() { - Impl_->ReopenLogNoFlush(); -} - +void TThreadedLogBackend::ReopenLogNoFlush() { + Impl_->ReopenLogNoFlush(); +} + void TThreadedLogBackend::WriteEmergencyData(const TLogRecord& rec) { Impl_->WriteEmergencyData(rec); } diff --git a/library/cpp/logger/thread.h b/library/cpp/logger/thread.h index 6a934f4f53..65f7a88e87 100644 --- a/library/cpp/logger/thread.h +++ b/library/cpp/logger/thread.h @@ -14,7 +14,7 @@ public: void WriteData(const TLogRecord& rec) override; void ReopenLog() override; - void ReopenLogNoFlush() override; + void ReopenLogNoFlush() override; size_t QueueSize() const override; // Write an emergency message when the memory allocator is corrupted. |