aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/logger
diff options
context:
space:
mode:
authorbulatman <bulatman@yandex-team.ru>2022-02-10 16:45:50 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:50 +0300
commit2f6ca198245aeffd5e2d82b65927c2465b68b4f5 (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /library/cpp/logger
parent6560e4993b14d193f8c879e33a3de5e5eba6e21d (diff)
downloadydb-2f6ca198245aeffd5e2d82b65927c2465b68b4f5.tar.gz
Restoring authorship annotation for <bulatman@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/logger')
-rw-r--r--library/cpp/logger/global/common.h72
-rw-r--r--library/cpp/logger/global/global.cpp18
-rw-r--r--library/cpp/logger/global/global.h2
-rw-r--r--library/cpp/logger/global/rty_formater.cpp44
-rw-r--r--library/cpp/logger/global/rty_formater.h36
5 files changed, 86 insertions, 86 deletions
diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h
index 94327bf745..7dcf650dec 100644
--- a/library/cpp/logger/global/common.h
+++ b/library/cpp/logger/global/common.h
@@ -21,46 +21,46 @@ T* CreateDefaultLogger() {
return nullptr;
}
-namespace NLoggingImpl {
- template<class T, class TTraits>
- class TOperatorBase {
- struct TPtr {
- TPtr()
- : Instance(TTraits::CreateDefault())
- {
- }
-
- THolder<T> Instance;
- };
-
- public:
- inline static bool Usage() {
+namespace NLoggingImpl {
+ template<class T, class TTraits>
+ class TOperatorBase {
+ struct TPtr {
+ TPtr()
+ : Instance(TTraits::CreateDefault())
+ {
+ }
+
+ THolder<T> Instance;
+ };
+
+ public:
+ inline static bool Usage() {
return SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Get();
}
- inline static T* Get() {
+ inline static T* Get() {
return SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Get();
- }
-
- inline static void Set(T* v) {
+ }
+
+ inline static void Set(T* v) {
SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Reset(v);
- }
+ }
};
- template<class T>
- struct TLoggerTraits {
- static T* CreateDefault() {
- return CreateDefaultLogger<T>();
- }
- };
-}
-
-template <class T>
-class TLoggerOperator : public NLoggingImpl::TOperatorBase<T, NLoggingImpl::TLoggerTraits<T>> {
-public:
+ template<class T>
+ struct TLoggerTraits {
+ static T* CreateDefault() {
+ return CreateDefaultLogger<T>();
+ }
+ };
+}
+
+template <class T>
+class TLoggerOperator : public NLoggingImpl::TOperatorBase<T, NLoggingImpl::TLoggerTraits<T>> {
+public:
inline static TLog& Log() {
- Y_ASSERT(TLoggerOperator::Usage());
- return *TLoggerOperator::Get();
+ Y_ASSERT(TLoggerOperator::Usage());
+ return *TLoggerOperator::Get();
}
};
@@ -70,11 +70,11 @@ namespace NLoggingImpl {
// Returns correct log type to use
TString PrepareToOpenLog(TString logType, int logLevel, bool rotation, bool startAsDaemon);
-
- template <class TLoggerType>
- void InitLogImpl(TString logType, const int logLevel, const bool rotation, const bool startAsDaemon) {
+
+ template <class TLoggerType>
+ void InitLogImpl(TString logType, const int logLevel, const bool rotation, const bool startAsDaemon) {
TLoggerOperator<TLoggerType>::Set(new TLoggerType(PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), (ELogPriority)logLevel));
- }
+ }
}
struct TLogRecordContext {
diff --git a/library/cpp/logger/global/global.cpp b/library/cpp/logger/global/global.cpp
index beca88d5fa..9fbd10f666 100644
--- a/library/cpp/logger/global/global.cpp
+++ b/library/cpp/logger/global/global.cpp
@@ -1,11 +1,11 @@
#include "global.h"
-static void DoInitGlobalLog(THolder<TGlobalLog> logger, THolder<ILoggerFormatter> formatter) {
- TLoggerOperator<TGlobalLog>::Set(logger.Release());
- if (!formatter) {
- formatter.Reset(CreateRtyLoggerFormatter());
- }
- TLoggerFormatterOperator::Set(formatter.Release());
+static void DoInitGlobalLog(THolder<TGlobalLog> logger, THolder<ILoggerFormatter> formatter) {
+ TLoggerOperator<TGlobalLog>::Set(logger.Release());
+ if (!formatter) {
+ formatter.Reset(CreateRtyLoggerFormatter());
+ }
+ TLoggerFormatterOperator::Set(formatter.Release());
}
void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter, bool threaded) {
@@ -18,10 +18,10 @@ void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rota
std::move(formatter));
}
-void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter) {
+void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter) {
DoInitGlobalLog(THolder(new TGlobalLog(std::move(backend))), std::move(formatter));
-}
-
+}
+
bool GlobalLogInitialized() {
return TLoggerOperator<TGlobalLog>::Usage();
}
diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h
index 97907558d6..cbe71b16ea 100644
--- a/library/cpp/logger/global/global.h
+++ b/library/cpp/logger/global/global.h
@@ -7,7 +7,7 @@
bool GlobalLogInitialized();
void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter = {}, bool threaded = false);
-void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {});
+void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {});
inline void InitGlobalLog2Null() {
DoInitGlobalLog("null", TLOG_EMERG, false, false);
diff --git a/library/cpp/logger/global/rty_formater.cpp b/library/cpp/logger/global/rty_formater.cpp
index 2b86b68a0e..305f8470c5 100644
--- a/library/cpp/logger/global/rty_formater.cpp
+++ b/library/cpp/logger/global/rty_formater.cpp
@@ -62,33 +62,33 @@ namespace NLoggingImpl {
}
}
-namespace {
- class TRtyLoggerFormatter : public ILoggerFormatter {
- public:
- void Format(const TLogRecordContext& context, TLogElement& elem) const override {
- elem << context.CustomMessage << ": " << NLoggingImpl::GetLocalTimeS() << " "
- << NLoggingImpl::StripFileName(context.SourceLocation.File) << ":" << context.SourceLocation.Line;
- if (context.Priority > TLOG_RESOURCES && !ExitStarted()) {
- elem << NLoggingImpl::GetSystemResources();
- }
- elem << " ";
- }
- };
-}
-
-ILoggerFormatter* CreateRtyLoggerFormatter() {
- return new TRtyLoggerFormatter();
-}
-
+namespace {
+ class TRtyLoggerFormatter : public ILoggerFormatter {
+ public:
+ void Format(const TLogRecordContext& context, TLogElement& elem) const override {
+ elem << context.CustomMessage << ": " << NLoggingImpl::GetLocalTimeS() << " "
+ << NLoggingImpl::StripFileName(context.SourceLocation.File) << ":" << context.SourceLocation.Line;
+ if (context.Priority > TLOG_RESOURCES && !ExitStarted()) {
+ elem << NLoggingImpl::GetSystemResources();
+ }
+ elem << " ";
+ }
+ };
+}
+
+ILoggerFormatter* CreateRtyLoggerFormatter() {
+ return new TRtyLoggerFormatter();
+}
+
bool TRTYMessageFormater::CheckLoggingContext(TLog& /*logger*/, const TLogRecordContext& /*context*/) {
return true;
}
TSimpleSharedPtr<TLogElement> TRTYMessageFormater::StartRecord(TLog& logger, const TLogRecordContext& context, TSimpleSharedPtr<TLogElement> earlier) {
- if (!earlier) {
+ if (!earlier) {
earlier.Reset(new TLogElement(&logger));
- }
-
- TLoggerFormatterOperator::Get()->Format(context, *earlier);
+ }
+
+ TLoggerFormatterOperator::Get()->Format(context, *earlier);
return earlier;
}
diff --git a/library/cpp/logger/global/rty_formater.h b/library/cpp/logger/global/rty_formater.h
index b89b50776a..6532e1d769 100644
--- a/library/cpp/logger/global/rty_formater.h
+++ b/library/cpp/logger/global/rty_formater.h
@@ -6,15 +6,15 @@ namespace NMemInfo {
struct TMemInfo;
}
-class ILoggerFormatter {
-public:
- virtual ~ILoggerFormatter() = default;
-
- virtual void Format(const TLogRecordContext&, TLogElement&) const = 0;
-};
-
-ILoggerFormatter* CreateRtyLoggerFormatter();
-
+class ILoggerFormatter {
+public:
+ virtual ~ILoggerFormatter() = default;
+
+ virtual void Format(const TLogRecordContext&, TLogElement&) const = 0;
+};
+
+ILoggerFormatter* CreateRtyLoggerFormatter();
+
namespace NLoggingImpl {
class TLocalTimeS {
public:
@@ -42,17 +42,17 @@ namespace NLoggingImpl {
TString GetSystemResources();
TString PrintSystemResources(const NMemInfo::TMemInfo& info);
-
- struct TLoggerFormatterTraits {
- static ILoggerFormatter* CreateDefault() {
- return CreateRtyLoggerFormatter();
- }
- };
+
+ struct TLoggerFormatterTraits {
+ static ILoggerFormatter* CreateDefault() {
+ return CreateRtyLoggerFormatter();
+ }
+ };
}
-class TLoggerFormatterOperator : public NLoggingImpl::TOperatorBase<ILoggerFormatter, NLoggingImpl::TLoggerFormatterTraits> {
-};
-
+class TLoggerFormatterOperator : public NLoggingImpl::TOperatorBase<ILoggerFormatter, NLoggingImpl::TLoggerFormatterTraits> {
+};
+
struct TRTYMessageFormater {
static bool CheckLoggingContext(TLog& logger, const TLogRecordContext& context);
static TSimpleSharedPtr<TLogElement> StartRecord(TLog& logger, const TLogRecordContext& context, TSimpleSharedPtr<TLogElement> earlier);