Просмотр исходного кода

Restoring authorship annotation for <varvar4ik@yandex-team.ru>. Commit 2 of 2.

varvar4ik 3 лет назад
Родитель
Сommit
c1fc120577

+ 12 - 12
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.";

+ 7 - 7
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;
 };

+ 12 - 12
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();
 }

+ 1 - 1
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;
 

+ 20 - 20
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;
 

+ 8 - 8
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);
 }

+ 1 - 1
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.