diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-10-31 17:11:37 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-10-31 17:11:37 +0000 |
commit | a4a4e847216dbe1e32056717eb466537d2128bce (patch) | |
tree | 27070fcd1102d57042f56b8eb602789b020a1d04 /library/cpp | |
parent | e13dea6e57e441f5dc2fe09409a2932cdc4f821c (diff) | |
parent | 6c9f2f9532a9812c29ae9f3ed08ad266b93993c0 (diff) | |
download | ydb-a4a4e847216dbe1e32056717eb466537d2128bce.tar.gz |
Merge branch 'rightlib' into mergelibs-241031-1710
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/blockcodecs/core/codecs.h | 6 | ||||
-rw-r--r-- | library/cpp/tld/tlds-alpha-by-domain.txt | 2 | ||||
-rw-r--r-- | library/cpp/yt/logging/backends/stream/stream_log_manager.cpp | 6 | ||||
-rw-r--r-- | library/cpp/yt/logging/logger.cpp | 13 | ||||
-rw-r--r-- | library/cpp/yt/logging/logger.h | 51 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/convert.cpp | 6 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/convert.h | 2 |
7 files changed, 66 insertions, 20 deletions
diff --git a/library/cpp/blockcodecs/core/codecs.h b/library/cpp/blockcodecs/core/codecs.h index 9c93c002748..6512abddefc 100644 --- a/library/cpp/blockcodecs/core/codecs.h +++ b/library/cpp/blockcodecs/core/codecs.h @@ -25,6 +25,12 @@ namespace NBlockCodecs { : TStringBuf((const char*)t.Data(), t.Size()) { } + + template <> + inline TData(const TString& t) + : TStringBuf((const char*)t.data(), t.size()) + { + } }; struct TCodecError: public yexception { diff --git a/library/cpp/tld/tlds-alpha-by-domain.txt b/library/cpp/tld/tlds-alpha-by-domain.txt index fbf58d0ddbb..4964f4e61d0 100644 --- a/library/cpp/tld/tlds-alpha-by-domain.txt +++ b/library/cpp/tld/tlds-alpha-by-domain.txt @@ -1,4 +1,4 @@ -# Version 2024102500, Last Updated Fri Oct 25 07:07:02 2024 UTC +# Version 2024102800, Last Updated Mon Oct 28 07:07:02 2024 UTC AAA AARP ABB diff --git a/library/cpp/yt/logging/backends/stream/stream_log_manager.cpp b/library/cpp/yt/logging/backends/stream/stream_log_manager.cpp index 62fa3e91d05..8b46d5679ff 100644 --- a/library/cpp/yt/logging/backends/stream/stream_log_manager.cpp +++ b/library/cpp/yt/logging/backends/stream/stream_log_manager.cpp @@ -21,12 +21,10 @@ public: { } void RegisterStaticAnchor( - TLoggingAnchor* anchor, + TLoggingAnchor* /*anchor*/, ::TSourceLocation /*sourceLocation*/, TStringBuf /*anchorMessage*/) override - { - anchor->Registered = true; - } + { } virtual void UpdateAnchor(TLoggingAnchor* /*anchor*/) override { } diff --git a/library/cpp/yt/logging/logger.cpp b/library/cpp/yt/logging/logger.cpp index 58add384296..a6a0010b3bf 100644 --- a/library/cpp/yt/logging/logger.cpp +++ b/library/cpp/yt/logging/logger.cpp @@ -195,14 +195,21 @@ bool TLogger::IsEssential() const return Essential_; } -void TLogger::UpdateAnchor(TLoggingAnchor* anchor) const +void TLogger::UpdateStaticAnchor( + TLoggingAnchor* anchor, + std::atomic<bool>* anchorRegistered, + ::TSourceLocation sourceLocation, + TStringBuf message) const { + if (!anchorRegistered->exchange(true)) { + LogManager_->RegisterStaticAnchor(anchor, sourceLocation, message); + } LogManager_->UpdateAnchor(anchor); } -void TLogger::RegisterStaticAnchor(TLoggingAnchor* anchor, ::TSourceLocation sourceLocation, TStringBuf message) const +void TLogger::UpdateDynamicAnchor(TLoggingAnchor* anchor) const { - LogManager_->RegisterStaticAnchor(anchor, sourceLocation, message); + LogManager_->UpdateAnchor(anchor); } void TLogger::Write(TLogEvent&& event) const diff --git a/library/cpp/yt/logging/logger.h b/library/cpp/yt/logging/logger.h index 35aba4eb4c4..eff5da078ea 100644 --- a/library/cpp/yt/logging/logger.h +++ b/library/cpp/yt/logging/logger.h @@ -206,8 +206,12 @@ public: bool IsEssential() const; bool IsAnchorUpToDate(const TLoggingAnchor& anchor) const; - void UpdateAnchor(TLoggingAnchor* anchor) const; - void RegisterStaticAnchor(TLoggingAnchor* anchor, ::TSourceLocation sourceLocation, TStringBuf message) const; + void UpdateStaticAnchor( + TLoggingAnchor* anchor, + std::atomic<bool>* anchorRegistered, + ::TSourceLocation sourceLocation, + TStringBuf message) const; + void UpdateDynamicAnchor(TLoggingAnchor* anchor) const; void Write(TLogEvent&& event) const; @@ -302,19 +306,12 @@ void LogStructuredEvent( #define YT_LOG_FATAL_UNLESS(condition, ...) if (!Y_LIKELY(condition)) YT_LOG_FATAL(__VA_ARGS__) #define YT_LOG_EVENT(logger, level, ...) \ - YT_LOG_EVENT_WITH_ANCHOR(logger, level, nullptr, __VA_ARGS__) - -#define YT_LOG_EVENT_WITH_ANCHOR(logger, level, anchor, ...) \ do { \ const auto& logger__ = (logger)(); \ auto level__ = (level); \ auto location__ = __LOCATION__; \ - \ - ::NYT::NLogging::TLoggingAnchor* anchor__ = (anchor); \ - [[unlikely]] if (!anchor__) { \ - static ::NYT::TLeakyStorage<::NYT::NLogging::TLoggingAnchor> staticAnchor__; \ - anchor__ = staticAnchor__.Get(); \ - } \ + static ::NYT::TLeakyStorage<::NYT::NLogging::TLoggingAnchor> anchorStorage__; \ + auto* anchor__ = anchorStorage__.Get(); \ \ bool anchorUpToDate__ = logger__.IsAnchorUpToDate(*anchor__); \ [[likely]] if (anchorUpToDate__) { \ @@ -328,7 +325,8 @@ void LogStructuredEvent( auto message__ = ::NYT::NLogging::NDetail::BuildLogMessage(loggingContext__, logger__, __VA_ARGS__); \ \ [[unlikely]] if (!anchorUpToDate__) { \ - logger__.RegisterStaticAnchor(anchor__, location__, message__.Anchor); \ + static std::atomic<bool> anchorRegistered__; \ + logger__.UpdateStaticAnchor(anchor__, &anchorRegistered__, location__, message__.Anchor); \ } \ \ auto effectiveLevel__ = ::NYT::NLogging::TLogger::GetEffectiveLoggingLevel(level__, *anchor__); \ @@ -345,6 +343,35 @@ void LogStructuredEvent( std::move(message__.MessageRef)); \ } while (false) +#define YT_LOG_EVENT_WITH_DYNAMIC_ANCHOR(logger, level, anchor, ...) \ + do { \ + const auto& logger__ = (logger)(); \ + auto level__ = (level); \ + auto location__ = __LOCATION__; \ + auto* anchor__ = (anchor); \ + \ + bool anchorUpToDate__ = logger__.IsAnchorUpToDate(*anchor__); \ + [[unlikely]] if (!anchorUpToDate__) { \ + logger__.UpdateDynamicAnchor(anchor__); \ + } \ + \ + auto effectiveLevel__ = ::NYT::NLogging::TLogger::GetEffectiveLoggingLevel(level__, *anchor__); \ + if (!logger__.IsLevelEnabled(effectiveLevel__)) { \ + break; \ + } \ + \ + auto loggingContext__ = ::NYT::NLogging::GetLoggingContext(); \ + auto message__ = ::NYT::NLogging::NDetail::BuildLogMessage(loggingContext__, logger__, __VA_ARGS__); \ + \ + ::NYT::NLogging::NDetail::LogEventImpl( \ + loggingContext__, \ + logger__, \ + effectiveLevel__, \ + location__, \ + anchor__, \ + std::move(message__.MessageRef)); \ + } while (false) + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NLogging diff --git a/library/cpp/yt/yson_string/convert.cpp b/library/cpp/yt/yson_string/convert.cpp index 6d78ea6c9db..68241adb789 100644 --- a/library/cpp/yt/yson_string/convert.cpp +++ b/library/cpp/yt/yson_string/convert.cpp @@ -67,6 +67,12 @@ TYsonString ConvertToYsonString<TString>(const TString& value) return ConvertToYsonString(static_cast<TStringBuf>(value)); } +template <> +TYsonString ConvertToYsonString<std::string>(const std::string& value) +{ + return ConvertToYsonString(static_cast<TStringBuf>(value)); +} + struct TConvertStringToYsonStringTag { }; diff --git a/library/cpp/yt/yson_string/convert.h b/library/cpp/yt/yson_string/convert.h index 06de28d2f9d..eedb0939e00 100644 --- a/library/cpp/yt/yson_string/convert.h +++ b/library/cpp/yt/yson_string/convert.h @@ -44,6 +44,8 @@ TYsonString ConvertToYsonString<ui64>(const ui64& value); template <> TYsonString ConvertToYsonString<TString>(const TString& value); template <> +TYsonString ConvertToYsonString<std::string>(const std::string& value); +template <> TYsonString ConvertToYsonString<TStringBuf>(const TStringBuf& value); TYsonString ConvertToYsonString(const char* value); |