diff options
71 files changed, 138 insertions, 108 deletions
diff --git a/library/cpp/yt/logging/logger-inl.h b/library/cpp/yt/logging/logger-inl.h index d076b3690e..dcf40d9c11 100644 --- a/library/cpp/yt/logging/logger-inl.h +++ b/library/cpp/yt/logging/logger-inl.h @@ -64,6 +64,11 @@ Y_FORCE_INLINE bool TLogger::IsLevelEnabled(ELogLevel level) const return IsLevelEnabledHeavy(level); } +Y_FORCE_INLINE const TLogger& TLogger::operator()() const +{ + return *this; +} + //////////////////////////////////////////////////////////////////////////////// namespace NDetail { diff --git a/library/cpp/yt/logging/logger.h b/library/cpp/yt/logging/logger.h index 0913b9ea08..693ea2b9cd 100644 --- a/library/cpp/yt/logging/logger.h +++ b/library/cpp/yt/logging/logger.h @@ -181,6 +181,10 @@ public: explicit operator bool() const; + //! Enables using |Logger| in YT_LOG_* macros as both data members and functions + //! (e.g. those introduced by YT_DEFINE_GLOBAL). + const TLogger& operator()() const; + const TLoggingCategory* GetCategory() const; //! Validate that level is admitted by logger's own min level @@ -292,7 +296,7 @@ void LogStructuredEvent( #define YT_LOG_EVENT_WITH_ANCHOR(logger, level, anchor, ...) \ do { \ - const auto& logger__ = (logger); \ + const auto& logger__ = (logger)(); \ auto level__ = (level); \ \ if (!logger__.IsLevelEnabled(level__)) { \ diff --git a/library/cpp/yt/misc/global.h b/library/cpp/yt/misc/global.h new file mode 100644 index 0000000000..df831b50c3 --- /dev/null +++ b/library/cpp/yt/misc/global.h @@ -0,0 +1,13 @@ +#pragma once + +//! Defines a global variable that is initialized on its first access. +/*! + * In contrast to a usual variable with static storage duration, this one + * is not susceptible to initialization order fisco issues. + */ +#define YT_DEFINE_GLOBAL(type, name, ...) \ + inline type& name() \ + { \ + static type result(__VA_ARGS__); \ + return result; \ + } diff --git a/yt/yt/core/actions/unittests/new_with_offloaded_dtor_ut.cpp b/yt/yt/core/actions/unittests/new_with_offloaded_dtor_ut.cpp index be7482808a..e9315b293e 100644 --- a/yt/yt/core/actions/unittests/new_with_offloaded_dtor_ut.cpp +++ b/yt/yt/core/actions/unittests/new_with_offloaded_dtor_ut.cpp @@ -17,7 +17,7 @@ using namespace NThreading; //////////////////////////////////////////////////////////////////////////////// -const NLogging::TLogger Logger("Test"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, Logger, "Test"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/bus/private.h b/yt/yt/core/bus/private.h index 9619611995..281105e1f5 100644 --- a/yt/yt/core/bus/private.h +++ b/yt/yt/core/bus/private.h @@ -12,7 +12,7 @@ namespace NYT::NBus { //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger BusLogger("Bus"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, BusLogger, "Bus"); inline const NProfiling::TProfiler BusProfiler("/bus"); using TConnectionId = TGuid; diff --git a/yt/yt/core/bus/tcp/client.cpp b/yt/yt/core/bus/tcp/client.cpp index 770375ddfe..efcd140620 100644 --- a/yt/yt/core/bus/tcp/client.cpp +++ b/yt/yt/core/bus/tcp/client.cpp @@ -28,7 +28,7 @@ using namespace NYTree; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = BusLogger; +static constexpr auto& Logger = BusLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/bus/tcp/connection.cpp b/yt/yt/core/bus/tcp/connection.cpp index f0acaaca92..3f514a5ab7 100644 --- a/yt/yt/core/bus/tcp/connection.cpp +++ b/yt/yt/core/bus/tcp/connection.cpp @@ -131,7 +131,7 @@ TTcpConnection::TTcpConnection( EndpointDescription_, Config_->EncryptionMode, Config_->VerificationMode)) - , Logger(BusLogger.WithTag(LoggingTag_.c_str())) + , Logger(BusLogger().WithTag(LoggingTag_.c_str())) , GenerateChecksums_(Config_->GenerateChecksums) , Socket_(socket) , MultiplexingBand_(multiplexingBand) diff --git a/yt/yt/core/bus/tcp/dispatcher_impl.cpp b/yt/yt/core/bus/tcp/dispatcher_impl.cpp index 5c0bf871ea..ddad066c89 100644 --- a/yt/yt/core/bus/tcp/dispatcher_impl.cpp +++ b/yt/yt/core/bus/tcp/dispatcher_impl.cpp @@ -22,7 +22,7 @@ using namespace NYson; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = BusLogger; +static constexpr auto& Logger = BusLogger; static constexpr auto PeriodicCheckPeriod = TDuration::MilliSeconds(100); static constexpr auto PerConnectionPeriodicCheckPeriod = TDuration::Seconds(10); diff --git a/yt/yt/core/bus/tcp/server.cpp b/yt/yt/core/bus/tcp/server.cpp index 4dadac913f..6d6737a96b 100644 --- a/yt/yt/core/bus/tcp/server.cpp +++ b/yt/yt/core/bus/tcp/server.cpp @@ -134,7 +134,7 @@ protected: YT_DECLARE_SPIN_LOCK(NThreading::TReaderWriterSpinLock, ConnectionsSpinLock_); THashSet<TTcpConnectionPtr> Connections_; - NLogging::TLogger Logger = BusLogger; + NLogging::TLogger Logger = BusLogger(); virtual void CreateServerSocket() = 0; diff --git a/yt/yt/core/compression/brotli.cpp b/yt/yt/core/compression/brotli.cpp index 55e101c7e9..5207a6cc89 100644 --- a/yt/yt/core/compression/brotli.cpp +++ b/yt/yt/core/compression/brotli.cpp @@ -10,7 +10,7 @@ namespace NYT::NCompression::NDetail { //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = CompressionLogger; +static constexpr auto& Logger = CompressionLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/compression/lzma.cpp b/yt/yt/core/compression/lzma.cpp index 3918215005..2f9009bac5 100644 --- a/yt/yt/core/compression/lzma.cpp +++ b/yt/yt/core/compression/lzma.cpp @@ -20,7 +20,7 @@ namespace NYT::NCompression::NDetail { namespace { -const auto& Logger = CompressionLogger; +static constexpr auto& Logger = CompressionLogger; // ISzAlloc is an interface containing alloc/free functions (with its own signatures) // required by lzma API. diff --git a/yt/yt/core/compression/private.h b/yt/yt/core/compression/private.h index da62a73fce..7b48b5513f 100644 --- a/yt/yt/core/compression/private.h +++ b/yt/yt/core/compression/private.h @@ -8,7 +8,7 @@ namespace NYT::NCompression { //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger CompressionLogger("Compression"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, CompressionLogger, "Compression"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/compression/zstd.cpp b/yt/yt/core/compression/zstd.cpp index da70d042dd..c8c067e763 100644 --- a/yt/yt/core/compression/zstd.cpp +++ b/yt/yt/core/compression/zstd.cpp @@ -18,7 +18,7 @@ namespace NYT::NCompression::NDetail { //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = CompressionLogger; +static constexpr auto& Logger = CompressionLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/delayed_executor.cpp b/yt/yt/core/concurrency/delayed_executor.cpp index c8d1da6415..23aabbff95 100644 --- a/yt/yt/core/concurrency/delayed_executor.cpp +++ b/yt/yt/core/concurrency/delayed_executor.cpp @@ -17,7 +17,7 @@ namespace NYT::NConcurrency { static constexpr auto CoalescingInterval = TDuration::MicroSeconds(100); static constexpr auto LateWarningThreshold = TDuration::Seconds(1); -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/execution_stack.cpp b/yt/yt/core/concurrency/execution_stack.cpp index 3d2c826296..f2a66f0476 100644 --- a/yt/yt/core/concurrency/execution_stack.cpp +++ b/yt/yt/core/concurrency/execution_stack.cpp @@ -22,7 +22,7 @@ namespace NYT::NConcurrency { -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/fair_share_thread_pool.cpp b/yt/yt/core/concurrency/fair_share_thread_pool.cpp index 37be0d6a54..4b4a48224d 100644 --- a/yt/yt/core/concurrency/fair_share_thread_pool.cpp +++ b/yt/yt/core/concurrency/fair_share_thread_pool.cpp @@ -21,7 +21,7 @@ namespace NYT::NConcurrency { using namespace NProfiling; -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// @@ -393,7 +393,7 @@ private: AccountCurrentlyExecutingBuckets(tscp); #ifdef YT_ENABLE_TRACE_LOGGING - if (Logger.IsLevelEnabled(NLogging::ELogLevel::Trace)) { + if (Logger().IsLevelEnabled(NLogging::ELogLevel::Trace)) { auto guard = Guard(TagMappingSpinLock_); YT_LOG_TRACE("Buckets: [%v]", MakeFormattableView( diff --git a/yt/yt/core/concurrency/fiber.cpp b/yt/yt/core/concurrency/fiber.cpp index 0bff308d4c..4e2395abb9 100644 --- a/yt/yt/core/concurrency/fiber.cpp +++ b/yt/yt/core/concurrency/fiber.cpp @@ -26,7 +26,7 @@ using namespace NProfiling; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/fiber_scheduler_thread.cpp b/yt/yt/core/concurrency/fiber_scheduler_thread.cpp index 9b4345b0bc..03a292e3b3 100644 --- a/yt/yt/core/concurrency/fiber_scheduler_thread.cpp +++ b/yt/yt/core/concurrency/fiber_scheduler_thread.cpp @@ -38,7 +38,7 @@ using namespace NProfiling; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/invoker_queue.cpp b/yt/yt/core/concurrency/invoker_queue.cpp index 22fa826733..27d985eb8a 100644 --- a/yt/yt/core/concurrency/invoker_queue.cpp +++ b/yt/yt/core/concurrency/invoker_queue.cpp @@ -16,7 +16,7 @@ using namespace NThreading; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/new_fair_share_thread_pool.cpp b/yt/yt/core/concurrency/new_fair_share_thread_pool.cpp index 7482f49b1d..f65dfdbff2 100644 --- a/yt/yt/core/concurrency/new_fair_share_thread_pool.cpp +++ b/yt/yt/core/concurrency/new_fair_share_thread_pool.cpp @@ -30,7 +30,7 @@ namespace NYT::NConcurrency { using namespace NProfiling; -inline const NLogging::TLogger Logger("FairShareThreadPool"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, Logger, "FairShareThreadPool"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/notify_manager.cpp b/yt/yt/core/concurrency/notify_manager.cpp index 596b3bc346..df9dc72fdd 100644 --- a/yt/yt/core/concurrency/notify_manager.cpp +++ b/yt/yt/core/concurrency/notify_manager.cpp @@ -5,7 +5,7 @@ namespace NYT::NConcurrency { -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/private.h b/yt/yt/core/concurrency/private.h index 7c1558e0ad..6a48878538 100644 --- a/yt/yt/core/concurrency/private.h +++ b/yt/yt/core/concurrency/private.h @@ -60,7 +60,7 @@ DECLARE_REFCOUNTED_STRUCT(IFairShareCallbackQueue) //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger ConcurrencyLogger("Concurrency"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, ConcurrencyLogger, "Concurrency"); inline const NProfiling::TProfiler ConcurrencyProfiler("/concurrency"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/quantized_executor.cpp b/yt/yt/core/concurrency/quantized_executor.cpp index 4487a6a205..205880ade4 100644 --- a/yt/yt/core/concurrency/quantized_executor.cpp +++ b/yt/yt/core/concurrency/quantized_executor.cpp @@ -25,7 +25,7 @@ public: : Name_(std::move(name)) , CallbackProvider_(std::move(callbackProvider)) , Options_(options) - , Logger(ConcurrencyLogger.WithTag("Executor: %v", Name_)) + , Logger(ConcurrencyLogger().WithTag("Executor: %v", Name_)) , ControlQueue_(New<TActionQueue>(Format("%vCtl", Name_))) , ControlInvoker_(ControlQueue_->GetInvoker()) , DesiredWorkerCount_(options.WorkerCount) diff --git a/yt/yt/core/concurrency/thread_pool_detail.cpp b/yt/yt/core/concurrency/thread_pool_detail.cpp index 0008f4a8c6..cb9c5dc1e6 100644 --- a/yt/yt/core/concurrency/thread_pool_detail.cpp +++ b/yt/yt/core/concurrency/thread_pool_detail.cpp @@ -9,7 +9,7 @@ namespace NYT::NConcurrency { -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/thread_pool_poller.cpp b/yt/yt/core/concurrency/thread_pool_poller.cpp index 444fd63228..045319c1c7 100644 --- a/yt/yt/core/concurrency/thread_pool_poller.cpp +++ b/yt/yt/core/concurrency/thread_pool_poller.cpp @@ -194,7 +194,7 @@ public: const TString& threadNamePrefix, TDuration pollingPeriod) : TThread(Format("%v:%v", threadNamePrefix, "Poll")) - , Logger(ConcurrencyLogger.WithTag("ThreadNamePrefix: %v", threadNamePrefix)) + , Logger(ConcurrencyLogger().WithTag("ThreadNamePrefix: %v", threadNamePrefix)) { // Register auxilary notifictation handle to wake up poller thread when deregistering // pollables and on shutdown. diff --git a/yt/yt/core/concurrency/two_level_fair_share_thread_pool.cpp b/yt/yt/core/concurrency/two_level_fair_share_thread_pool.cpp index 4711db5fb3..cb8a8fd010 100644 --- a/yt/yt/core/concurrency/two_level_fair_share_thread_pool.cpp +++ b/yt/yt/core/concurrency/two_level_fair_share_thread_pool.cpp @@ -24,7 +24,7 @@ namespace NYT::NConcurrency { using namespace NProfiling; -static const auto& Logger = ConcurrencyLogger; +static constexpr auto& Logger = ConcurrencyLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/concurrency/unittests/scheduler_ut.cpp b/yt/yt/core/concurrency/unittests/scheduler_ut.cpp index 12a8b32607..eacf17a1e6 100644 --- a/yt/yt/core/concurrency/unittests/scheduler_ut.cpp +++ b/yt/yt/core/concurrency/unittests/scheduler_ut.cpp @@ -49,7 +49,7 @@ using ::testing::ContainsRegex; constexpr auto SleepQuantum = TDuration::MilliSeconds(100); -inline const NLogging::TLogger Logger("SchedulerTest"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, Logger, "SchedulerTest"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/crypto/unittests/tls_ut.cpp b/yt/yt/core/crypto/unittests/tls_ut.cpp index eb7045b5a0..e756b2c808 100644 --- a/yt/yt/core/crypto/unittests/tls_ut.cpp +++ b/yt/yt/core/crypto/unittests/tls_ut.cpp @@ -67,7 +67,7 @@ TEST_F(TTlsTest, CreateDialer) { auto config = New<TDialerConfig>(); config->SetDefaults(); - auto dialer = Context->CreateDialer(config, Poller, NetLogger); + auto dialer = Context->CreateDialer(config, Poller, NetLogger()); } TEST_F(TTlsTest, SimplePingPong) @@ -77,7 +77,7 @@ TEST_F(TTlsTest, SimplePingPong) auto config = New<TDialerConfig>(); config->SetDefaults(); - auto dialer = Context->CreateDialer(config, Poller, NetLogger); + auto dialer = Context->CreateDialer(config, Poller, NetLogger()); auto context = New<TDialerContext>(); context->Host = "localhost"; diff --git a/yt/yt/core/dns/ares_dns_resolver.cpp b/yt/yt/core/dns/ares_dns_resolver.cpp index 799a681c3c..1943b28710 100644 --- a/yt/yt/core/dns/ares_dns_resolver.cpp +++ b/yt/yt/core/dns/ares_dns_resolver.cpp @@ -116,7 +116,7 @@ using namespace NNet; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = DnsLogger; +static constexpr auto& Logger = DnsLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/dns/private.h b/yt/yt/core/dns/private.h index 30869f3a40..88b2fcdcc4 100644 --- a/yt/yt/core/dns/private.h +++ b/yt/yt/core/dns/private.h @@ -10,7 +10,7 @@ namespace NYT::NDns { //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger DnsLogger("Dns"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, DnsLogger, "Dns"); inline const NProfiling::TProfiler DnsProfiler("/dns"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/http/client.cpp b/yt/yt/core/http/client.cpp index 24f955bcdb..83041bfc17 100644 --- a/yt/yt/core/http/client.cpp +++ b/yt/yt/core/http/client.cpp @@ -324,7 +324,7 @@ IClientPtr CreateClient( { return CreateClient( config, - CreateDialer(New<TDialerConfig>(), poller, HttpLogger), + CreateDialer(New<TDialerConfig>(), poller, HttpLogger()), poller->GetInvoker()); } diff --git a/yt/yt/core/http/helpers.cpp b/yt/yt/core/http/helpers.cpp index 52e56c0dfa..d2546c59bd 100644 --- a/yt/yt/core/http/helpers.cpp +++ b/yt/yt/core/http/helpers.cpp @@ -25,7 +25,7 @@ namespace NYT::NHttp { -static const auto& Logger = HttpLogger; +static constexpr auto& Logger = HttpLogger; using namespace NJson; using namespace NYson; diff --git a/yt/yt/core/http/private.h b/yt/yt/core/http/private.h index 15cecc2ff9..691d022bbd 100644 --- a/yt/yt/core/http/private.h +++ b/yt/yt/core/http/private.h @@ -1,6 +1,6 @@ #pragma once -#include "http.h" +#include "public.h" #include <yt/yt/core/logging/log.h> @@ -10,7 +10,7 @@ namespace NYT::NHttp { //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger HttpLogger("Http"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, HttpLogger, "Http"); inline const NProfiling::TProfiler HttpProfiler = NProfiling::TProfiler{"/http"}.WithHot(); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/http/retrying_client.cpp b/yt/yt/core/http/retrying_client.cpp index 50ece57066..f386b33bec 100644 --- a/yt/yt/core/http/retrying_client.cpp +++ b/yt/yt/core/http/retrying_client.cpp @@ -1,6 +1,7 @@ #include "config.h" #include "retrying_client.h" +#include "http.h" #include "private.h" #include <yt/yt/core/http/client.h> @@ -14,7 +15,7 @@ using namespace NNet; using namespace NYTree; using namespace NConcurrency; -static const auto& Logger = HttpLogger; +static constexpr auto& Logger = HttpLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/http/server.cpp b/yt/yt/core/http/server.cpp index 5d049a33d3..10cb7ea841 100644 --- a/yt/yt/core/http/server.cpp +++ b/yt/yt/core/http/server.cpp @@ -25,7 +25,7 @@ using namespace NConcurrency; using namespace NProfiling; using namespace NNet; -static const auto& Logger = HttpLogger; +static constexpr auto& Logger = HttpLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/http/stream.cpp b/yt/yt/core/http/stream.cpp index 30931be20d..2811da6eae 100644 --- a/yt/yt/core/http/stream.cpp +++ b/yt/yt/core/http/stream.cpp @@ -14,7 +14,7 @@ namespace NYT::NHttp { using namespace NConcurrency; using namespace NNet; -static const auto& Logger = HttpLogger; +static constexpr auto& Logger = HttpLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/http/unittests/http_ut.cpp b/yt/yt/core/http/unittests/http_ut.cpp index 80c016722a..d8351afcec 100644 --- a/yt/yt/core/http/unittests/http_ut.cpp +++ b/yt/yt/core/http/unittests/http_ut.cpp @@ -1025,7 +1025,7 @@ TEST_P(THttpServerTest, ResponseStreaming) Sleep(TDuration::MilliSeconds(10)); } -const auto& Logger = HttpLogger; +static constexpr auto& Logger = HttpLogger; class TCancelingHandler : public IHttpHandler @@ -1068,7 +1068,7 @@ TEST_P(THttpServerTest, RequestCancel) Server->AddHandler("/cancel", handler); Server->Start(); - auto dialer = CreateDialer(New<TDialerConfig>(), Poller, HttpLogger); + auto dialer = CreateDialer(New<TDialerConfig>(), Poller, HttpLogger()); auto connection = WaitFor(dialer->Dial(TNetworkAddress::CreateIPv6Loopback(TestPort))) .ValueOrThrow(); WaitFor(connection->Write(TSharedRef::FromString("POST /cancel HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n"))) @@ -1107,7 +1107,7 @@ TEST_P(THttpServerTest, RequestHangUp) Server->AddHandler("/validating", validating); Server->Start(); - auto dialer = CreateDialer(New<TDialerConfig>(), Poller, HttpLogger); + auto dialer = CreateDialer(New<TDialerConfig>(), Poller, HttpLogger()); auto connection = WaitFor(dialer->Dial(TNetworkAddress::CreateIPv6Loopback(TestPort))) .ValueOrThrow(); WaitFor(connection->Write(TSharedRef::FromString("POST /validating HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n"))) @@ -1134,7 +1134,7 @@ TEST_P(THttpServerTest, ConnectionKeepAlive) Server->AddHandler("/echo", New<TEchoHttpHandler>()); Server->Start(); - auto dialer = CreateDialer(New<TDialerConfig>(), Poller, HttpLogger); + auto dialer = CreateDialer(New<TDialerConfig>(), Poller, HttpLogger()); // Many requests. { @@ -1218,7 +1218,7 @@ TEST_P(THttpServerTest, ReuseConnections) Server->AddHandler("/echo", New<TEchoHttpHandler>()); Server->Start(); - auto dialer = NNet::CreateDialer(New<TDialerConfig>(), Poller, HttpLogger); + auto dialer = NNet::CreateDialer(New<TDialerConfig>(), Poller, HttpLogger()); auto dialerMock = New<TDialerMock>(dialer); auto clientConfig = New<NHttp::TClientConfig>(); clientConfig->MaxIdleConnections = 2; @@ -1253,7 +1253,7 @@ TEST_P(THttpServerTest, DropConnectionsByTimeout) Server->AddHandler("/echo", New<TEchoHttpHandler>()); Server->Start(); - auto dialer = NNet::CreateDialer(New<TDialerConfig>(), Poller, HttpLogger); + auto dialer = NNet::CreateDialer(New<TDialerConfig>(), Poller, HttpLogger()); auto dialerMock = New<TDialerMock>(dialer); auto clientConfig = New<NHttp::TClientConfig>(); clientConfig->MaxIdleConnections = 1; @@ -1290,7 +1290,7 @@ TEST_P(THttpServerTest, ConnectionsDropRoutine) Server->AddHandler("/echo", New<TEchoHttpHandler>()); Server->Start(); - auto dialer = NNet::CreateDialer(New<TDialerConfig>(), Poller, HttpLogger); + auto dialer = NNet::CreateDialer(New<TDialerConfig>(), Poller, HttpLogger()); auto dialerMock = New<TDialerMock>(dialer); auto clientConfig = New<NHttp::TClientConfig>(); clientConfig->MaxIdleConnections = 1; diff --git a/yt/yt/core/https/client.cpp b/yt/yt/core/https/client.cpp index 8ce559a583..95ac66b856 100644 --- a/yt/yt/core/https/client.cpp +++ b/yt/yt/core/https/client.cpp @@ -125,7 +125,7 @@ IClientPtr CreateClient( auto tlsDialer = sslContext->CreateDialer( New<TDialerConfig>(), poller, - HttpLogger); + HttpLogger()); auto httpClient = NHttp::CreateClient( config, diff --git a/yt/yt/core/logging/unittests/logging_ut.cpp b/yt/yt/core/logging/unittests/logging_ut.cpp index 9448c56b9b..2d14f8235d 100644 --- a/yt/yt/core/logging/unittests/logging_ut.cpp +++ b/yt/yt/core/logging/unittests/logging_ut.cpp @@ -28,6 +28,8 @@ #include <library/cpp/streams/zstd/zstd.h> +#include <library/cpp/yt/misc/global.h> + #include <util/system/fs.h> #include <util/system/tempfile.h> @@ -50,7 +52,7 @@ using namespace NJson; //////////////////////////////////////////////////////////////////////////////// -const TLogger Logger("Test"); +YT_DEFINE_GLOBAL(NLogging::TLogger, Logger, "Test"); TString GenerateLogFileName() { @@ -87,7 +89,7 @@ protected: { TLogEvent event; event.Family = ELogFamily::PlainText; - event.Category = Logger.GetCategory(); + event.Category = Logger().GetCategory(); event.Level = ELogLevel::Debug; event.MessageRef = TSharedRef::FromString("message"); event.MessageKind = ELogMessageKind::Unstructured; @@ -99,7 +101,7 @@ protected: { EXPECT_EQ( Format("\tD\t%v\t%v\t%v\t\t\n", - Logger.GetCategory()->Name, + Logger().GetCategory()->Name, "message", "ba"), line.substr(DateLength)); @@ -119,7 +121,7 @@ protected: TString line; std::vector<TString> lines; while (input->ReadLine(line)) { - if (line.Contains(Logger.GetCategory()->Name)) { + if (line.Contains(Logger().GetCategory()->Name)) { lines.push_back(line + "\n"); } } @@ -507,7 +509,7 @@ TEST_F(TLoggingTest, PlainTextLoggingStructuredFormatter) { TLogEvent event; event.Family = ELogFamily::PlainText; - event.Category = Logger.GetCategory(); + event.Category = Logger().GetCategory(); event.Level = ELogLevel::Debug; event.MessageRef = TSharedRef::FromString("test_message"); event.MessageKind = ELogMessageKind::Unstructured; @@ -538,7 +540,7 @@ TEST_F(TLoggingTest, PlainTextLoggingStructuredFormatter) auto message = DeserializeStructuredEvent(lines[0], format); EXPECT_EQ(message->GetChildOrThrow("message")->AsString()->GetValue(), "test_message"); EXPECT_EQ(message->GetChildOrThrow("level")->AsString()->GetValue(), "debug"); - EXPECT_EQ(message->GetChildOrThrow("category")->AsString()->GetValue(), Logger.GetCategory()->Name); + EXPECT_EQ(message->GetChildOrThrow("category")->AsString()->GetValue(), Logger().GetCategory()->Name); EXPECT_EQ(message->GetChildOrThrow("fiber_id")->AsString()->GetValue(), "1f"); EXPECT_EQ(message->GetChildOrThrow("trace_id")->AsString()->GetValue(), "4-3-2-1"); @@ -555,7 +557,7 @@ TEST_F(TLoggingTest, StructuredLogging) { TLogEvent event; event.Family = ELogFamily::Structured; - event.Category = Logger.GetCategory(); + event.Category = Logger().GetCategory(); event.Level = ELogLevel::Debug; event.MessageRef = BuildYsonStringFluently<EYsonType::MapFragment>() .Item("message").Value("test_message") @@ -587,7 +589,7 @@ TEST_F(TLoggingTest, StructuredLogging) auto message = DeserializeStructuredEvent(lines[0], format); EXPECT_EQ(message->GetChildOrThrow("message")->AsString()->GetValue(), "test_message"); EXPECT_EQ(message->GetChildOrThrow("level")->AsString()->GetValue(), "debug"); - EXPECT_EQ(message->GetChildOrThrow("category")->AsString()->GetValue(), Logger.GetCategory()->Name); + EXPECT_EQ(message->GetChildOrThrow("category")->AsString()->GetValue(), Logger().GetCategory()->Name); EXPECT_EQ(message->FindChild("fiber_id"), nullptr); EXPECT_EQ(message->FindChild("trace_id"), nullptr); @@ -598,7 +600,7 @@ TEST_F(TLoggingTest, UnstructuredLogging) { TLogEvent event; event.Family = ELogFamily::Structured; - event.Category = Logger.GetCategory(); + event.Category = Logger().GetCategory(); event.Level = ELogLevel::Debug; event.MessageRef = TSharedRef::FromString("test_message"); event.MessageKind = ELogMessageKind::Unstructured; @@ -624,7 +626,7 @@ TEST_F(TLoggingTest, UnstructuredLogging) auto message = DeserializeStructuredEvent(lines[0], format); EXPECT_EQ(message->GetChildOrThrow("message")->AsString()->GetValue(), "test_message"); EXPECT_EQ(message->GetChildOrThrow("level")->AsString()->GetValue(), FormatEnum(ELogLevel::Debug)); - EXPECT_EQ(message->GetChildOrThrow("category")->AsString()->GetValue(), Logger.GetCategory()->Name); + EXPECT_EQ(message->GetChildOrThrow("category")->AsString()->GetValue(), Logger().GetCategory()->Name); } } @@ -635,7 +637,7 @@ TEST_F(TLoggingTest, StructuredLoggingJsonFormat) TLogEvent event; event.Family = ELogFamily::Structured; - event.Category = Logger.GetCategory(); + event.Category = Logger().GetCategory(); event.Level = ELogLevel::Debug; event.MessageRef = BuildYsonStringFluently<EYsonType::MapFragment>() .Item("message").Value("test_message") @@ -679,7 +681,7 @@ TEST_F(TLoggingTest, StructuredLoggingJsonFormat) EXPECT_EQ(message->GetChildOrThrow("nan_value")->AsString()->GetValue(), "nan"); EXPECT_EQ(message->GetChildOrThrow("long_string_value")->AsString()->GetValue(), longStringPrefix); EXPECT_EQ(message->GetChildOrThrow("level")->AsString()->GetValue(), FormatEnum(ELogLevel::Debug)); - EXPECT_EQ(message->GetChildOrThrow("category")->AsString()->GetValue(), Logger.GetCategory()->Name); + EXPECT_EQ(message->GetChildOrThrow("category")->AsString()->GetValue(), Logger().GetCategory()->Name); } TEST_F(TLoggingTest, StructuredLoggingWithValidator) @@ -703,7 +705,7 @@ TEST_F(TLoggingTest, StructuredLoggingWithValidator) "structured_validation_sampling_rate" = 1.0; })", logFile.Name())); - auto logger = Logger.WithStructuredValidator([] (const TYsonString& yson) { + auto logger = Logger().WithStructuredValidator([] (const TYsonString& yson) { auto message = ConvertToNode(yson)->AsMap(); auto testField = message->FindChild("test_field"); if (!testField) { @@ -730,7 +732,7 @@ TEST_F(TLoggingTest, StructuredLoggingWithValidator) TEST_F(TLoggingTest, StructuredValidationWithSamplingRate) { int counter = 0; - auto logger = Logger.WithStructuredValidator([&counter] (const TYsonString& /*yson*/) { + auto logger = Logger().WithStructuredValidator([&counter] (const TYsonString& /*yson*/) { counter++; }); @@ -767,7 +769,7 @@ TEST_F(TLoggingTest, StructuredLoggingDisableSystemFields) { TLogEvent event; event.Family = ELogFamily::Structured; - event.Category = Logger.GetCategory(); + event.Category = Logger().GetCategory(); event.Level = ELogLevel::Debug; event.MessageRef = BuildYsonStringFluently<EYsonType::MapFragment>() .Item("message").Value("test_message") @@ -1282,7 +1284,7 @@ public: void Write(const TLogEvent& event) override { - if (event.Category == Logger.GetCategory()) { + if (event.Category == Logger().GetCategory()) { Messages_.push_back(TString(Config_->Padding, ' ') + event.MessageRef.ToStringBuf()); } } diff --git a/yt/yt/core/misc/atomic_ptr-inl.h b/yt/yt/core/misc/atomic_ptr-inl.h index 021c82318b..43cdafb07b 100644 --- a/yt/yt/core/misc/atomic_ptr-inl.h +++ b/yt/yt/core/misc/atomic_ptr-inl.h @@ -5,6 +5,8 @@ #endif #undef ATOMIC_PTR_INL_H_ +#include "private.h" + namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -19,7 +21,7 @@ TIntrusivePtr<T> TryMakeStrongFromHazard(const THazardPtr<T>& ptr) } if (!GetRefCounter(ptr.Get())->TryRef()) { - static const auto& Logger = LockFreePtrLogger; + constexpr auto& Logger = LockFreeLogger; YT_LOG_TRACE("Failed to acquire intrusive ptr from hazard ptr (Ptr: %v)", ptr.Get()); return nullptr; @@ -158,7 +160,7 @@ TAtomicPtr<T, EnableAcquireHazard> TAtomicPtr<T, EnableAcquireHazard>::SwapIfCom template <class T, bool EnableAcquireHazard> bool TAtomicPtr<T, EnableAcquireHazard>::SwapIfCompare(T* comparePtr, TIntrusivePtr<T> target) { - static const auto& Logger = LockFreePtrLogger; + constexpr auto& Logger = LockFreeLogger; auto* targetPtr = target.Get(); auto* savedPtr = comparePtr; diff --git a/yt/yt/core/misc/common.h b/yt/yt/core/misc/common.h index a9e6aa1bb1..3e6f1e74a7 100644 --- a/yt/yt/core/misc/common.h +++ b/yt/yt/core/misc/common.h @@ -12,6 +12,7 @@ // NB: Must be included after IntrusivePtr<T> for // template instantiation correctness. #include <library/cpp/yt/misc/optional.h> +#include <library/cpp/yt/misc/global.h> #include <util/datetime/base.h> diff --git a/yt/yt/core/misc/concurrent_cache-inl.h b/yt/yt/core/misc/concurrent_cache-inl.h index 8fe3021148..8af78fb940 100644 --- a/yt/yt/core/misc/concurrent_cache-inl.h +++ b/yt/yt/core/misc/concurrent_cache-inl.h @@ -50,7 +50,7 @@ TConcurrentCache<T>::RenewTable(const TIntrusivePtr<TLookupTable>& head, size_t newHead->Next = head; if (Head_.SwapIfCompare(head, newHead)) { - static const auto& Logger = LockFreePtrLogger; + constexpr auto& Logger = LockFreeLogger; YT_LOG_DEBUG("Concurrent cache lookup table rotated (LoadFactor: %v)", head->Size.load()); @@ -75,7 +75,7 @@ TConcurrentCache<T>::~TConcurrentCache() { auto head = Head_.Acquire(); - static const auto& Logger = LockFreePtrLogger; + constexpr auto& Logger = LockFreeLogger; YT_LOG_DEBUG("Concurrent cache head statistics (ElementCount: %v)", head->Size.load()); } diff --git a/yt/yt/core/misc/hazard_ptr.cpp b/yt/yt/core/misc/hazard_ptr.cpp index 07b3f5c80a..ea61b0e02e 100644 --- a/yt/yt/core/misc/hazard_ptr.cpp +++ b/yt/yt/core/misc/hazard_ptr.cpp @@ -1,5 +1,7 @@ #include "hazard_ptr.h" +#include "private.h" + #include <yt/yt/core/misc/singleton.h> #include <yt/yt/core/misc/proc.h> #include <yt/yt/core/misc/ring_queue.h> @@ -23,8 +25,7 @@ using namespace NConcurrency; ///////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger LockFreePtrLogger("LockFree"); -static const auto& Logger = LockFreePtrLogger; +static constexpr auto& Logger = LockFreeLogger; //////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/misc/hazard_ptr.h b/yt/yt/core/misc/hazard_ptr.h index df31004c03..f6a3bf58ca 100644 --- a/yt/yt/core/misc/hazard_ptr.h +++ b/yt/yt/core/misc/hazard_ptr.h @@ -12,8 +12,6 @@ namespace NYT { //////////////////////////////////////////////////////////////////////////////// -extern const NLogging::TLogger LockFreePtrLogger; - void ReclaimHazardPointers(bool flush = true); using THazardPtrReclaimer = void(*)(TPackedPtr packedPtr); diff --git a/yt/yt/core/misc/private.h b/yt/yt/core/misc/private.h new file mode 100644 index 0000000000..ad3e815305 --- /dev/null +++ b/yt/yt/core/misc/private.h @@ -0,0 +1,15 @@ +#pragma once + +#include "common.h" + +#include <library/cpp/yt/logging/logger.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +YT_DEFINE_GLOBAL(const NLogging::TLogger, LockFreeLogger, "LockFree"); + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/yt/yt/core/misc/slab_allocator.cpp b/yt/yt/core/misc/slab_allocator.cpp index 55a3aed322..bba4c9afc7 100644 --- a/yt/yt/core/misc/slab_allocator.cpp +++ b/yt/yt/core/misc/slab_allocator.cpp @@ -133,7 +133,7 @@ public: ~TSmallArena() { - static const auto& Logger = LockFreePtrLogger; + constexpr auto& Logger = LockFreeLogger; FreeList_.ExtractAll(); @@ -225,7 +225,7 @@ private: auto segmentCount = SegmentCount_.load(); auto refCount = GetRefCounter(this)->GetRefCount(); - static const auto& Logger = LockFreePtrLogger; + constexpr auto& Logger = LockFreeLogger; YT_LOG_TRACE("Allocating segment (ObjectSize: %v, RefCount: %v, SegmentCount: %v, TotalObjectCapacity: %v, TotalSize: %v)", ObjectSize_, diff --git a/yt/yt/core/net/address.cpp b/yt/yt/core/net/address.cpp index c7f29b6052..460b503292 100644 --- a/yt/yt/core/net/address.cpp +++ b/yt/yt/core/net/address.cpp @@ -52,7 +52,7 @@ using namespace NDns; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = NetLogger; +static constexpr auto& Logger = NetLogger; //////////////////////////////////////////////////////////////////////////////// // These are implemented in local_address.cpp. diff --git a/yt/yt/core/net/listener.cpp b/yt/yt/core/net/listener.cpp index 8c74d6e4e4..03996e7640 100644 --- a/yt/yt/core/net/listener.cpp +++ b/yt/yt/core/net/listener.cpp @@ -16,7 +16,7 @@ using namespace NConcurrency; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = NetLogger; +static constexpr auto& Logger = NetLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/net/private.h b/yt/yt/core/net/private.h index 04dcc63e14..bbb18b771d 100644 --- a/yt/yt/core/net/private.h +++ b/yt/yt/core/net/private.h @@ -8,7 +8,7 @@ namespace NYT::NNet { //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger NetLogger("Net"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, NetLogger, "Net"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/net/unittests/net_ut.cpp b/yt/yt/core/net/unittests/net_ut.cpp index 62e3b0a4c1..f924bcb020 100644 --- a/yt/yt/core/net/unittests/net_ut.cpp +++ b/yt/yt/core/net/unittests/net_ut.cpp @@ -39,7 +39,7 @@ protected: return NNet::CreateDialer( New<TDialerConfig>(), Poller_, - NetLogger); + NetLogger()); } }; diff --git a/yt/yt/core/rpc/balancing_channel.cpp b/yt/yt/core/rpc/balancing_channel.cpp index 7c1555f381..5231086218 100644 --- a/yt/yt/core/rpc/balancing_channel.cpp +++ b/yt/yt/core/rpc/balancing_channel.cpp @@ -28,7 +28,7 @@ using namespace NNet; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = RpcClientLogger; +static constexpr auto& Logger = RpcClientLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/bus/server.cpp b/yt/yt/core/rpc/bus/server.cpp index ef7f01b5ca..cb7e39d581 100644 --- a/yt/yt/core/rpc/bus/server.cpp +++ b/yt/yt/core/rpc/bus/server.cpp @@ -30,7 +30,7 @@ class TBusServer { public: explicit TBusServer(IBusServerPtr busServer) - : TServerBase(RpcServerLogger.WithTag("BusServerId: %v", TGuid::Create())) + : TServerBase(RpcServerLogger().WithTag("BusServerId: %v", TGuid::Create())) , BusServer_(std::move(busServer)) { } diff --git a/yt/yt/core/rpc/caching_channel_factory.cpp b/yt/yt/core/rpc/caching_channel_factory.cpp index 256077e714..8f8c8c784a 100644 --- a/yt/yt/core/rpc/caching_channel_factory.cpp +++ b/yt/yt/core/rpc/caching_channel_factory.cpp @@ -20,7 +20,7 @@ using namespace NYT::NBus; //////////////////////////////////////////////////////////////////////////////// static constexpr auto ExpirationCheckInterval = TDuration::Seconds(15); -static const auto& Logger = RpcClientLogger; +static constexpr auto& Logger = RpcClientLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/client.cpp b/yt/yt/core/rpc/client.cpp index 37e3cf42c3..cbeef69214 100644 --- a/yt/yt/core/rpc/client.cpp +++ b/yt/yt/core/rpc/client.cpp @@ -27,7 +27,7 @@ using NYT::ToProto; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = RpcClientLogger; +static constexpr auto& Logger = RpcClientLogger; static const auto LightInvokerDurationWarningThreshold = TDuration::MilliSeconds(10); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/dynamic_channel_pool.cpp b/yt/yt/core/rpc/dynamic_channel_pool.cpp index e6c858a1e3..92a33a2426 100644 --- a/yt/yt/core/rpc/dynamic_channel_pool.cpp +++ b/yt/yt/core/rpc/dynamic_channel_pool.cpp @@ -57,7 +57,7 @@ public: .EndMap())) , ServiceName_(std::move(serviceName)) , PeerDiscovery_(std::move(peerDiscovery)) - , Logger(RpcClientLogger.WithTag( + , Logger(RpcClientLogger().WithTag( "ChannelId: %v, Endpoint: %v, Service: %v", TGuid::Create(), EndpointDescription_, diff --git a/yt/yt/core/rpc/grpc/channel.cpp b/yt/yt/core/rpc/grpc/channel.cpp index 5fc956dd84..ee9d005184 100644 --- a/yt/yt/core/rpc/grpc/channel.cpp +++ b/yt/yt/core/rpc/grpc/channel.cpp @@ -246,7 +246,6 @@ private: , Request_(std::move(request)) , ResponseHandler_(std::move(responseHandler)) , GuardedCompletionQueue_(TDispatcher::Get()->PickRandomGuardedCompletionQueue()) - , Logger(GrpcLogger) { YT_LOG_DEBUG("Sending request (RequestId: %v, Method: %v.%v, Timeout: %v)", Request_->GetRequestId(), @@ -442,16 +441,15 @@ private: const TSendOptions Options_; const IClientRequestPtr Request_; + const NLogging::TLogger& Logger = GrpcLogger(); + YT_DECLARE_SPIN_LOCK(NThreading::TSpinLock, ResponseHandlerLock_); IClientResponseHandlerPtr ResponseHandler_; // Completion queue must be accessed under read lock // in order to prohibit creating new requests after shutting completion queue down. TGuardedGrpcCompletionQueue* GuardedCompletionQueue_; - const NLogging::TLogger& Logger; - NYT::NTracing::TTraceContextHandler TraceContext_; - TGrpcCallPtr Call_; TGrpcCallTracerPtr Tracer_; TSharedRefArray RequestBody_; diff --git a/yt/yt/core/rpc/grpc/dispatcher.cpp b/yt/yt/core/rpc/grpc/dispatcher.cpp index 09ce5386dc..a658619856 100644 --- a/yt/yt/core/rpc/grpc/dispatcher.cpp +++ b/yt/yt/core/rpc/grpc/dispatcher.cpp @@ -20,7 +20,7 @@ using namespace NConcurrency; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = GrpcLogger; +static constexpr auto& Logger = GrpcLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/grpc/private.h b/yt/yt/core/rpc/grpc/private.h index bfb0044fe0..78cad71744 100644 --- a/yt/yt/core/rpc/grpc/private.h +++ b/yt/yt/core/rpc/grpc/private.h @@ -26,7 +26,7 @@ inline const NProfiling::TProfiler GrpcServerProfiler("/grpc/server"); //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger GrpcLogger("Grpc"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, GrpcLogger, "Grpc"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/grpc/server.cpp b/yt/yt/core/rpc/grpc/server.cpp index 013f21d258..c005265d9b 100644 --- a/yt/yt/core/rpc/grpc/server.cpp +++ b/yt/yt/core/rpc/grpc/server.cpp @@ -68,7 +68,7 @@ class TServer { public: explicit TServer(TServerConfigPtr config) - : TServerBase(GrpcLogger.WithTag("GrpcServerId: %v", TGuid::Create())) + : TServerBase(GrpcLogger().WithTag("GrpcServerId: %v", TGuid::Create())) , Config_(std::move(config)) , ShutdownCookie_(RegisterShutdownCallback( "GrpcServer", diff --git a/yt/yt/core/rpc/hedging_channel.cpp b/yt/yt/core/rpc/hedging_channel.cpp index a75ed434d3..f5fb0dcbae 100644 --- a/yt/yt/core/rpc/hedging_channel.cpp +++ b/yt/yt/core/rpc/hedging_channel.cpp @@ -22,7 +22,7 @@ using namespace NConcurrency; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = RpcClientLogger; +static constexpr auto& Logger = RpcClientLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/local_channel.cpp b/yt/yt/core/rpc/local_channel.cpp index 3e2fe3cfea..11ffef2af1 100644 --- a/yt/yt/core/rpc/local_channel.cpp +++ b/yt/yt/core/rpc/local_channel.cpp @@ -30,7 +30,7 @@ using NYT::ToProto; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = RpcClientLogger; +static constexpr auto& Logger = RpcClientLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/local_server.cpp b/yt/yt/core/rpc/local_server.cpp index 910b4efe54..7c2c5f1307 100644 --- a/yt/yt/core/rpc/local_server.cpp +++ b/yt/yt/core/rpc/local_server.cpp @@ -11,7 +11,7 @@ class TLocalServer { public: TLocalServer() - : TServerBase(RpcServerLogger.WithTag("LocalServerId: %v", TGuid::Create())) + : TServerBase(RpcServerLogger().WithTag("LocalServerId: %v", TGuid::Create())) { } }; diff --git a/yt/yt/core/rpc/private.h b/yt/yt/core/rpc/private.h index 849f744cbf..963e542baf 100644 --- a/yt/yt/core/rpc/private.h +++ b/yt/yt/core/rpc/private.h @@ -10,8 +10,8 @@ namespace NYT::NRpc { //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger RpcServerLogger("RpcServer"); -inline const NLogging::TLogger RpcClientLogger("RpcClient"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, RpcServerLogger, "RpcServer"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, RpcClientLogger, "RpcClient"); inline const NProfiling::TProfiler RpcServerProfiler("/rpc/server"); inline const NProfiling::TProfiler RpcClientProfiler("/rpc/client"); diff --git a/yt/yt/core/rpc/retrying_channel.cpp b/yt/yt/core/rpc/retrying_channel.cpp index b9fd70a8cd..5e50f4e5bd 100644 --- a/yt/yt/core/rpc/retrying_channel.cpp +++ b/yt/yt/core/rpc/retrying_channel.cpp @@ -18,7 +18,7 @@ using namespace NConcurrency; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = RpcClientLogger; +static constexpr auto& Logger = RpcClientLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/unittests/handle_channel_failure_ut.cpp b/yt/yt/core/rpc/unittests/handle_channel_failure_ut.cpp index 23196016bc..fbd523cc63 100644 --- a/yt/yt/core/rpc/unittests/handle_channel_failure_ut.cpp +++ b/yt/yt/core/rpc/unittests/handle_channel_failure_ut.cpp @@ -7,10 +7,6 @@ namespace { //////////////////////////////////////////////////////////////////////////////// -const NLogging::TLogger Logger("HandleChannelFailureTest"); - -//////////////////////////////////////////////////////////////////////////////// - template <class TImpl> class THandleChannelFailureTestBase : public ::testing::Test diff --git a/yt/yt/core/rpc/unittests/roaming_channel_ut.cpp b/yt/yt/core/rpc/unittests/roaming_channel_ut.cpp index 5c1bb6024c..de5fdfbfc5 100644 --- a/yt/yt/core/rpc/unittests/roaming_channel_ut.cpp +++ b/yt/yt/core/rpc/unittests/roaming_channel_ut.cpp @@ -1,7 +1,5 @@ #include <yt/yt/core/test_framework/framework.h> -#include <yt/yt/core/logging/log.h> - #include <yt/yt/core/rpc/roaming_channel.h> #include <yt/yt/core/rpc/unittests/lib/common.h> @@ -11,10 +9,6 @@ namespace { //////////////////////////////////////////////////////////////////////////////// -const NLogging::TLogger Logger("RoamingChannelTest"); - -//////////////////////////////////////////////////////////////////////////////// - class TOneChannelProvider : public IRoamingChannelProvider { diff --git a/yt/yt/core/threading/private.h b/yt/yt/core/threading/private.h index c4a7e7e148..37f9048770 100644 --- a/yt/yt/core/threading/private.h +++ b/yt/yt/core/threading/private.h @@ -6,7 +6,7 @@ namespace NYT::NThreading { //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger ThreadingLogger("Threading"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, ThreadingLogger, "Threading"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/threading/thread.cpp b/yt/yt/core/threading/thread.cpp index 41688af355..e3222f8336 100644 --- a/yt/yt/core/threading/thread.cpp +++ b/yt/yt/core/threading/thread.cpp @@ -23,7 +23,7 @@ namespace NYT::NThreading { YT_DEFINE_THREAD_LOCAL(TThreadId, CurrentUniqueThreadId) ; static std::atomic<TThreadId> UniqueThreadIdGenerator; -static const auto& Logger = ThreadingLogger; +static constexpr auto& Logger = ThreadingLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/tracing/private.h b/yt/yt/core/tracing/private.h index 36ce19b9b4..cc9b13db0c 100644 --- a/yt/yt/core/tracing/private.h +++ b/yt/yt/core/tracing/private.h @@ -8,7 +8,7 @@ namespace NYT::NTracing { //////////////////////////////////////////////////////////////////////////////// -inline const NLogging::TLogger TracingLogger("Tracing"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, TracingLogger, "Tracing"); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/tracing/trace_context.cpp b/yt/yt/core/tracing/trace_context.cpp index 6feb04aed2..7e5b1140f1 100644 --- a/yt/yt/core/tracing/trace_context.cpp +++ b/yt/yt/core/tracing/trace_context.cpp @@ -37,7 +37,7 @@ using NYT::ToProto; //////////////////////////////////////////////////////////////////////////////// -static const auto& Logger = TracingLogger; +static constexpr auto& Logger = TracingLogger; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/yson/protobuf_interop.cpp b/yt/yt/core/yson/protobuf_interop.cpp index 855e4094fe..5900fe24d2 100644 --- a/yt/yt/core/yson/protobuf_interop.cpp +++ b/yt/yt/core/yson/protobuf_interop.cpp @@ -78,7 +78,7 @@ namespace { //////////////////////////////////////////////////////////////////////////////// -const NLogging::TLogger Logger("ProtobufInterop"); +YT_DEFINE_GLOBAL(const NLogging::TLogger, Logger, "ProtobufInterop"); //////////////////////////////////////////////////////////////////////////////// |