diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/logger/global/rty_formater.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/logger/global/rty_formater.h')
-rw-r--r-- | library/cpp/logger/global/rty_formater.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/library/cpp/logger/global/rty_formater.h b/library/cpp/logger/global/rty_formater.h new file mode 100644 index 0000000000..6532e1d769 --- /dev/null +++ b/library/cpp/logger/global/rty_formater.h @@ -0,0 +1,61 @@ +#pragma once + +#include "common.h" + +namespace NMemInfo { + struct TMemInfo; +} + +class ILoggerFormatter { +public: + virtual ~ILoggerFormatter() = default; + + virtual void Format(const TLogRecordContext&, TLogElement&) const = 0; +}; + +ILoggerFormatter* CreateRtyLoggerFormatter(); + +namespace NLoggingImpl { + class TLocalTimeS { + public: + TLocalTimeS(TInstant instant = TInstant::Now()) + : Instant(instant) + { + } + + TInstant GetInstant() const { + return Instant; + } + + operator TString() const; + TString operator+(TStringBuf right) const; + + private: + TInstant Instant; + }; + + IOutputStream& operator<<(IOutputStream& out, TLocalTimeS localTimeS); + + inline TLocalTimeS GetLocalTimeS() { + return TLocalTimeS(); + } + + TString GetSystemResources(); + TString PrintSystemResources(const NMemInfo::TMemInfo& info); + + struct TLoggerFormatterTraits { + static ILoggerFormatter* CreateDefault() { + return CreateRtyLoggerFormatter(); + } + }; +} + +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); +}; + +using TRTYLogPreprocessor = TLogRecordPreprocessor<TLogFilter, TRTYMessageFormater>; |