diff options
| author | yazevnul <[email protected]> | 2022-02-10 16:46:46 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:46 +0300 | 
| commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
| tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /library/cpp/logger | |
| parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/logger')
| -rw-r--r-- | library/cpp/logger/backend.cpp | 2 | ||||
| -rw-r--r-- | library/cpp/logger/backend.h | 8 | ||||
| -rw-r--r-- | library/cpp/logger/element.h | 2 | ||||
| -rw-r--r-- | library/cpp/logger/global/common.h | 2 | ||||
| -rw-r--r-- | library/cpp/logger/global/global.h | 4 | ||||
| -rw-r--r-- | library/cpp/logger/global/rty_formater.h | 2 | ||||
| -rw-r--r-- | library/cpp/logger/global/rty_formater_ut.cpp | 10 | ||||
| -rw-r--r-- | library/cpp/logger/log.cpp | 62 | ||||
| -rw-r--r-- | library/cpp/logger/log.h | 122 | ||||
| -rw-r--r-- | library/cpp/logger/stream.cpp | 2 | ||||
| -rw-r--r-- | library/cpp/logger/stream.h | 6 | ||||
| -rw-r--r-- | library/cpp/logger/system.cpp | 8 | ||||
| -rw-r--r-- | library/cpp/logger/ya.make | 8 | 
13 files changed, 119 insertions, 119 deletions
diff --git a/library/cpp/logger/backend.cpp b/library/cpp/logger/backend.cpp index b26bf5e88ce..069c9768ef7 100644 --- a/library/cpp/logger/backend.cpp +++ b/library/cpp/logger/backend.cpp @@ -24,7 +24,7 @@ namespace {                      return;                  }              } -            Y_FAIL("Incorrect pointer for log backend"); +            Y_FAIL("Incorrect pointer for log backend");           }          void Reopen(bool flush) { diff --git a/library/cpp/logger/backend.h b/library/cpp/logger/backend.h index d088726d6d4..36023d048d7 100644 --- a/library/cpp/logger/backend.h +++ b/library/cpp/logger/backend.h @@ -1,14 +1,14 @@  #pragma once -#include "priority.h" - +#include "priority.h"  +   #include <util/generic/noncopyable.h> - +   #include <cstddef>  struct TLogRecord; -// NOTE: be aware that all `TLogBackend`s are registred in singleton. +// NOTE: be aware that all `TLogBackend`s are registred in singleton.   class TLogBackend: public TNonCopyable {  public:      TLogBackend() noexcept; diff --git a/library/cpp/logger/element.h b/library/cpp/logger/element.h index fc9bff851ff..0066270efca 100644 --- a/library/cpp/logger/element.h +++ b/library/cpp/logger/element.h @@ -21,7 +21,7 @@ public:      template <class T>      inline TLogElement& operator<<(const T& t) { -        static_cast<IOutputStream&>(*this) << t; +        static_cast<IOutputStream&>(*this) << t;           return *this;      } diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h index 7dcf650decb..6f06d6ae4c8 100644 --- a/library/cpp/logger/global/common.h +++ b/library/cpp/logger/global/common.h @@ -135,7 +135,7 @@ TSimpleSharedPtr<TLogElement> GetLoggerForce(TLog& log, const TLogRecordContext&  namespace NPrivateGlobalLogger {      struct TEatStream { -        Y_FORCE_INLINE bool operator|(const IOutputStream&) const { +        Y_FORCE_INLINE bool operator|(const IOutputStream&) const {               return true;          }      }; diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h index cbe71b16ea5..6940d06fb79 100644 --- a/library/cpp/logger/global/global.h +++ b/library/cpp/logger/global/global.h @@ -10,7 +10,7 @@ void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rota  void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {});  inline void InitGlobalLog2Null() { -    DoInitGlobalLog("null", TLOG_EMERG, false, false); +    DoInitGlobalLog("null", TLOG_EMERG, false, false);   }  inline void InitGlobalLog2Console(int loglevel = TLOG_INFO) { @@ -91,7 +91,7 @@ namespace NPrivateGlobalLogger {          ~TVerifyEvent();          template <class T>          inline TVerifyEvent& operator<<(const T& t) { -            static_cast<IOutputStream&>(*this) << t; +            static_cast<IOutputStream&>(*this) << t;               return *this;          } diff --git a/library/cpp/logger/global/rty_formater.h b/library/cpp/logger/global/rty_formater.h index 6532e1d7695..3872b22458c 100644 --- a/library/cpp/logger/global/rty_formater.h +++ b/library/cpp/logger/global/rty_formater.h @@ -34,7 +34,7 @@ namespace NLoggingImpl {          TInstant Instant;      }; -    IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS); +    IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS);       inline TLocalTimeS GetLocalTimeS() {          return TLocalTimeS(); diff --git a/library/cpp/logger/global/rty_formater_ut.cpp b/library/cpp/logger/global/rty_formater_ut.cpp index 551a97c5bfe..59376b5c3c8 100644 --- a/library/cpp/logger/global/rty_formater_ut.cpp +++ b/library/cpp/logger/global/rty_formater_ut.cpp @@ -7,23 +7,23 @@ namespace {      const TStringBuf SampleRtyLog("2017-07-25 19:26:09.894 +0300");  } -Y_UNIT_TEST_SUITE(NLoggingImplTest) { -    Y_UNIT_TEST(TestTLocalTimeSToStream) { +Y_UNIT_TEST_SUITE(NLoggingImplTest) {  +    Y_UNIT_TEST(TestTLocalTimeSToStream) {           NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));          TStringStream ss;          ss << lt;          UNIT_ASSERT_EQUAL(ss.Str(), SampleRtyLog);      } -    Y_UNIT_TEST(TestTLocalTimeSToString) { +    Y_UNIT_TEST(TestTLocalTimeSToString) {           NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));          UNIT_ASSERT_EQUAL(TString(lt), SampleRtyLog);      } -    Y_UNIT_TEST(TestTLocalTimeSAddLeft) { +    Y_UNIT_TEST(TestTLocalTimeSAddLeft) {           NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));          TStringBuf suffix("suffix");          UNIT_ASSERT_EQUAL(lt + suffix, TString(SampleRtyLog) + suffix);      } -    Y_UNIT_TEST(TestTLocalTimeSAddRight) { +    Y_UNIT_TEST(TestTLocalTimeSAddRight) {           NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));          TString prefix("prefix");          UNIT_ASSERT_EQUAL(prefix + lt, prefix + SampleRtyLog); diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp index e1d70cc3d28..c4419e75e94 100644 --- a/library/cpp/logger/log.cpp +++ b/library/cpp/logger/log.cpp @@ -27,7 +27,7 @@ THolder<TOwningThreadedLogBackend> CreateOwningThreadedLogBackend(const TString&  }  class TLog::TImpl: public TAtomicRefCount<TImpl> { -    class TPriorityLogStream final: public IOutputStream { +    class TPriorityLogStream final: public IOutputStream {       public:          inline TPriorityLogStream(ELogPriority p, const TImpl* parent)              : Priority_(p) @@ -40,13 +40,13 @@ class TLog::TImpl: public TAtomicRefCount<TImpl> {          }      private: -        ELogPriority Priority_ = LOG_DEF_PRIORITY; -        const TImpl* Parent_ = nullptr; +        ELogPriority Priority_ = LOG_DEF_PRIORITY;  +        const TImpl* Parent_ = nullptr;       };  public:      inline TImpl(THolder<TLogBackend> backend) -        : Backend_(std::move(backend)) +        : Backend_(std::move(backend))       {      } @@ -55,7 +55,7 @@ public:              return;          } -        Backend_->ReopenLog(); +        Backend_->ReopenLog();       }      inline void ReopenLogNoFlush() { @@ -63,7 +63,7 @@ public:              return;          } -        Backend_->ReopenLogNoFlush(); +        Backend_->ReopenLogNoFlush();       }      inline void AddLog(ELogPriority priority, const char* format, va_list args) const { @@ -77,30 +77,30 @@ public:      }      inline void ResetBackend(THolder<TLogBackend> backend) noexcept { -        Backend_ = std::move(backend); +        Backend_ = std::move(backend);       }      inline THolder<TLogBackend> ReleaseBackend() noexcept { -        return std::move(Backend_); +        return std::move(Backend_);       }      inline bool IsNullLog() const noexcept { -        return !IsOpen() || (dynamic_cast<TNullLogBackend*>(Backend_.Get()) != nullptr); +        return !IsOpen() || (dynamic_cast<TNullLogBackend*>(Backend_.Get()) != nullptr);       }      inline bool IsOpen() const noexcept { -        return nullptr != Backend_.Get(); +        return nullptr != Backend_.Get();       }      inline void CloseLog() noexcept { -        Backend_.Destroy(); +        Backend_.Destroy();           Y_ASSERT(!IsOpen());      }      inline void WriteData(ELogPriority priority, const char* data, size_t len) const {          if (IsOpen()) { -            Backend_->WriteData(TLogRecord(priority, data, len)); +            Backend_->WriteData(TLogRecord(priority, data, len));           }      } @@ -113,38 +113,38 @@ public:      }      inline ELogPriority FiltrationLevel() const noexcept { -        return Backend_->FiltrationLevel(); +        return Backend_->FiltrationLevel();       }      inline size_t BackEndQueueSize() const { -        return Backend_->QueueSize(); +        return Backend_->QueueSize();       }  private: -    THolder<TLogBackend> Backend_; -    ELogPriority DefaultPriority_ = LOG_DEF_PRIORITY; +    THolder<TLogBackend> Backend_;  +    ELogPriority DefaultPriority_ = LOG_DEF_PRIORITY;   };  TLog::TLog() -    : Impl_(MakeIntrusive<TImpl>(nullptr)) +    : Impl_(MakeIntrusive<TImpl>(nullptr))   {  } -TLog::TLog(const TString& fname, ELogPriority priority) +TLog::TLog(const TString& fname, ELogPriority priority)       : TLog(CreateLogBackend(fname, priority, false)) -{ +{   }  TLog::TLog(THolder<TLogBackend> backend) -    : Impl_(MakeIntrusive<TImpl>(std::move(backend))) +    : Impl_(MakeIntrusive<TImpl>(std::move(backend)))   {  } -TLog::TLog(const TLog&) = default; -TLog::TLog(TLog&&) = default; -TLog::~TLog() = default; -TLog& TLog::operator=(const TLog&) = default; -TLog& TLog::operator=(TLog&&) = default; +TLog::TLog(const TLog&) = default;  +TLog::TLog(TLog&&) = default;  +TLog::~TLog() = default;  +TLog& TLog::operator=(const TLog&) = default;  +TLog& TLog::operator=(TLog&&) = default;   bool TLog::IsOpen() const noexcept {      return Impl_->IsOpen(); @@ -177,13 +177,13 @@ void TLog::AddLogVAList(const char* format, va_list lst) {  }  void TLog::ReopenLog() { -    if (const auto copy = Impl_) { +    if (const auto copy = Impl_) {           copy->ReopenLog();      }  }  void TLog::ReopenLogNoFlush() { -    if (const auto copy = Impl_) { +    if (const auto copy = Impl_) {           copy->ReopenLogNoFlush();      }  } @@ -227,9 +227,9 @@ THolder<TLogBackend> TLog::ReleaseBackend() noexcept {  }  void TLog::Write(ELogPriority priority, const char* data, size_t len) const { -    if (Formatter_) { -        const auto formated = Formatter_(priority, TStringBuf{data, len}); -        Impl_->WriteData(priority, formated.data(), formated.size()); +    if (Formatter_) {  +        const auto formated = Formatter_(priority, TStringBuf{data, len});  +        Impl_->WriteData(priority, formated.data(), formated.size());       } else {          Impl_->WriteData(priority, data, len);      } @@ -244,7 +244,7 @@ void TLog::Write(const char* data, size_t len) const {  }  void TLog::SetFormatter(TLogFormatter formatter) noexcept { -    Formatter_ = std::move(formatter); +    Formatter_ = std::move(formatter);   }  size_t TLog::BackEndQueueSize() const { diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h index 8be984ccc8d..e0d9e8998fc 100644 --- a/library/cpp/logger/log.h +++ b/library/cpp/logger/log.h @@ -14,81 +14,81 @@  using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>; -// Logging facilities interface. -// -// ```cpp -// TLog base; -// ... -// auto log = base; -// log.SetFormatter([reqId](ELogPriority p, TStringBuf msg) { -//     return TStringBuilder() << "reqid=" << reqId << "; " << msg; -// }); -// -// log.Write(TLOG_INFO, "begin"); -// HandleRequest(...); -// log.Write(TLOG_INFO, "end"); -// ``` -// -// Users are encouraged to copy `TLog` instance. +// Logging facilities interface.  +//  +// ```cpp  +// TLog base;  +// ...  +// auto log = base;  +// log.SetFormatter([reqId](ELogPriority p, TStringBuf msg) {  +//     return TStringBuilder() << "reqid=" << reqId << "; " << msg;  +// });  +//  +// log.Write(TLOG_INFO, "begin");  +// HandleRequest(...);  +// log.Write(TLOG_INFO, "end");  +// ```  +//  +// Users are encouraged to copy `TLog` instance.   class TLog {  public: -    // Construct empty logger all writes will be spilled. +    // Construct empty logger all writes will be spilled.       TLog(); -    // Construct file logger. +    // Construct file logger.       TLog(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY); -    // Construct any type of logger +    // Construct any type of logger       TLog(THolder<TLogBackend> backend); -    TLog(const TLog&); -    TLog(TLog&&); +    TLog(const TLog&);  +    TLog(TLog&&);       ~TLog(); -    TLog& operator=(const TLog&); -    TLog& operator=(TLog&&); +    TLog& operator=(const TLog&);  +    TLog& operator=(TLog&&);  -    // Change underlying backend. -    // NOTE: not thread safe. +    // Change underlying backend.  +    // NOTE: not thread safe.       void ResetBackend(THolder<TLogBackend> backend) noexcept; -    // Reset underlying backend, `IsNullLog()` will return `true` after this call. -    // NOTE: not thread safe. +    // Reset underlying backend, `IsNullLog()` will return `true` after this call.  +    // NOTE: not thread safe.       THolder<TLogBackend> ReleaseBackend() noexcept; -    // Check if underlying backend is defined and is not null. -    // NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`. +    // Check if underlying backend is defined and is not null.  +    // NOTE: not thread safe with respect to `ResetBackend` and `ReleaseBackend`.       bool IsNullLog() const noexcept; -    // Write message to the log. -    // -    // @param[in] priority          Message priority to use. -    // @param[in] message           Message to write. -    void Write(ELogPriority priority, TStringBuf message) const; -    // Write message to the log using `DefaultPriority()`. +    // Write message to the log.  +    //  +    // @param[in] priority          Message priority to use.  +    // @param[in] message           Message to write.  +    void Write(ELogPriority priority, TStringBuf message) const;  +    // Write message to the log using `DefaultPriority()`.       void Write(const char* data, size_t len) const; -    // Write message to the log, but pass the message in a c-style. +    // Write message to the log, but pass the message in a c-style.       void Write(ELogPriority priority, const char* data, size_t len) const; - -    // Write message to the log in a c-like printf style. -    void Y_PRINTF_FORMAT(3, 4) AddLog(ELogPriority priority, const char* format, ...) const; -    // Write message to the log in a c-like printf style with `DefaultPriority()` priority. +  +    // Write message to the log in a c-like printf style.  +    void Y_PRINTF_FORMAT(3, 4) AddLog(ELogPriority priority, const char* format, ...) const;  +    // Write message to the log in a c-like printf style with `DefaultPriority()` priority.       void Y_PRINTF_FORMAT(2, 3) AddLog(const char* format, ...) const; - -    // Call `ReopenLog()` of the underlying backend. +  +    // Call `ReopenLog()` of the underlying backend.       void ReopenLog(); -    // Call `ReopenLogNoFlush()` of the underlying backend. +    // Call `ReopenLogNoFlush()` of the underlying backend.       void ReopenLogNoFlush(); -    // Call `QueueSize()` of the underlying backend. +    // Call `QueueSize()` of the underlying backend.       size_t BackEndQueueSize() const; -    // Set log default priority. -    // NOTE: not thread safe. +    // Set log default priority.  +    // NOTE: not thread safe.       void SetDefaultPriority(ELogPriority priority) noexcept; -    // Get default priority +    // Get default priority       ELogPriority DefaultPriority() const noexcept; -    // Call `FiltrationLevel()` of the underlying backend. +    // Call `FiltrationLevel()` of the underlying backend.       ELogPriority FiltrationLevel() const noexcept; -    // Set current log formatter. -    void SetFormatter(TLogFormatter formatter) noexcept; - +    // Set current log formatter.  +    void SetFormatter(TLogFormatter formatter) noexcept;  +       template <class T>      inline TLogElement operator<<(const T& t) const {          TLogElement ret(this); @@ -96,18 +96,18 @@ public:          return ret;      } -public: -    // These methods are deprecated and present here only for compatibility reasons (for 13 years -    // already ...). Do not use them. -    bool OpenLog(const char* path, ELogPriority lp = LOG_MAX_PRIORITY); -    bool IsOpen() const noexcept; -    void AddLogVAList(const char* format, va_list lst); -    void CloseLog(); - +public:  +    // These methods are deprecated and present here only for compatibility reasons (for 13 years  +    // already ...). Do not use them.  +    bool OpenLog(const char* path, ELogPriority lp = LOG_MAX_PRIORITY);  +    bool IsOpen() const noexcept;  +    void AddLogVAList(const char* format, va_list lst);  +    void CloseLog();  +   private:      class TImpl; -    TIntrusivePtr<TImpl> Impl_; -    TLogFormatter Formatter_; +    TIntrusivePtr<TImpl> Impl_;  +    TLogFormatter Formatter_;   };  THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY, bool threaded = false); diff --git a/library/cpp/logger/stream.cpp b/library/cpp/logger/stream.cpp index 96787ad94ba..a4c7c2e5b5f 100644 --- a/library/cpp/logger/stream.cpp +++ b/library/cpp/logger/stream.cpp @@ -3,7 +3,7 @@  #include <util/stream/output.h> -TStreamLogBackend::TStreamLogBackend(IOutputStream* slave) +TStreamLogBackend::TStreamLogBackend(IOutputStream* slave)       : Slave_(slave)  {  } diff --git a/library/cpp/logger/stream.h b/library/cpp/logger/stream.h index feb240afcbd..69a7d3dd128 100644 --- a/library/cpp/logger/stream.h +++ b/library/cpp/logger/stream.h @@ -2,16 +2,16 @@  #include "backend.h" -class IOutputStream; +class IOutputStream;   class TStreamLogBackend: public TLogBackend {  public: -    TStreamLogBackend(IOutputStream* slave); +    TStreamLogBackend(IOutputStream* slave);       ~TStreamLogBackend() override;      void WriteData(const TLogRecord& rec) override;      void ReopenLog() override;  private: -    IOutputStream* Slave_; +    IOutputStream* Slave_;   }; diff --git a/library/cpp/logger/system.cpp b/library/cpp/logger/system.cpp index 42233f63d25..1b228e3d24a 100644 --- a/library/cpp/logger/system.cpp +++ b/library/cpp/logger/system.cpp @@ -1,5 +1,5 @@ -#include <util/stream/output.h> -#include <util/stream/null.h> +#include <util/stream/output.h>  +#include <util/stream/null.h>   #include <util/system/compat.h>  #include <util/system/yassert.h>  #include <util/system/defaults.h> @@ -20,7 +20,7 @@ TSysLogBackend::TSysLogBackend(const char* ident, EFacility facility, int flags)      , Flags(flags)  {  #if defined(_unix_) -    Y_ASSERT(TSYSLOG_LOCAL0 <= facility && facility <= TSYSLOG_LOCAL7); +    Y_ASSERT(TSYSLOG_LOCAL0 <= facility && facility <= TSYSLOG_LOCAL7);       static const int f2sf[] = {          LOG_LOCAL0, @@ -56,7 +56,7 @@ void TSysLogBackend::WriteData(const TLogRecord& rec) {  #if defined(_unix_)      syslog(ELogPriority2SyslogPriority(rec.Priority), "%.*s", (int)rec.Len, rec.Data);  #else -    Y_UNUSED(rec); +    Y_UNUSED(rec);   #endif  } diff --git a/library/cpp/logger/ya.make b/library/cpp/logger/ya.make index 00a5263cba7..1cef3f66239 100644 --- a/library/cpp/logger/ya.make +++ b/library/cpp/logger/ya.make @@ -5,8 +5,8 @@ OWNER(      g:base  ) -LIBRARY() - +LIBRARY()  +   GENERATE_ENUM_SERIALIZATION(priority.h)  PEERDIR ( @@ -43,5 +43,5 @@ SRCS(  )  END() - -RECURSE_FOR_TESTS(ut) +  +RECURSE_FOR_TESTS(ut)   | 
