diff --git a/client/impl/ydb_internal/grpc_connections/grpc_connections.cpp b/client/impl/ydb_internal/grpc_connections/grpc_connections.cpp index d8c1982bc5f..7c68bbbe9a9 100644 --- a/client/impl/ydb_internal/grpc_connections/grpc_connections.cpp +++ b/client/impl/ydb_internal/grpc_connections/grpc_connections.cpp @@ -389,7 +389,7 @@ bool TGRpcConnectionsImpl::StartStatCollecting(NMonitoring::IMetricRegistry* sen if (auto ptr = dynamic_cast(sensorsRegistry)) { MetricRegistryPtr_ = ptr; } else { - Cerr << "Unknown IMetricRegistry impl" << Endl; + std::cerr << "Unknown IMetricRegistry impl" << std::endl; return false; } } diff --git a/client/impl/ydb_internal/retry/retry.h b/client/impl/ydb_internal/retry/retry.h index c89ec74e0cb..2695d379888 100644 --- a/client/impl/ydb_internal/retry/retry.h +++ b/client/impl/ydb_internal/retry/retry.h @@ -47,9 +47,9 @@ class TRetryContextBase : TNonCopyable { void LogRetry(const TStatus& status) { if (Settings_.Verbose_) { - Cerr << "Previous query attempt was finished with unsuccessful status " - << status.GetStatus() << ": " << status.GetIssues().ToString(true) << Endl; - Cerr << "Sending retry attempt " << RetryNumber_ << " of " << Settings_.MaxRetries_ << Endl; + std::cerr << "Previous query attempt was finished with unsuccessful status " + << ToString(status.GetStatus()) << ": " << status.GetIssues().ToString(true) << std::endl; + std::cerr << "Sending retry attempt " << RetryNumber_ << " of " << Settings_.MaxRetries_ << std::endl; } } diff --git a/client/ydb_coordination/coordination_ut.cpp b/client/ydb_coordination/coordination_ut.cpp index abeb1ce24ab..b2092045925 100644 --- a/client/ydb_coordination/coordination_ut.cpp +++ b/client/ydb_coordination/coordination_ut.cpp @@ -24,7 +24,7 @@ namespace { { Y_UNUSED(context); - Cerr << "ListEndpoints: " << request->ShortDebugString() << Endl; + std::cerr << "ListEndpoints: " << request->ShortDebugString() << std::endl; const auto* result = MockResults.FindPtr(request->database()); Y_ABORT_UNLESS(result, "Mock service doesn't have a result for database '%s'", request->database().c_str()); @@ -50,7 +50,7 @@ namespace { { Y_UNUSED(context); - Cerr << "Session stream started" << Endl; + std::cerr << "Session stream started" << std::endl; Ydb::Coordination::SessionRequest request; @@ -60,7 +60,7 @@ namespace { // Disconnected before the request was sent return grpc::Status::OK; } - Cerr << "Session request: " << request.ShortDebugString() << Endl; + std::cerr << "Session request: " << request.ShortDebugString() << std::endl; Y_ABORT_UNLESS(request.has_session_start(), "Expected session start"); auto& start = request.session_start(); uint64_t sessionId = start.session_id(); @@ -77,7 +77,7 @@ namespace { size_t pings_received = 0; while (stream->Read(&request)) { - Cerr << "Session request: " << request.ShortDebugString() << Endl; + std::cerr << "Session request: " << request.ShortDebugString() << std::endl; Y_ABORT_UNLESS(request.has_ping(), "Only ping requests are supported"); if (++pings_received <= 2) { // Only reply to the first 2 ping requests @@ -134,11 +134,11 @@ Y_UNIT_TEST_SUITE(Coordination) { // Start our mock discovery service ui16 discoveryPort = pm.GetPort(); - std::string discoveryAddr = TYdbStringBuilder() << "0.0.0.0:" << discoveryPort; + std::string discoveryAddr = TStringBuilder() << "0.0.0.0:" << discoveryPort; auto discoveryServer = StartGrpcServer(discoveryAddr, discoveryService); auto config = TDriverConfig() - .SetEndpoint(TYdbStringBuilder() << "localhost:" << discoveryPort) + .SetEndpoint(TStringBuilder() << "localhost:" << discoveryPort) .SetDatabase("/Root/My/DB"); TDriver driver(config); TClient client(driver); @@ -152,7 +152,7 @@ Y_UNIT_TEST_SUITE(Coordination) { auto endTimestamp = TInstant::Now(); auto elapsed = endTimestamp - startTimestamp; - Cerr << "Got: " << res.GetStatus() << ": " << res.GetIssues().ToString() << Endl; + std::cerr << "Got: " << ToString(res.GetStatus()) << ": " << res.GetIssues().ToString() << std::endl; // Both connection and session timeout return EStatus::TIMEOUT UNIT_ASSERT_VALUES_EQUAL_C(res.GetStatus(), EStatus::TIMEOUT, res.GetIssues().ToString()); @@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(Coordination) { TMockCoordinationService coordinationService; ui16 coordinationPort = pm.GetPort(); auto coordinationServer = StartGrpcServer( - TYdbStringBuilder() << "0.0.0.0:" << coordinationPort, + TStringBuilder() << "0.0.0.0:" << coordinationPort, coordinationService); // Fill a fake discovery service @@ -183,12 +183,12 @@ Y_UNIT_TEST_SUITE(Coordination) { // Start a fake discovery service ui16 discoveryPort = pm.GetPort(); auto discoveryServer = StartGrpcServer( - TYdbStringBuilder() << "0.0.0.0:" << discoveryPort, + TStringBuilder() << "0.0.0.0:" << discoveryPort, discoveryService); // Create a driver and a client auto config = TDriverConfig() - .SetEndpoint(TYdbStringBuilder() << "localhost:" << discoveryPort) + .SetEndpoint(TStringBuilder() << "localhost:" << discoveryPort) .SetDatabase("/Root/My/DB"); TDriver driver(config); TClient client(driver); @@ -197,7 +197,7 @@ Y_UNIT_TEST_SUITE(Coordination) { auto stoppedFuture = stoppedPromise.GetFuture(); auto settings = TSessionSettings() .OnStateChanged([](auto state) { - Cerr << "Session state: " << state << Endl; + std::cerr << "Session state: " << ToString(state) << std::endl; }) .OnStopped([stoppedPromise]() mutable { stoppedPromise.SetValue(); @@ -221,7 +221,7 @@ Y_UNIT_TEST_SUITE(Coordination) { // Check the last failure stored in a session auto res2 = session.Close().ExtractValueSync(); - Cerr << "Close: " << res2.GetStatus() << ": " << res2.GetIssues().ToString() << Endl; + std::cerr << "Close: " << ToString(res2.GetStatus()) << ": " << res2.GetIssues().ToString() << std::endl; UNIT_ASSERT_VALUES_EQUAL_C(res2.GetStatus(), EStatus::TIMEOUT, res2.GetIssues().ToString()); } @@ -232,7 +232,7 @@ Y_UNIT_TEST_SUITE(Coordination) { TMockCoordinationService coordinationService; ui16 coordinationPort = pm.GetPort(); auto coordinationServer = StartGrpcServer( - TYdbStringBuilder() << "0.0.0.0:" << coordinationPort, + TStringBuilder() << "0.0.0.0:" << coordinationPort, coordinationService); // Fill a fake discovery service @@ -247,12 +247,12 @@ Y_UNIT_TEST_SUITE(Coordination) { // Start a fake discovery service ui16 discoveryPort = pm.GetPort(); auto discoveryServer = StartGrpcServer( - TYdbStringBuilder() << "0.0.0.0:" << discoveryPort, + TStringBuilder() << "0.0.0.0:" << discoveryPort, discoveryService); // Create a driver and a client auto config = TDriverConfig() - .SetEndpoint(TYdbStringBuilder() << "localhost:" << discoveryPort) + .SetEndpoint(TStringBuilder() << "localhost:" << discoveryPort) .SetDatabase("/Root/My/DB"); std::optional driver(std::in_place, config); std::optional client(std::in_place, *driver); @@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(Coordination) { auto stoppedFuture = stoppedPromise.GetFuture(); auto settings = TSessionSettings() .OnStateChanged([](auto state) { - Cerr << "Session state: " << state << Endl; + std::cerr << "Session state: " << ToString(state) << std::endl; }) .OnStopped([stoppedPromise]() mutable { stoppedPromise.SetValue(); @@ -288,7 +288,7 @@ Y_UNIT_TEST_SUITE(Coordination) { // Check the last failure stored in a session auto res2 = session.Close().ExtractValueSync(); - Cerr << "Close: " << res2.GetStatus() << ": " << res2.GetIssues().ToString() << Endl; + std::cerr << "Close: " << ToString(res2.GetStatus()) << ": " << res2.GetIssues().ToString() << std::endl; UNIT_ASSERT_VALUES_EQUAL_C(res2.GetStatus(), EStatus::CLIENT_CANCELLED, res2.GetIssues().ToString()); } diff --git a/client/ydb_driver/driver_ut.cpp b/client/ydb_driver/driver_ut.cpp index b67963c4f16..e0d50d13b1a 100644 --- a/client/ydb_driver/driver_ut.cpp +++ b/client/ydb_driver/driver_ut.cpp @@ -29,7 +29,7 @@ namespace { { Y_UNUSED(context); - Cerr << "ListEndpoints: " << request->ShortDebugString() << Endl; + std::cerr << "ListEndpoints: " << request->ShortDebugString() << std::endl; const auto* result = MockResults.FindPtr(request->database()); Y_ABORT_UNLESS(result, "Mock service doesn't have a result for database '%s'", request->database().c_str()); @@ -54,7 +54,7 @@ namespace { { Y_UNUSED(context); - Cerr << "CreateSession: " << request->ShortDebugString() << Endl; + std::cerr << "CreateSession: " << request->ShortDebugString() << std::endl; Ydb::Table::CreateSessionResult result; result.set_session_id("my-session-id"); @@ -127,9 +127,9 @@ Y_UNIT_TEST_SUITE(CppGrpcClientSimpleTest) { }; std::vector InvalidTokens = { - std::string('\t'), - std::string('\n'), - std::string('\r') + std::string("\t"), + std::string("\n"), + std::string("\r") }; for (auto& t : InvalidTokens) { UNIT_ASSERT_EQUAL(checkToken(t), EStatus::CLIENT_UNAUTHENTICATED); @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(CppGrpcClientSimpleTest) { TMockTableService tableService; ui16 tablePort = pm.GetPort(); auto tableServer = StartGrpcServer( - TYdbStringBuilder() << "127.0.0.1:" << tablePort, + TStringBuilder() << "127.0.0.1:" << tablePort, tableService); // Start our mock discovery service @@ -165,12 +165,12 @@ Y_UNIT_TEST_SUITE(CppGrpcClientSimpleTest) { } ui16 discoveryPort = pm.GetPort(); auto discoveryServer = StartGrpcServer( - TYdbStringBuilder() << "0.0.0.0:" << discoveryPort, + TStringBuilder() << "0.0.0.0:" << discoveryPort, discoveryService); auto driver = TDriver( TDriverConfig() - .SetEndpoint(TYdbStringBuilder() << "localhost:" << discoveryPort) + .SetEndpoint(TStringBuilder() << "localhost:" << discoveryPort) .SetDatabase("/Root/My/DB")); auto client = NTable::TTableClient(driver); auto sessionFuture = client.CreateSession(); diff --git a/client/ydb_federated_topic/ut/basic_usage_ut.cpp b/client/ydb_federated_topic/ut/basic_usage_ut.cpp index 77115390441..b5d9bbe8d31 100644 --- a/client/ydb_federated_topic/ut/basic_usage_ut.cpp +++ b/client/ydb_federated_topic/ut/basic_usage_ut.cpp @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // Create topic client. NYdb::TDriverConfig cfg; - cfg.SetEndpoint(TYdbStringBuilder() << "localhost:" << newServicePort); + cfg.SetEndpoint(TStringBuilder() << "localhost:" << newServicePort); cfg.SetDatabase("/Root"); cfg.SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG)); NYdb::TDriver driver(cfg); @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .AppendTopics(setup->GetTestTopic()); ReadSession = topicClient.CreateReadSession(readSettings); - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; ReadSession->WaitEvent().Wait(TDuration::Seconds(1)); std::optional event = ReadSession->GetEvent(false); @@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { ReadSession->WaitEvent().Wait(); // Get event std::optional event = ReadSession->GetEvent(true/*block - will block if no event received yet*/); - Cerr << "Got new read session event: " << DebugString(*event) << Endl; + std::cerr << "Got new read session event: " << DebugString(*event) << std::endl; auto* startPartitionSessionEvent = std::get_if(&*event); Y_ASSERT(startPartitionSessionEvent); @@ -122,7 +122,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // Create topic client. NYdb::TDriverConfig cfg; - cfg.SetEndpoint(TYdbStringBuilder() << "localhost:" << newServicePort); + cfg.SetEndpoint(TStringBuilder() << "localhost:" << newServicePort); cfg.SetDatabase("/Root"); cfg.SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG)); NYdb::TDriver driver(cfg); @@ -135,19 +135,19 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .MaxMemoryUsageBytes(1_MB) .AppendTopics(setup->GetTestTopic()); - Cerr << "Before ReadSession was created" << Endl; + std::cerr << "Before ReadSession was created" << std::endl; ReadSession = topicClient.CreateReadSession(readSettings); - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; auto f = ReadSession->WaitEvent(); - Cerr << "Returned from WaitEvent" << Endl; + std::cerr << "Returned from WaitEvent" << std::endl; // observer asyncInit should respect client/session timeouts UNIT_ASSERT(!f.Wait(TDuration::Seconds(1))); - Cerr << "Session blocked successfully" << Endl; + std::cerr << "Session blocked successfully" << std::endl; UNIT_ASSERT(ReadSession->Close(TDuration::MilliSeconds(10))); - Cerr << "Session closed gracefully" << Endl; + std::cerr << "Session closed gracefully" << std::endl; } Y_UNIT_TEST(RetryDiscoveryWithCancel) { @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // Create topic client. NYdb::TDriverConfig cfg; - cfg.SetEndpoint(TYdbStringBuilder() << "localhost:" << newServicePort); + cfg.SetEndpoint(TStringBuilder() << "localhost:" << newServicePort); cfg.SetDatabase("/Root"); cfg.SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG)); NYdb::TDriver driver(cfg); @@ -211,7 +211,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // Create topic client. NYdb::TDriverConfig cfg; - cfg.SetEndpoint(TYdbStringBuilder() << "localhost:" << newServicePort); + cfg.SetEndpoint(TStringBuilder() << "localhost:" << newServicePort); cfg.SetDatabase("/Root"); cfg.SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG)); NYdb::TDriver driver(cfg); @@ -231,7 +231,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .AppendTopics(setup->GetTestTopic()); ReadSession = topicClient.CreateReadSession(readSettings); - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; Sleep(TDuration::MilliSeconds(50)); @@ -296,7 +296,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { UNIT_ASSERT(!events.empty()); for (auto& e : events) { - Cerr << ">>> Got event: " << DebugString(e) << Endl; + std::cerr << ">>> Got event: " << DebugString(e) << std::endl; if (auto* dataEvent = std::get_if(&e)) { dataEvent->Commit(); } else if (auto* startPartitionSessionEvent = std::get_if(&e)) { @@ -326,7 +326,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // Create topic client. NYdb::TDriverConfig cfg; - cfg.SetEndpoint(TYdbStringBuilder() << "localhost:" << newServicePort); + cfg.SetEndpoint(TStringBuilder() << "localhost:" << newServicePort); cfg.SetDatabase("/Root"); cfg.SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG)); NYdb::TDriver driver(cfg); @@ -343,11 +343,11 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .AppendTopics(setup->GetTestTopic()); ReadSession = topicClient.CreateReadSession(readSettings); - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; ReadSession->WaitEvent().Wait(TDuration::Seconds(1)); auto event = ReadSession->GetEvent(false); - UNIT_ASSERT(!event.Defined()); + UNIT_ASSERT(!event.has_value()); std::optional fdsRequest; @@ -362,16 +362,16 @@ Y_UNIT_TEST_SUITE(BasicUsage) { ReadSession->WaitEvent().Wait(); event = ReadSession->GetEvent(false); - UNIT_ASSERT(event.Defined()); - Cerr << ">>> Got event: " << DebugString(*event) << Endl; + UNIT_ASSERT(event.has_value()); + std::cerr << ">>> Got event: " << DebugString(*event) << std::endl; UNIT_ASSERT(std::holds_alternative(*event)); auto ReadSession2 = topicClient.CreateReadSession(readSettings); - Cerr << "Session2 was created" << Endl; + std::cerr << "Session2 was created" << std::endl; ReadSession2->WaitEvent().Wait(TDuration::Seconds(1)); event = ReadSession2->GetEvent(false); - UNIT_ASSERT(!event.Defined()); + UNIT_ASSERT(!event.has_value()); do { fdsRequest = fdsMock.GetNextPendingRequest(); @@ -383,11 +383,11 @@ Y_UNIT_TEST_SUITE(BasicUsage) { fdsRequest->Result.SetValue(fdsMock.ComposeOkResult()); event = ReadSession2->GetEvent(true); - UNIT_ASSERT(event.Defined()); - Cerr << ">>> Got event: " << DebugString(*event) << Endl; + UNIT_ASSERT(event.has_value()); + std::cerr << ">>> Got event: " << DebugString(*event) << std::endl; UNIT_ASSERT(std::holds_alternative(*event)); - // Cerr << ">>> Got event: " << DebugString(*event) << Endl; + // std::cerr << ">>> Got event: " << DebugString(*event) << std::endl; // UNIT_ASSERT(std::holds_alternative(*event)); } @@ -408,12 +408,12 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .AppendTopics(setup->GetTestTopic()); ReadSession = topicClient.CreateReadSession(readSettings); - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; ReadSession->WaitEvent().Wait(TDuration::Seconds(1)); std::optional event = ReadSession->GetEvent(false); Y_ASSERT(event); - Cerr << "Got new read session event: " << DebugString(*event) << Endl; + std::cerr << "Got new read session event: " << DebugString(*event) << std::endl; auto* startPartitionSessionEvent = std::get_if(&*event); Y_ASSERT(startPartitionSessionEvent); @@ -436,7 +436,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // Create topic client. NYdb::TDriverConfig cfg; - cfg.SetEndpoint(TYdbStringBuilder() << "localhost:" << newServicePort); + cfg.SetEndpoint(TStringBuilder() << "localhost:" << newServicePort); cfg.SetDatabase("/Root"); cfg.SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG)); NYdb::TDriver driver(cfg); @@ -471,7 +471,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .AppendTopics(setup->GetTestTopic()); readSettings.FederatedEventHandlers_.SimpleDataHandlers([&](TReadSessionEvent::TDataReceivedEvent& ev) mutable { - Cerr << ">>> event from dataHandler: " << DebugString(ev) << Endl; + std::cerr << ">>> event from dataHandler: " << DebugString(ev) << std::endl; Y_VERIFY_S(AtomicGet(check) != 0, "check is false"); auto& messages = ev.GetMessages(); for (size_t i = 0u; i < messages.size(); ++i) { @@ -484,7 +484,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { }); ReadSession = topicClient.CreateReadSession(readSettings); - Cerr << ">>> Session was created" << Endl; + std::cerr << ">>> Session was created" << std::endl; Sleep(TDuration::MilliSeconds(50)); @@ -548,12 +548,12 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .MessageGroupId("src_id"); WriteSession = topicClient.CreateWriteSession(writeSettings); - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; WriteSession->WaitEvent().Wait(TDuration::Seconds(1)); auto event = WriteSession->GetEvent(false); Y_ASSERT(event); - Cerr << "Got new read session event: " << DebugString(*event) << Endl; + std::cerr << "Got new read session event: " << DebugString(*event) << std::endl; auto* readyToAcceptEvent = std::get_if(&*event); Y_ASSERT(readyToAcceptEvent); WriteSession->Write(std::move(readyToAcceptEvent->ContinuationToken), NTopic::TWriteMessage("hello")); @@ -561,7 +561,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { WriteSession->WaitEvent().Wait(TDuration::Seconds(1)); event = WriteSession->GetEvent(false); Y_ASSERT(event); - Cerr << "Got new read session event: " << DebugString(*event) << Endl; + std::cerr << "Got new read session event: " << DebugString(*event) << std::endl; readyToAcceptEvent = std::get_if(&*event); Y_ASSERT(readyToAcceptEvent); @@ -579,7 +579,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { WriteSession->WaitEvent().Wait(TDuration::Seconds(1)); event = WriteSession->GetEvent(false); Y_ASSERT(event); - Cerr << "Got new read session event: " << DebugString(*event) << Endl; + std::cerr << "Got new read session event: " << DebugString(*event) << std::endl; auto* acksEvent = std::get_if(&*event); Y_ASSERT(acksEvent); diff --git a/client/ydb_federated_topic/ut/fds_mock.h b/client/ydb_federated_topic/ut/fds_mock.h index 1ed05a80f11..118d6c5c88b 100644 --- a/client/ydb_federated_topic/ut/fds_mock.h +++ b/client/ydb_federated_topic/ut/fds_mock.h @@ -61,7 +61,7 @@ class TFederationDiscoveryServiceMock: public Ydb::FederationDiscovery::V1::Fede f.Wait(TDuration::Seconds(35)); if (f.HasValue()) { auto result = f.ExtractValueSync(); - Cerr << ">>> Ready to answer: " << (result.Status.ok() ? "ok" : "err") << Endl; + std::cerr << ">>> Ready to answer: " << (result.Status.ok() ? "ok" : "err") << std::endl; *response = std::move(result.Response); return result.Status; } diff --git a/client/ydb_persqueue_core/impl/write_session_impl.cpp b/client/ydb_persqueue_core/impl/write_session_impl.cpp index 65abba46471..3d3aa4b216e 100644 --- a/client/ydb_persqueue_core/impl/write_session_impl.cpp +++ b/client/ydb_persqueue_core/impl/write_session_impl.cpp @@ -831,10 +831,10 @@ bool TWriteSessionImpl::CleanupOnAcknowledged(ui64 id) { LOG_LAZY(DbDriverState->Log, TLOG_DEBUG, LogPrefix() << "Write session: acknoledged message " << id); UpdateTimedCountersImpl(); if (SentOriginalMessages.empty() || SentOriginalMessages.front().Id != id){ - Cerr << "State before restart was:\n" << StateStr << "\n\n"; + std::cerr << "State before restart was:\n" << StateStr << "\n\n"; DumpState(); - Cerr << "State on ack with id " << id << " is:\n"; - Cerr << StateStr << "\n\n"; + std::cerr << "State on ack with id " << id << " is:\n"; + std::cerr << StateStr << "\n\n"; Y_ABORT("got unknown ack"); } @@ -1098,9 +1098,9 @@ bool TWriteSessionImpl::IsReadyToSendNextImpl() { Y_ABORT_UNLESS(!OriginalMessagesToSend.empty(), "There are packed messages but no original messages"); if (OriginalMessagesToSend.front().Id > PackedMessagesToSend.top().Offset) { - Cerr << " State before restart was:\n" << StateStr << "\n\n"; + std::cerr << " State before restart was:\n" << StateStr << "\n\n"; DumpState(); - Cerr << " State after restart is:\n" << StateStr << "\n\n"; + std::cerr << " State after restart is:\n" << StateStr << "\n\n"; Y_ABORT("Lost original message(s)"); } diff --git a/client/ydb_persqueue_core/ut/basic_usage_ut.cpp b/client/ydb_persqueue_core/ut/basic_usage_ut.cpp index b62790a701f..1f5556e40b9 100644 --- a/client/ydb_persqueue_core/ut/basic_usage_ut.cpp +++ b/client/ydb_persqueue_core/ut/basic_usage_ut.cpp @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { ui32 previousOffset = 0; bool closed = false; while ((readMessageCount < messageCount || committedOffset <= previousOffset) && !closed) { - Cerr << "Get event on client\n"; + std::cerr << "Get event on client\n"; auto event = *readSession->GetEvent(true); std::visit(TOverloaded { [&](TReadSessionEvent::TDataReceivedEvent& event) { @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { if (shouldCaptureData.has_value()) { TYdbStringBuilder msg; msg << "Session has captured " << sessionAdapter.GetAcquiredMessagesCount() - << " messages, capturing was expected: " << *shouldCaptureData << Endl; + << " messages, capturing was expected: " << *shouldCaptureData << std::endl; UNIT_ASSERT_VALUES_EQUAL_C(sessionAdapter.GetAcquiredMessagesCount() > 0, *shouldCaptureData, msg.c_str()); } } @@ -329,7 +329,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { oss << message; } - Cerr << message << " " << packed << "\n"; + std::cerr << message << " " << packed << "\n"; { auto event = *writer->GetEvent(true); @@ -364,7 +364,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { } ++tokens; } - Cerr << "GOT EVENT " << acks << " " << tokens << "\n"; + std::cerr << "GOT EVENT " << acks << " " << tokens << "\n"; } UNIT_ASSERT(!writer->WaitEvent().Wait(TDuration::Seconds(5))); @@ -377,7 +377,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { ); ui32 readMessageCount = 0; while (readMessageCount < 4) { - Cerr << "Get event on client\n"; + std::cerr << "Get event on client\n"; auto event = *readSession->GetEvent(true); std::visit(TOverloaded { [&](TReadSessionEvent::TDataReceivedEvent& event) { @@ -481,7 +481,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .RetryPolicy(IRetryPolicy::GetNoRetryPolicy()); std::shared_ptr readSession = client.CreateReadSession(settings); - Cerr << "Get event on client\n"; + std::cerr << "Get event on client\n"; auto event = *readSession->GetEvent(true); std::visit(TOverloaded { [&](TReadSessionEvent::TDataReceivedEvent&) { @@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { UNIT_FAIL("Test does not support lock sessions yet"); }, [&](TSessionClosedEvent& event) { - Cerr << "Got close event: " << event.DebugString(); + std::cerr << "Got close event: " << event.DebugString(); } }, event); diff --git a/client/ydb_persqueue_core/ut/compress_executor_ut.cpp b/client/ydb_persqueue_core/ut/compress_executor_ut.cpp index da4bcde9c72..c79d2b7daa7 100644 --- a/client/ydb_persqueue_core/ut/compress_executor_ut.cpp +++ b/client/ydb_persqueue_core/ut/compress_executor_ut.cpp @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(CompressExecutor) { UNIT_ASSERT(!f1.HasValue()); UNIT_ASSERT(!f2.HasValue()); queue->Enqueue(1); - Cerr << "Waiting for writes to complete.\n"; + std::cerr << "Waiting for writes to complete.\n"; f1.Wait(); f2.Wait(); @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(CompressExecutor) { Y_ABORT("ANother ready to accept!"); } if(std::holds_alternative(event)) { - Cerr << "Session closed: " << std::get(event).DebugString() << "\n"; + std::cerr << "Session closed: " << std::get(event).DebugString() << "\n"; Y_ABORT(""); } } @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(CompressExecutor) { event = *writer->GetEvent(true); UNIT_ASSERT(std::holds_alternative(event)); - Cerr << "===Will now kick tablets\n"; + std::cerr << "===Will now kick tablets\n"; setup->KickTablets(); retryPolicy->ExpectBreakDown(); retryPolicy->WaitForRetriesSync(1); @@ -92,7 +92,7 @@ Y_UNIT_TEST_SUITE(CompressExecutor) { continueToken = std::move(std::get(event).ContinuationToken); } } - Cerr << "============ UT - Wait event...\n"; + std::cerr << "============ UT - Wait event...\n"; waitEventFuture = writer->WaitEvent(); waitEventFuture.Wait(TDuration::Seconds(3)); UNIT_ASSERT(!waitEventFuture.HasValue()); diff --git a/client/ydb_persqueue_core/ut/compression_ut.cpp b/client/ydb_persqueue_core/ut/compression_ut.cpp index 834498bba51..cab143c39a8 100644 --- a/client/ydb_persqueue_core/ut/compression_ut.cpp +++ b/client/ydb_persqueue_core/ut/compression_ut.cpp @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(Compression) { UNIT_ASSERT(status.ok()); Ydb::PersQueue::V1::AlterTopicResult result; response.operation().result().UnpackTo(&result); - Cerr << "Alter topic response: " << response << "\nAlter result: " << result << "\n"; + std::cerr << "Alter topic response: " << response << "\nAlter result: " << result << "\n"; UNIT_ASSERT_VALUES_EQUAL(response.operation().status(), Ydb::StatusIds::SUCCESS); } @@ -78,14 +78,14 @@ Y_UNIT_TEST_SUITE(Compression) { const std::vector codecs, bool decompress ) { - Cerr << Endl << "Start read" << Endl << Endl; + std::cerr << std::endl << "Start read" << std::endl << std::endl; auto readSettings = setup.GetReadSessionSettings(); readSettings.Decompress(decompress); NThreading::TPromise checkedPromise = NThreading::NewPromise(); auto totalReceived = 0u; readSettings.EventHandlers_.SimpleDataHandlers( [&](const NYdb::NPersQueue::TReadSessionEvent::TDataReceivedEvent& ev) { - Cerr << Endl << Endl << Endl << "Got messages" << Endl << Endl; + std::cerr << std::endl << std::endl << std::endl << "Got messages" << std::endl << std::endl; if (decompress) { UNIT_ASSERT_NO_EXCEPTION(ev.GetMessages()); UNIT_ASSERT_EXCEPTION(ev.GetCompressedMessages(), yexception); @@ -102,7 +102,7 @@ Y_UNIT_TEST_SUITE(Compression) { ++totalReceived; } } - Cerr << Endl << "totalReceived: " << totalReceived << " wait: " << messages.size() << Endl << Endl; + std::cerr << std::endl << "totalReceived: " << totalReceived << " wait: " << messages.size() << std::endl << std::endl; if (totalReceived == messages.size()) checkedPromise.SetValue(); } diff --git a/client/ydb_persqueue_core/ut/read_session_ut.cpp b/client/ydb_persqueue_core/ut/read_session_ut.cpp index 0d681aa6b51..8117e7e7114 100644 --- a/client/ydb_persqueue_core/ut/read_session_ut.cpp +++ b/client/ydb_persqueue_core/ut/read_session_ut.cpp @@ -526,7 +526,7 @@ class TReorderingExecutor : public ::IExecutor { void Post(TFunction&& f) override { { std::lock_guard guard(Lock); - Cerr << "Post function" << Endl; + std::cerr << "Post function" << std::endl; ++TasksAdded; if (Functions.empty()) { Functions.reserve(CycleCount); @@ -686,7 +686,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { UNIT_ASSERT(event); UNIT_ASSERT_EVENT_TYPE(*event, TReadSessionEvent::TCreatePartitionStreamEvent); std::get(*event).Confirm(); - Cerr << "create event " << DebugString(*event) << Endl; + std::cerr << "create event " << DebugString(*event) << std::endl; } // Event 2: data. { @@ -698,7 +698,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { for (auto& msg : dataEvent.GetMessages()) { UNIT_ASSERT(msg.GetData() == "message1" || msg.GetData() == "message2"); } - Cerr << "data event " << DebugString(*event) << Endl; + std::cerr << "data event " << DebugString(*event) << std::endl; if (commit) { dc.Add(dataEvent); } @@ -714,7 +714,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { for (auto& msg : dataEvent.GetMessages()) { UNIT_ASSERT(msg.GetData() == "message3"); } - Cerr << "data event " << DebugString(*event) << Endl; + std::cerr << "data event " << DebugString(*event) << std::endl; dataEvent.Commit(); // Commit right now! } @@ -729,14 +729,14 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { if (commit) { // (commit && close) branch check is broken with current TReadSession::Close quick fix std::optional event = session->GetEvent(!close); // Event is expected to be already in queue if closed. UNIT_ASSERT(event); - Cerr << "commit ack or close event " << DebugString(*event) << Endl; + std::cerr << "commit ack or close event " << DebugString(*event) << std::endl; UNIT_ASSERT(std::holds_alternative(*event) || std::holds_alternative(*event)); } if (close && !commit) { std::optional event = session->GetEvent(false); UNIT_ASSERT(event); - Cerr << "close event " << DebugString(*event) << Endl; + std::cerr << "close event " << DebugString(*event) << std::endl; UNIT_ASSERT(std::holds_alternative(*event)); UNIT_ASSERT_STRING_CONTAINS(DebugString(*event), "Session was gracefully closed"); } @@ -769,7 +769,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { std::optional event = \ session->GetEvent(true); \ UNIT_ASSERT(event); \ - Cerr << DebugString(*event) << Endl; \ + std::cerr << DebugString(*event) << std::endl; \ UNIT_ASSERT_EVENT_TYPE(*event, TSessionClosedEvent); \ /**/ @@ -805,7 +805,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { std::shared_ptr session = setup.GetPersQueueClient().CreateReadSession(settings); std::optional event = session->GetEvent(true); UNIT_ASSERT(event); - Cerr << DebugString(*event) << Endl; + std::cerr << DebugString(*event) << std::endl; UNIT_ASSERT_EVENT_TYPE(*event, TSessionClosedEvent); } @@ -820,7 +820,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { std::shared_ptr session = setup.GetPersQueueClient().CreateReadSession(settings); std::optional event = session->GetEvent(true); UNIT_ASSERT(event); - Cerr << DebugString(*event) << Endl; + std::cerr << DebugString(*event) << std::endl; UNIT_ASSERT_NOT_EVENT_TYPE(*event, TSessionClosedEvent); } @@ -830,7 +830,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { std::shared_ptr session = setup.GetPersQueueClient().CreateReadSession(settings); std::optional event = session->GetEvent(true); UNIT_ASSERT(event); - Cerr << DebugString(*event) << Endl; + std::cerr << DebugString(*event) << std::endl; UNIT_ASSERT_EVENT_TYPE(*event, TSessionClosedEvent); } @@ -840,7 +840,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { std::shared_ptr session = setup.GetPersQueueClient().CreateReadSession(settings); std::optional event = session->GetEvent(true); UNIT_ASSERT(event); - Cerr << DebugString(*event) << Endl; + std::cerr << DebugString(*event) << std::endl; UNIT_ASSERT_EVENT_TYPE(*event, TSessionClosedEvent); } } @@ -856,7 +856,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { UNIT_ASSERT(event); UNIT_ASSERT_EVENT_TYPE(*event, TReadSessionEvent::TCreatePartitionStreamEvent); std::get(*event).Confirm(); - Cerr << DebugString(*event) << Endl; + std::cerr << DebugString(*event) << std::endl; } // Event 2: receive data. @@ -867,7 +867,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { TReadSessionEvent::TDataReceivedEvent& dataEvent = std::get(*event); UNIT_ASSERT_VALUES_EQUAL(dataEvent.GetMessages().size(), 1); UNIT_ASSERT_VALUES_EQUAL(dataEvent.GetMessages()[0].GetData(), content); - Cerr << DebugString(*event) << Endl; + std::cerr << DebugString(*event) << std::endl; return event; }; @@ -893,7 +893,7 @@ Y_UNIT_TEST_SUITE(PersQueueSdkReadSessionTest) { std::optional event = session->GetEvent(true); UNIT_ASSERT(event); Y_ASSERT(std::holds_alternative(*event)); - Cerr << DebugString(*event) << Endl; + std::cerr << DebugString(*event) << std::endl; } auto eventFuture = session->WaitEvent(); @@ -1221,7 +1221,7 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) { UNIT_ASSERT(event); UNIT_ASSERT_EVENT_TYPE(*event, TReadSessionEvent::TDataReceivedEvent); auto& dataEvent = std::get(*event); - Cerr << dataEvent.DebugString() << "\n"; + std::cerr << dataEvent.DebugString() << "\n"; UNIT_ASSERT_VALUES_EQUAL(dataEvent.GetMessages().size(), 3); UNIT_ASSERT_EXCEPTION(dataEvent.GetMessages()[0].GetData(), TZLibDecompressorError); UNIT_ASSERT_VALUES_EQUAL(dataEvent.GetMessages()[1].GetData(), "message2"); @@ -1316,8 +1316,8 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) { const std::string messageData = GenerateMessageData(messageSize); const std::string compressedMessageData = Compress(messageData); - Cerr << "Message data size: " << messageData.size() << Endl; - Cerr << "Compressed message data size: " << compressedMessageData.size() << Endl; + std::cerr << "Message data size: " << messageData.size() << std::endl; + std::cerr << "Compressed message data size: " << compressedMessageData.size() << std::endl; ui64 offset = 1; ui64 seqNo = 42; THashSet committedCookies; @@ -1328,7 +1328,7 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) { committedCookies.insert(commit.partition_cookie()); } for (const auto& range : req.offset_ranges()) { - Cerr << "GOT RANGE " << range.start_offset() << " " << range.end_offset() << "\n"; + std::cerr << "GOT RANGE " << range.start_offset() << " " << range.end_offset() << "\n"; for (ui64 i = range.start_offset(); i < range.end_offset(); ++i) { committedOffsets.insert(i); } @@ -1350,11 +1350,11 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) { ui64 prevOffset = 0; ui64 prevSeqNo = 41; for (size_t i = 0; i < batches; ++i) { - Cerr << "Getting new event" << Endl; + std::cerr << "Getting new event" << std::endl; std::optional event = setup.EventsQueue->GetEvent(true, batchLimit); UNIT_ASSERT(event); UNIT_ASSERT_EVENT_TYPE(*event, TReadSessionEvent::TDataReceivedEvent); - Cerr << DebugString(*event) << Endl; + std::cerr << DebugString(*event) << std::endl; auto& dataEvent = std::get(*event); UNIT_ASSERT_VALUES_EQUAL(dataEvent.GetMessages().size(), messagesInBatch); for (const auto& message : dataEvent.GetMessages()) { @@ -1563,7 +1563,7 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) { bool has2 = false; EXPECT_CALL(*setup.MockProcessor, OnCommitRequest(_)) .WillRepeatedly(Invoke([&](const Ydb::PersQueue::V1::MigrationStreamingReadClientMessage::Commit& req) { - Cerr << "Got commit req " << req << "\n"; + std::cerr << "Got commit req " << req << "\n"; for (const auto& commit : req.cookies()) { if (commit.partition_cookie() == 1) { has1 = true; @@ -1574,7 +1574,7 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) { } } for (const auto& range : req.offset_ranges()) { - Cerr << "RANGE " << range.start_offset() << " " << range.end_offset() << "\n"; + std::cerr << "RANGE " << range.start_offset() << " " << range.end_offset() << "\n"; if (range.start_offset() == 10 && range.end_offset() == 12) has1 = true; else if (range.start_offset() == 0 && range.end_offset() == 10) has2 = true; else UNIT_ASSERT(false); @@ -1586,7 +1586,7 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) { UNIT_ASSERT(event); UNIT_ASSERT_EVENT_TYPE(*event, TReadSessionEvent::TDataReceivedEvent); TReadSessionEvent::TDataReceivedEvent& dataEvent = std::get(*event); - Cerr << "got data event: " << dataEvent.DebugString() << "\n"; + std::cerr << "got data event: " << dataEvent.DebugString() << "\n"; dataEvent.Commit(); i += dataEvent.GetMessagesCount(); @@ -1628,7 +1628,7 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) { settings.EventHandlers_.SimpleDataHandlers([&](TReadSessionEvent::TDataReceivedEvent& event) { for (auto& message: event.GetMessages()) { ++time; - Cerr << "GOT MESSAGE: " << message.DebugString(true) << "\n"; + std::cerr << "GOT MESSAGE: " << message.DebugString(true) << "\n"; UNIT_ASSERT_VALUES_EQUAL(message.GetData(), TYdbStringBuilder() << "message" << time); if (time == 3) { calledPromise.SetValue(); diff --git a/client/ydb_persqueue_core/ut/retry_policy_ut.cpp b/client/ydb_persqueue_core/ut/retry_policy_ut.cpp index 58cb669963b..3c5251dd5e4 100644 --- a/client/ydb_persqueue_core/ut/retry_policy_ut.cpp +++ b/client/ydb_persqueue_core/ut/retry_policy_ut.cpp @@ -19,9 +19,9 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { auto doBreakDown = [&] () { helper.Policy->ExpectBreakDown(); NThreading::TPromise retriesPromise = NThreading::NewPromise(); - Cerr << "WAIT for retries...\n"; + std::cerr << "WAIT for retries...\n"; helper.Policy->WaitForRetries(30, retriesPromise); - Cerr << "KICK tablets\n"; + std::cerr << "KICK tablets\n"; helper.Setup->KickTablets(); auto f1 = helper.Write(false); @@ -29,19 +29,19 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { auto retriesFuture = retriesPromise.GetFuture(); retriesFuture.Wait(); - Cerr << "WAIT for retries done\n"; + std::cerr << "WAIT for retries done\n"; NThreading::TPromise repairPromise = NThreading::NewPromise(); auto repairFuture = repairPromise.GetFuture(); helper.Policy->WaitForRepair(repairPromise); - Cerr << "ALLOW tablets\n"; + std::cerr << "ALLOW tablets\n"; helper.Setup->AllowTablets(); - Cerr << "WAIT for repair\n"; + std::cerr << "WAIT for repair\n"; repairFuture.Wait(); - Cerr << "REPAIR done\n"; + std::cerr << "REPAIR done\n"; f1.Wait(); f2.Wait(); helper.Write(true); @@ -82,29 +82,29 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { retryPolicy->ExpectBreakDown(); auto& client = setup1->GetPersQueueClient(); - Cerr << "=== Create write session \n"; + std::cerr << "=== Create write session \n"; auto writer = client.CreateWriteSession(settings); NThreading::TPromise retriesPromise = NThreading::NewPromise(); auto retriesFuture = retriesPromise.GetFuture(); retryPolicy->WaitForRetries(3, retriesPromise); - Cerr << "=== Wait retries\n"; + std::cerr << "=== Wait retries\n"; retriesFuture.Wait(); - Cerr << "=== Enable dc2\n"; + std::cerr << "=== Enable dc2\n"; setup1->EnableDataCenter("dc2"); NThreading::TPromise repairPromise = NThreading::NewPromise(); auto repairFuture = repairPromise.GetFuture(); retryPolicy->WaitForRepair(repairPromise); - Cerr << "=== Wait for repair\n"; + std::cerr << "=== Wait for repair\n"; repairFuture.Wait(); - Cerr << "=== Close writer\n"; + std::cerr << "=== Close writer\n"; writer->Close(); } Y_UNIT_TEST(TWriteSession_SwitchBackToLocalCluster) { - Cerr << "====Start test\n"; + std::cerr << "====Start test\n"; auto setup1 = std::make_shared(TEST_CASE_NAME, false); SDKTestSetup setup2("SwitchBackToLocalCluster", false); @@ -113,14 +113,14 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { setup1->AddDataCenter("dc2", setup2, true); setup1->Start(); setup2.Start(false); - Cerr << "=== Start session 1\n"; + std::cerr << "=== Start session 1\n"; auto helper = MakeHolder("", nullptr, std::string(), setup1); helper->Write(true); auto retryPolicy = helper->Policy; retryPolicy->Initialize(); auto waitForReconnect = [&](bool enable) { - Cerr << "=== Expect breakdown\n"; + std::cerr << "=== Expect breakdown\n"; retryPolicy->ExpectBreakDown(); NThreading::TPromise retriesPromise = NThreading::NewPromise(); @@ -132,11 +132,11 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { retryPolicy->WaitForRepair(repairPromise); if (enable) { - Cerr << "===Enabled DC1\n"; + std::cerr << "===Enabled DC1\n"; setup1->EnableDataCenter("dc1"); setup2.EnableDataCenter("dc1"); } else { - Cerr << "===Disabled DC1\n"; + std::cerr << "===Disabled DC1\n"; setup1->DisableDataCenter("dc1"); setup2.DisableDataCenter("dc1"); } @@ -145,9 +145,9 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { retriesFuture.Wait(); repairFuture.Wait(); }; - Cerr << "===Wait for 1st reconnect\n"; + std::cerr << "===Wait for 1st reconnect\n"; waitForReconnect(false); - Cerr << "===Wait for 2nd reconnect\n"; + std::cerr << "===Wait for 2nd reconnect\n"; waitForReconnect(true); } @@ -169,14 +169,14 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { auto& client = setup1->GetPersQueueClient(); //! Fill data in dc1 1 with SeqNo = 1..10 for 2 different SrcId - Cerr << "===Write 10 messages into every writer\n"; + std::cerr << "===Write 10 messages into every writer\n"; for (auto i = 0; i != 10; i++) { writer1->Write(true); // 1 writer2->Write(true); // 1 } - Cerr << "===Messages were written\n"; + std::cerr << "===Messages were written\n"; - Cerr << "===Disable dc1\n"; + std::cerr << "===Disable dc1\n"; //! Leave only dc2 available writer1->Policy->ExpectBreakDown(); writer2->Policy->ExpectBreakDown(); @@ -184,17 +184,17 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { writer1->Policy->WaitForRetriesSync(1); writer2->Policy->WaitForRetriesSync(1); - Cerr << "===Recreate writers\n"; + std::cerr << "===Recreate writers\n"; //! Re-create writers, kill previous sessions. New sessions will connect to dc2. writer1 = MakeHolder("", nullptr, std::string(), setup1, sourceId1, true); writer2 = MakeHolder("", nullptr, std::string(), setup1, sourceId2, true); //! Write some data and await confirmation - just to ensure sessions are started. - Cerr << "===Write one message into every writer\n"; + std::cerr << "===Write one message into every writer\n"; writer1->Write(true); writer2->Write(true); - Cerr << "===Messages were written\n"; + std::cerr << "===Messages were written\n"; //! Leave no available DCs writer1->Policy->ExpectBreakDown(); @@ -202,14 +202,14 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { writer1->Policy->Initialize(); writer2->Policy->Initialize(); - Cerr << "===Disable dc2\n"; + std::cerr << "===Disable dc2\n"; setup1->DisableDataCenter("dc2"); - Cerr << "===Wait for retries after initial dc2 shutdown\n"; + std::cerr << "===Wait for retries after initial dc2 shutdown\n"; writer1->Policy->WaitForRetriesSync(1); writer2->Policy->WaitForRetriesSync(1); //! Put some data inflight. It cannot be written now, but SeqNo will be assigned. - Cerr << "===Write four async message into every writer\n"; + std::cerr << "===Write four async message into every writer\n"; for (auto i = 0; i != 3; i++) { writer1->Write(false); writer2->Write(false); @@ -220,46 +220,46 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { //! Enable DC1. Now writers gonna write collected data to DC1 having LastSeqNo = 10 //! (because of data written in the very beginning), and inflight data has SeqNo assigned = 2..5, //! so the SeqNo shift takes place. - Cerr << "===Enable dc2\n"; + std::cerr << "===Enable dc2\n"; setup1->EnableDataCenter("dc1"); - Cerr << "===Wait for writes to complete\n"; + std::cerr << "===Wait for writes to complete\n"; f1.Wait(); f2.Wait(); - Cerr << "===Messages were written\n"; + std::cerr << "===Messages were written\n"; //! Writer1 is not used any more. writer1->EventLoop->AllowStop(); writer1 = nullptr; - Cerr << "===Writer 1 closed\n"; + std::cerr << "===Writer 1 closed\n"; writer2->Policy->ExpectBreakDown(); writer2->Policy->Initialize(); //! For the second writer, do switchback to dc2. - Cerr << "===Disable dc1\n"; + std::cerr << "===Disable dc1\n"; setup1->DisableDataCenter("dc1"); - Cerr << "===Wait for retries after dc1 shutdown\n"; + std::cerr << "===Wait for retries after dc1 shutdown\n"; writer2->Policy->WaitForRetriesSync(1); //! Put some data inflight again; - Cerr << "===Write four async messages into writer2\n"; + std::cerr << "===Write four async messages into writer2\n"; for (auto i = 0; i != 3; i++) { writer2->Write(false); } f2 = writer2->Write(false); - Cerr << "===Enable dc2\n"; + std::cerr << "===Enable dc2\n"; setup1->EnableDataCenter("dc2"); f2.Wait(); - Cerr << "===Messages were written\n"; + std::cerr << "===Messages were written\n"; writer2->EventLoop->AllowStop(); writer2->Policy->ExpectBreakDown(); writer2 = nullptr; - Cerr << "===Enable dc1\n"; + std::cerr << "===Enable dc1\n"; setup1->EnableDataCenter("dc1"); auto CheckSeqNo = [&] (const std::string& dcName, ui64 expectedSeqNo) { settings.PreferredCluster(dcName); @@ -274,17 +274,17 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { //!check SeqNo in both DC. For writer1 We expect 14 messages in DC1 //! (10 written initially + 4 written after reconnect) and 1 message in DC2 (only initial message). settings.MessageGroupId(sourceId1); - Cerr << "===Check SeqNo writer1, dc2\n"; + std::cerr << "===Check SeqNo writer1, dc2\n"; CheckSeqNo("dc2", 1); - Cerr << "===Check SeqNo writer1, dc1\n"; + std::cerr << "===Check SeqNo writer1, dc1\n"; CheckSeqNo("dc1", 14); //! Check SeqNo for writer 2; Expect to have 6 messages on DC2 with MaxSeqNo = 6; settings.MessageGroupId(sourceId2); - Cerr << "===Check SeqNo writer2 dc1\n"; + std::cerr << "===Check SeqNo writer2 dc1\n"; CheckSeqNo("dc1", 14); //! DC2 has no shift in SeqNo since 5 messages were written to dc 1. - Cerr << "===Check SeqNo writer2 dc2\n"; + std::cerr << "===Check SeqNo writer2 dc2\n"; CheckSeqNo("dc2", 9); @@ -309,11 +309,11 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { ui32 clustersPendingSrc2 = 2; while (!stop && (clustersPendingSrc2 || clustersPendingSrc1)) { - Cerr << "===Get event on client\n"; + std::cerr << "===Get event on client\n"; auto event = *readSession->GetEvent(true); std::visit(TOverloaded { [&](TReadSessionEvent::TDataReceivedEvent& event) { - Cerr << "===Data event\n"; + std::cerr << "===Data event\n"; auto& clusterName = event.GetPartitionStream()->GetCluster(); for (auto& message: event.GetMessages()) { std::string sourceId = message.GetMessageGroupId(); @@ -361,15 +361,15 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { event.Confirm(); }, [&](TReadSessionEvent::TPartitionStreamStatusEvent&) { - Cerr << "===Status event\n"; + std::cerr << "===Status event\n"; UNIT_FAIL("Test does not support lock sessions yet"); }, [&](TReadSessionEvent::TPartitionStreamClosedEvent&) { - Cerr << "===Stream closed event\n"; + std::cerr << "===Stream closed event\n"; UNIT_FAIL("Test does not support lock sessions yet"); }, [&](TSessionClosedEvent& event) { - Cerr << "===Got close event: " << event.DebugString(); + std::cerr << "===Got close event: " << event.DebugString(); stop = true; } @@ -387,7 +387,7 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { auto& client = setup->GetPersQueueClient(); auto writer = client.CreateWriteSession(settings); auto event = *writer->GetEvent(true); - Cerr << NYdb::NPersQueue::DebugString(event) << "\n"; + std::cerr << NYdb::NPersQueue::DebugString(event) << "\n"; UNIT_ASSERT(std::holds_alternative(event)); auto continueToken = std::move(std::get(event).ContinuationToken); std::string message = "1234567890"; @@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(RetryPolicy) { retryPolicy->WaitForRetriesSync(3); while (seqNo < 10) { auto event = *writer->GetEvent(true); - Cerr << NYdb::NPersQueue::DebugString(event) << "\n"; + std::cerr << NYdb::NPersQueue::DebugString(event) << "\n"; UNIT_ASSERT(std::holds_alternative(event)); writer->Write( std::move(std::get(event).ContinuationToken), diff --git a/client/ydb_persqueue_core/ut/ut_utils/ut_utils.h b/client/ydb_persqueue_core/ut/ut_utils/ut_utils.h index b4e2f47182b..79563d67910 100644 --- a/client/ydb_persqueue_core/ut/ut_utils/ut_utils.h +++ b/client/ydb_persqueue_core/ut/ut_utils/ut_utils.h @@ -139,7 +139,7 @@ struct TYDBClientEventLoop : public ::NPersQueue::IClientEventLoop { continueToken = std::move(event.ContinuationToken); }, [&](const TSessionClosedEvent& event) { - Log << TLOG_INFO << "Got close event: " << event.DebugString() << Endl; + Log << TLOG_INFO << "Got close event: " << event.DebugString() << std::endl; if (!MayStop) { UNIT_ASSERT(MustStop); UNIT_ASSERT(MessageBuffer.IsEmpty()); @@ -201,7 +201,7 @@ struct TYdbPqTestRetryState : NYdb::NPersQueue::IRetryPolicy::IRetryState { {} std::optional GetNextRetryDelay(NYdb::EStatus) override { - Cerr << "Test retry state: get retry delay\n"; + std::cerr << "Test retry state: get retry delay\n"; RetryDone(); return Delay; } @@ -226,17 +226,17 @@ struct TYdbPqTestRetryPolicy : IRetryPolicy { TYdbPqTestRetryPolicy(const TDuration& delay = TDuration::MilliSeconds(2000)) : Delay(delay) { - Cerr << "====TYdbPqTestRetryPolicy()\n"; + std::cerr << "====TYdbPqTestRetryPolicy()\n"; } IRetryState::TPtr CreateRetryState() const override { - Cerr << "====CreateRetryState\n"; + std::cerr << "====CreateRetryState\n"; if (AtomicSwap(&OnFatalBreakDown, 0)) { return std::make_unique(); } if (AtomicGet(Initialized_)) { - Cerr << "====CreateRetryState Initialized\n"; + std::cerr << "====CreateRetryState Initialized\n"; auto res = AtomicSwap(&OnBreakDown, 0); UNIT_ASSERT(res); for (size_t i = 0; i < 100; i++) { @@ -269,7 +269,7 @@ struct TYdbPqTestRetryPolicy : IRetryPolicy { } void ExpectBreakDown() { // Either TYdbPqTestRetryPolicy() or Initialize() should be called beforehand in order to set OnBreakDown=0 - Cerr << "====ExpectBreakDown\n"; + std::cerr << "====ExpectBreakDown\n"; for (size_t i = 0; i < 100; i++) { if (AtomicGet(OnBreakDown) == 0) break; @@ -335,13 +335,13 @@ class TYdbPqTestExecutor : public IAsyncExecutor { TFunction f; while (TasksQueue.Dequeue(&f)) { ++CurrentTaskId; - Cerr << "Enqueue task with id " << CurrentTaskId << Endl; + std::cerr << "Enqueue task with id " << CurrentTaskId << std::endl; Tasks[CurrentTaskId] = f; } ui64 id = 0; while (ExecIdsQueue->Dequeue(&id)) { ExecIds.push(id); - Cerr << "Got ok to execute task with id " << id << Endl; + std::cerr << "Got ok to execute task with id " << id << std::endl; } while (!ExecIds.empty()) { @@ -349,15 +349,15 @@ class TYdbPqTestExecutor : public IAsyncExecutor { auto iter = Tasks.find(id); if (iter == Tasks.end()) break; - Cerr << "Executing compression of " << id << Endl; + std::cerr << "Executing compression of " << id << std::endl; ExecIds.pop(); try { (iter->second)(); } catch (...) { - Cerr << "Failed on compression call: " << CurrentExceptionMessage() << Endl; + std::cerr << "Failed on compression call: " << CurrentExceptionMessage() << std::endl; Y_ABORT(); } - Cerr << "Compression of " << id << " Done\n"; + std::cerr << "Compression of " << id << " Done\n"; Tasks.erase(iter); } diff --git a/client/ydb_topic/ut/basic_usage_ut.cpp b/client/ydb_topic/ut/basic_usage_ut.cpp index e200ab4347c..8f4cce016fc 100644 --- a/client/ydb_topic/ut/basic_usage_ut.cpp +++ b/client/ydb_topic/ut/basic_usage_ut.cpp @@ -78,7 +78,7 @@ void WriteAndReadToEndWithRestarts(TReadSessionSettings readSettings, TWriteSess [&] (TReadSessionEvent::TDataReceivedEvent& ev) mutable { AtomicSet(lastOffset, ev.GetMessages().back().GetOffset()); - Cerr << ">>> TEST: last offset = " << lastOffset << Endl; + std::cerr << ">>> TEST: last offset = " << lastOffset << std::endl; }); ReadSession = topicClient.CreateReadSession(readSettings); @@ -96,7 +96,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { TTopicSdkTestSetup setup(TEST_CASE_NAME); NYdb::TDriverConfig cfg; - cfg.SetEndpoint(TYdbStringBuilder() << "invalid:" << setup.GetServer().GrpcPort); + cfg.SetEndpoint(TStringBuilder() << "invalid:" << setup.GetServer().GrpcPort); cfg.SetDatabase("/Invalid"); cfg.SetLog(CreateLogBackend("cerr", ELogPriority::TLOG_DEBUG)); auto driver = NYdb::TDriver(cfg); @@ -118,7 +118,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { { auto settings = TTopicClientSettings() .Database({"/Root"}) - .DiscoveryEndpoint({TYdbStringBuilder() << "localhost:" << setup.GetServer().GrpcPort}); + .DiscoveryEndpoint({TStringBuilder() << "localhost:" << setup.GetServer().GrpcPort}); TTopicClient client(driver, settings); @@ -143,24 +143,24 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .Path(TEST_TOPIC) .ProducerId(TEST_MESSAGE_GROUP_ID) .MessageGroupId(TEST_MESSAGE_GROUP_ID); - Cerr << ">>> open write session " << i << Endl; + std::cerr << ">>> open write session " << i << std::endl; auto writeSession = client.CreateSimpleBlockingWriteSession(writeSettings); UNIT_ASSERT(writeSession->Write("message_using_MessageGroupId")); - Cerr << ">>> write session " << i << " message written" << Endl; + std::cerr << ">>> write session " << i << " message written" << std::endl; writeSession->Close(); - Cerr << ">>> write session " << i << " closed" << Endl; + std::cerr << ">>> write session " << i << " closed" << std::endl; } { auto writeSettings = TWriteSessionSettings() .Path(TEST_TOPIC) .ProducerId(TEST_MESSAGE_GROUP_ID) .PartitionId(0); - Cerr << ">>> open write session 100" << Endl; + std::cerr << ">>> open write session 100" << std::endl; auto writeSession = client.CreateSimpleBlockingWriteSession(writeSettings); UNIT_ASSERT(writeSession->Write("message_using_PartitionId")); - Cerr << ">>> write session 100 message written" << Endl; + std::cerr << ">>> write session 100 message written" << std::endl; writeSession->Close(); - Cerr << ">>> write session 100 closed" << Endl; + std::cerr << ">>> write session 100 closed" << std::endl; } { @@ -278,7 +278,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { if (shouldCaptureData.Defined()) { TYdbStringBuilder msg; msg << "Session has captured " << sessionAdapter.GetAcquiredMessagesCount() - << " messages, capturing was expected: " << *shouldCaptureData << Endl; + << " messages, capturing was expected: " << *shouldCaptureData << std::endl; UNIT_ASSERT_VALUES_EQUAL_C(sessionAdapter.GetAcquiredMessagesCount() > 0, *shouldCaptureData, msg.c_str()); } } @@ -296,7 +296,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { .MaxMemoryUsageBytes(1_MB) .AppendTopics(setup->GetTestTopic()); - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; NThreading::TPromise checkedPromise = NThreading::NewPromise(); auto totalReceived = 0u; @@ -405,7 +405,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { writeSession->Close(TDuration::Seconds(10)); } promiseToWrite.SetValue(); - Cerr << ">>>TEST: write promise set " << Endl; + std::cerr << ">>>TEST: write promise set " << std::endl; { NThreading::TPromise promise = NThreading::NewPromise(); @@ -415,7 +415,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { [promise = std::move(promise)](TReadSessionEvent::TDataReceivedEvent& ev) mutable { ev.Commit(); promise.SetValue(); - Cerr << ">>>TEST: get read event " << Endl; + std::cerr << ">>>TEST: get read event " << std::endl; }); auto readSession = topicClient.CreateReadSession(readSettings); @@ -423,7 +423,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { readSession->Close(TDuration::Seconds(10)); } promiseToRead.SetValue(); - Cerr << ">>>TEST: read promise set " << Endl; + std::cerr << ">>>TEST: read promise set " << std::endl; }); @@ -444,31 +444,31 @@ Y_UNIT_TEST_SUITE(BasicUsage) { auto RunTasks = [&](auto e, const std::vector& tasks) { size_t n = tasks.size(); - Cerr << ">>>TEST in RunTasks: before WaitPlannedTasks" << Endl; + std::cerr << ">>>TEST in RunTasks: before WaitPlannedTasks" << std::endl; WaitPlannedTasks(e, n); - Cerr << ">>>TEST in RunTasks: before WaitExecutedTasks" << Endl; + std::cerr << ">>>TEST in RunTasks: before WaitExecutedTasks" << std::endl; size_t completed = e->GetExecutedCount(); e->StartFuncs(tasks); WaitExecutedTasks(e, completed + n); }; UNIT_ASSERT(!futureWrite.HasValue()); - Cerr << ">>>TEST: future write has no value " << Endl; + std::cerr << ">>>TEST: future write has no value " << std::endl; RunTasks(stepByStepExecutor, {0}); futureWrite.GetValueSync(); UNIT_ASSERT(futureWrite.HasValue()); - Cerr << ">>>TEST: future write has value " << Endl; + std::cerr << ">>>TEST: future write has value " << std::endl; UNIT_ASSERT(!futureRead.HasValue()); - Cerr << ">>>TEST: future read has no value " << Endl; + std::cerr << ">>>TEST: future read has no value " << std::endl; RunTasks(stepByStepExecutor, {1}); futureRead.GetValueSync(); UNIT_ASSERT(futureRead.HasValue()); - Cerr << ">>>TEST: future read has value " << Endl; + std::cerr << ">>>TEST: future read has value " << std::endl; f.get(); - Cerr << ">>> TEST: gracefully closed" << Endl; + std::cerr << ">>> TEST: gracefully closed" << std::endl; } Y_UNIT_TEST(SessionNotDestroyedWhileUserEventHandlingInFlight) { @@ -516,7 +516,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // { // std::shared_ptr token; // writeSettings.EventHandlers_.CommonHandler([token](TWriteSessionEvent::TEvent& event){ - // Cerr << ">>>TEST: in CommonHandler " << Endl; + // std::cerr << ">>>TEST: in CommonHandler " << std::endl; // if (std::holds_alternative(event)) { // *token = std::move(std::get(event).ContinuationToken); @@ -531,7 +531,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // writeSession->Close(TDuration::Seconds(10)); // } // promiseToWrite.SetValue(); - // Cerr << ">>>TEST: write promise set " << Endl; + // std::cerr << ">>>TEST: write promise set " << std::endl; { NThreading::TPromise promise = NThreading::NewPromise(); @@ -539,7 +539,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { readSettings.EventHandlers_.SimpleDataHandlers( [promise = std::move(promise)](TReadSessionEvent::TDataReceivedEvent& ev) mutable { - Cerr << ">>>TEST: in SimpleDataHandlers " << Endl; + std::cerr << ">>>TEST: in SimpleDataHandlers " << std::endl; ev.Commit(); promise.SetValue(); }); @@ -549,7 +549,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { readSession->Close(TDuration::Seconds(10)); } promiseToRead.SetValue(); - Cerr << ">>>TEST: read promise set " << Endl; + std::cerr << ">>>TEST: read promise set " << std::endl; }); @@ -570,9 +570,9 @@ Y_UNIT_TEST_SUITE(BasicUsage) { auto RunTasks = [&](auto e, const std::vector& tasks) { size_t n = tasks.size(); - Cerr << ">>>TEST in RunTasks: before WaitPlannedTasks" << Endl; + std::cerr << ">>>TEST in RunTasks: before WaitPlannedTasks" << std::endl; WaitPlannedTasks(e, n); - Cerr << ">>>TEST in RunTasks: before WaitExecutedTasks" << Endl; + std::cerr << ">>>TEST in RunTasks: before WaitExecutedTasks" << std::endl; size_t completed = e->GetExecutedCount(); e->StartFuncs(tasks); WaitExecutedTasks(e, completed + n); @@ -580,25 +580,25 @@ Y_UNIT_TEST_SUITE(BasicUsage) { // RunTasks(stepByStepExecutor, {0}); // UNIT_ASSERT(!futureWrite.HasValue()); - // Cerr << ">>>TEST: future write has no value " << Endl; + // std::cerr << ">>>TEST: future write has no value " << std::endl; // RunTasks(stepByStepExecutor, {1}); // futureWrite.GetValueSync(); // UNIT_ASSERT(futureWrite.HasValue()); - // Cerr << ">>>TEST: future write has value " << Endl; + // std::cerr << ">>>TEST: future write has value " << std::endl; UNIT_ASSERT(!futureRead.HasValue()); - Cerr << ">>>TEST: future read has no value " << Endl; + std::cerr << ">>>TEST: future read has no value " << std::endl; // 0: TStartPartitionSessionEvent RunTasks(stepByStepExecutor, {0}); // 1: TDataReceivedEvent RunTasks(stepByStepExecutor, {1}); futureRead.GetValueSync(); UNIT_ASSERT(futureRead.HasValue()); - Cerr << ">>>TEST: future read has value " << Endl; + std::cerr << ">>>TEST: future read has value " << std::endl; f.get(); - Cerr << ">>> TEST: gracefully closed" << Endl; + std::cerr << ">>> TEST: gracefully closed" << std::endl; } Y_UNIT_TEST(ReadSessionCorrectClose) { @@ -640,11 +640,11 @@ Y_UNIT_TEST_SUITE(BasicUsage) { readSettings.EventHandlers_.SimpleDataHandlers( [] (NYdb::NTopic::TReadSessionEvent::TDataReceivedEvent& ev) mutable { - Cerr << ">>> Got TDataReceivedEvent" << Endl; + std::cerr << ">>> Got TDataReceivedEvent" << std::endl; ev.Commit(); }); - Cerr << ">>> TEST: Create session" << Endl; + std::cerr << ">>> TEST: Create session" << std::endl; ReadSession = topicClient.CreateReadSession(readSettings); @@ -652,7 +652,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) { ReadSession->Close(); ReadSession = nullptr; - Cerr << ">>> TEST: Session gracefully closed" << Endl; + std::cerr << ">>> TEST: Session gracefully closed" << std::endl; Sleep(TDuration::Seconds(5)); diff --git a/client/ydb_topic/ut/local_partition_ut.cpp b/client/ydb_topic/ut/local_partition_ut.cpp index 94e1ad28630..7431b1281ab 100644 --- a/client/ydb_topic/ut/local_partition_ut.cpp +++ b/client/ydb_topic/ut/local_partition_ut.cpp @@ -51,7 +51,7 @@ namespace NYdb::NTopic::NTests { void WriteMessage(TTopicClient& client) { - Cerr << "=== Write message" << Endl; + std::cerr << "=== Write message" << std::endl; auto writeSession = client.CreateSimpleBlockingWriteSession(CreateWriteSessionSettings()); UNIT_ASSERT(writeSession->Write("message")); @@ -60,7 +60,7 @@ namespace NYdb::NTopic::NTests { void ReadMessage(TTopicClient& client, ui64 expectedCommitedOffset = 1) { - Cerr << "=== Read message" << Endl; + std::cerr << "=== Read message" << std::endl; auto readSession = client.CreateReadSession(CreateReadSessionSettings()); @@ -103,13 +103,13 @@ namespace NYdb::NTopic::NTests { { ui16 discoveryPort = TPortManager().GetPort(); DiscoveryAddr = TYdbStringBuilder() << "0.0.0.0:" << discoveryPort; - Cerr << "==== TMockDiscovery server started on port " << discoveryPort << Endl; + std::cerr << "==== TMockDiscovery server started on port " << discoveryPort << std::endl; Server = ::NYdb::NTopic::NTests::NTestSuiteLocalPartition::StartGrpcServer(DiscoveryAddr, *this); } void SetGoodEndpoints(TTopicSdkTestSetup& setup) { - Cerr << "=== TMockDiscovery set good endpoint nodes " << Endl; + std::cerr << "=== TMockDiscovery set good endpoint nodes " << std::endl; SetEndpoints(setup.GetRuntime().GetNodeId(0), setup.GetRuntime().GetNodeCount(), setup.GetServer().GrpcPort); } @@ -117,7 +117,7 @@ namespace NYdb::NTopic::NTests { { std::lock_guard lock(Lock); - Cerr << "==== TMockDiscovery add endpoints, firstNodeId " << firstNodeId << ", nodeCount " << nodeCount << ", port " << port << Endl; + std::cerr << "==== TMockDiscovery add endpoints, firstNodeId " << firstNodeId << ", nodeCount " << nodeCount << ", port " << port << std::endl; MockResults.clear_endpoints(); if (nodeCount > 0) @@ -146,7 +146,7 @@ namespace NYdb::NTopic::NTests { if (Delay) { - Cerr << "==== Delay " << Delay << " before ListEndpoints request" << Endl; + std::cerr << "==== Delay " << Delay << " before ListEndpoints request" << std::endl; TInstant start = TInstant::Now(); while (start + Delay < TInstant::Now()) { @@ -156,14 +156,14 @@ namespace NYdb::NTopic::NTests { } } - Cerr << "==== ListEndpoints request: " << request->ShortDebugString() << Endl; + std::cerr << "==== ListEndpoints request: " << request->ShortDebugString() << std::endl; auto* op = response->mutable_operation(); op->set_ready(true); op->set_status(Ydb::StatusIds::SUCCESS); op->mutable_result()->PackFrom(MockResults); - Cerr << "==== ListEndpoints response: " << response->ShortDebugString() << Endl; + std::cerr << "==== ListEndpoints response: " << response->ShortDebugString() << std::endl; return grpc::Status::OK; } @@ -218,7 +218,7 @@ namespace NYdb::NTopic::NTests { auto [setup, client, discovery] = Start(TEST_CASE_NAME); for (size_t i = 1; i <= 10; ++i) { - Cerr << "=== Restart attempt " << i << Endl; + std::cerr << "=== Restart attempt " << i << std::endl; setup->GetServer().KillTopicPqTablets(setup->GetTopicPath()); WriteMessage(*client); ReadMessage(*client, i); @@ -242,23 +242,23 @@ namespace NYdb::NTopic::NTests { retryPolicy->Initialize(); retryPolicy->ExpectBreakDown(); - Cerr << "=== Create write session\n"; + std::cerr << "=== Create write session\n"; TTopicClient client(TDriver(CreateConfig(*setup, discovery.GetDiscoveryAddr()))); auto writeSession = client.CreateWriteSession(writeSettings); - Cerr << "=== Wait for retries\n"; + std::cerr << "=== Wait for retries\n"; retryPolicy->WaitForRetriesSync(3); - Cerr << "=== Alter partition count\n"; + std::cerr << "=== Alter partition count\n"; TAlterTopicSettings alterSettings; alterSettings.AlterPartitioningSettings(2, 2); auto alterResult = client.AlterTopic(setup->GetTopicPath(), alterSettings).GetValueSync(); UNIT_ASSERT_VALUES_EQUAL_C(alterResult.GetStatus(), NYdb::EStatus::SUCCESS, alterResult.GetIssues().ToString()); - Cerr << "=== Wait for repair\n"; + std::cerr << "=== Wait for repair\n"; retryPolicy->WaitForRepairSync(); - Cerr << "=== Close write session\n"; + std::cerr << "=== Close write session\n"; writeSession->Close(); } @@ -276,19 +276,19 @@ namespace NYdb::NTopic::NTests { retryPolicy->Initialize(); retryPolicy->ExpectBreakDown(); - Cerr << "=== Create write session\n"; + std::cerr << "=== Create write session\n"; TTopicClient client(TDriver(CreateConfig(*setup, discovery.GetDiscoveryAddr()))); auto writeSession = client.CreateWriteSession(writeSettings); - Cerr << "=== Wait for retries\n"; + std::cerr << "=== Wait for retries\n"; retryPolicy->WaitForRetriesSync(3); discovery.SetGoodEndpoints(*setup); - Cerr << "=== Wait for repair\n"; + std::cerr << "=== Wait for repair\n"; retryPolicy->WaitForRepairSync(); - Cerr << "=== Close write session\n"; + std::cerr << "=== Close write session\n"; writeSession->Close(); } @@ -306,19 +306,19 @@ namespace NYdb::NTopic::NTests { retryPolicy->Initialize(); retryPolicy->ExpectBreakDown(); - Cerr << "=== Create write session\n"; + std::cerr << "=== Create write session\n"; TTopicClient client(TDriver(CreateConfig(*setup, discovery.GetDiscoveryAddr()))); auto writeSession = client.CreateWriteSession(writeSettings); - Cerr << "=== Wait for retries\n"; + std::cerr << "=== Wait for retries\n"; retryPolicy->WaitForRetriesSync(3); discovery.SetGoodEndpoints(*setup); - Cerr << "=== Wait for repair\n"; + std::cerr << "=== Wait for repair\n"; retryPolicy->WaitForRepairSync(); - Cerr << "=== Close write session\n"; + std::cerr << "=== Close write session\n"; writeSession->Close(); } @@ -336,11 +336,11 @@ namespace NYdb::NTopic::NTests { retryPolicy->Initialize(); retryPolicy->ExpectBreakDown(); - Cerr << "=== Create write session\n"; + std::cerr << "=== Create write session\n"; TTopicClient client(TDriver(CreateConfig(*setup, discovery.GetDiscoveryAddr()))); auto writeSession = client.CreateWriteSession(writeSettings); - Cerr << "=== Close write session\n"; + std::cerr << "=== Close write session\n"; writeSession->Close(); } @@ -351,11 +351,11 @@ namespace NYdb::NTopic::NTests { discovery.SetGoodEndpoints(*setup); discovery.SetDelay(TDuration::Days(1)); - Cerr << "=== Create write session\n"; + std::cerr << "=== Create write session\n"; TTopicClient client(TDriver(CreateConfig(*setup, discovery.GetDiscoveryAddr()))); auto writeSession = client.CreateWriteSession(CreateWriteSessionSettings()); - Cerr << "=== Close write session\n"; + std::cerr << "=== Close write session\n"; writeSession->Close(); } } diff --git a/client/ydb_topic/ut/ut_utils/topic_sdk_test_setup.cpp b/client/ydb_topic/ut/ut_utils/topic_sdk_test_setup.cpp index 77130c8f310..8297d97b55a 100644 --- a/client/ydb_topic/ut/ut_utils/topic_sdk_test_setup.cpp +++ b/client/ydb_topic/ut/ut_utils/topic_sdk_test_setup.cpp @@ -1,5 +1,7 @@ #include "topic_sdk_test_setup.h" +#include + using namespace NYdb; using namespace NYdb::NTopic; using namespace NYdb::NTopic::NTests; @@ -9,7 +11,7 @@ TTopicSdkTestSetup::TTopicSdkTestSetup(const std::string& testCaseName, const NK , Server(settings, false) { Log.SetFormatter([testCaseName](ELogPriority priority, std::string_view message) { - return TYdbStringBuilder() << TInstant::Now() << " :" << testCaseName << " " << priority << ": " << message << Endl; + return TStringBuilder() << TInstant::Now() << " :" << testCaseName << " " << priority << ": " << message << Endl; }); Server.StartServer(true, GetDatabase()); @@ -73,7 +75,7 @@ TDriverConfig TTopicSdkTestSetup::MakeDriverConfig() const config.SetEndpoint(GetEndpoint()); config.SetDatabase(GetDatabase()); config.SetAuthToken("root@builtin"); - config.SetLog(MakeHolder(&Cerr)); + config.SetLog(MakeHolder(&std::cerr)); return config; } diff --git a/client/ydb_types/status/status.cpp b/client/ydb_types/status/status.cpp index ed69f282a69..00e540a8612 100644 --- a/client/ydb_types/status/status.cpp +++ b/client/ydb_types/status/status.cpp @@ -73,9 +73,15 @@ float TStatus::GetConsumedRu() const { } IOutputStream& operator<<(IOutputStream& out, const TStatus& st) { - out << "Status: " << st.GetStatus() << Endl; + std::stringstream buf; + buf << st; + return out << buf.str(); +} + +std::ostream& operator<<(std::ostream& out, const TStatus& st) { + out << "Status: " << ToString(st.GetStatus()) << std::endl; if (st.GetIssues()) { - out << "Issues: " << Endl; + out << "Issues: " << std::endl; st.GetIssues().PrintTo(out); } return out; diff --git a/client/ydb_types/status/status.h b/client/ydb_types/status/status.h index c4162a4f191..001959a77f3 100644 --- a/client/ydb_types/status/status.h +++ b/client/ydb_types/status/status.h @@ -27,6 +27,7 @@ class TStatus { float GetConsumedRu() const; friend IOutputStream& operator<<(IOutputStream& out, const TStatus& st); + friend std::ostream& operator<<(std::ostream& out, const TStatus& st); protected: void CheckStatusOk(const std::string& str) const; diff --git a/examples/basic_example/basic_example.cpp b/examples/basic_example/basic_example.cpp index 44a37d05954..77acc12bf19 100644 --- a/examples/basic_example/basic_example.cpp +++ b/examples/basic_example/basic_example.cpp @@ -22,8 +22,8 @@ static void ThrowOnError(const TStatus& status) { } static void PrintStatus(const TStatus& status) { - Cerr << "Status: " << status.GetStatus() << Endl; - status.GetIssues().PrintTo(Cerr); + std::cerr << "Status: " << ToString(status.GetStatus()) << std::endl; + status.GetIssues().PrintTo(std::cerr); } static std::string JoinPath(const std::string& basePath, const std::string& path) { @@ -95,9 +95,9 @@ static void DescribeTable(TTableClient client, const std::string& path, const st return result; })); - Cout << "> Describe table: " << name << Endl; + std::cout << "> Describe table: " << name << std::endl; for (auto& column : desc->GetColumns()) { - Cout << "Column, name: " << column.Name << ", type: " << FormatType(column.Type) << Endl; + std::cout << "Column, name: " << column.Name << ", type: " << FormatType(column.Type) << std::endl; } } @@ -272,7 +272,7 @@ static TStatus PreparedSelectTransaction(TSession session, const std::string& pa } if (!prepareResult.IsQueryFromCache()) { - Cerr << "+Finished preparing query: PreparedSelectTransaction" << Endl; + std::cerr << "+Finished preparing query: PreparedSelectTransaction" << std::endl; } auto dataQuery = prepareResult.GetQuery(); @@ -441,11 +441,11 @@ void SelectSimple(TTableClient client, const std::string& path) { TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { - Cout << "> SelectSimple:" << Endl << "Series" - << ", Id: " << parser.ColumnParser("series_id").GetOptionalUint64() - << ", Title: " << parser.ColumnParser("title").GetOptionalUtf8() - << ", Release date: " << parser.ColumnParser("release_date").GetOptionalString() - << Endl; + std::cout << "> SelectSimple:" << std::endl << "Series" + << ", Id: " << ToString(parser.ColumnParser("series_id").GetOptionalUint64()) + << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) + << ", Release date: " << ToString(parser.ColumnParser("release_date").GetOptionalString()) + << std::endl; } } @@ -463,10 +463,10 @@ void SelectWithParams(TTableClient client, const std::string& path) { TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { - Cout << "> SelectWithParams:" << Endl << "Season" - << ", Title: " << parser.ColumnParser("season_title").GetOptionalUtf8() - << ", Series title: " << parser.ColumnParser("series_title").GetOptionalUtf8() - << Endl; + std::cout << "> SelectWithParams:" << std::endl << "Season" + << ", Title: " << ToString(parser.ColumnParser("season_title").GetOptionalUtf8()) + << ", Series title: " << ToString(parser.ColumnParser("series_title").GetOptionalUtf8()) + << std::endl; } } @@ -480,10 +480,10 @@ void PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, if (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); - Cout << "> PreparedSelect:" << Endl << "Episode " << parser.ColumnParser("episode_id").GetOptionalUint64() - << ", Title: " << parser.ColumnParser("title").GetOptionalUtf8() + std::cout << "> PreparedSelect:" << std::endl << "Episode " << ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) + << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) << ", Air date: " << airDate.FormatLocalTime("%a %b %d, %Y") - << Endl; + << std::endl; } } @@ -494,15 +494,15 @@ void MultiStep(TTableClient client, const std::string& path) { })); TResultSetParser parser(*resultSet); - Cout << "> MultiStep:" << Endl; + std::cout << "> MultiStep:" << std::endl; while (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); - Cout << "Episode " << parser.ColumnParser("episode_id").GetOptionalUint64() - << ", Season: " << parser.ColumnParser("season_id").GetOptionalUint64() - << ", Title: " << parser.ColumnParser("title").GetOptionalUtf8() + std::cout << "Episode " << ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) + << ", Season: " << ToString(parser.ColumnParser("season_id").GetOptionalUint64()) + << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) << ", Air date: " << airDate.FormatLocalTime("%a %b %d, %Y") - << Endl; + << std::endl; } } @@ -536,19 +536,19 @@ void ScanQuerySelect(TTableClient client, const std::string& path) { auto result = client.StreamExecuteScanQuery(query, parameters).GetValueSync(); if (!result.IsSuccess()) { - Cerr << "ScanQuery execution failure: " << result.GetIssues().ToString() << Endl; + std::cerr << "ScanQuery execution failure: " << result.GetIssues().ToString() << std::endl; return; } bool eos = false; - Cout << "> ScanQuerySelect:" << Endl; + std::cout << "> ScanQuerySelect:" << std::endl; while (!eos) { auto streamPart = result.ReadNext().ExtractValueSync(); if (!streamPart.IsSuccess()) { eos = true; if (!streamPart.EOS()) { - Cerr << "ScanQuery execution failure: " << streamPart.GetIssues().ToString() << Endl; + std::cerr << "ScanQuery execution failure: " << streamPart.GetIssues().ToString() << std::endl; } continue; } @@ -559,12 +559,12 @@ void ScanQuerySelect(TTableClient client, const std::string& path) { TResultSetParser parser(rs); while (parser.TryNextRow()) { - Cout << "Season" - << ", SeriesId: " << parser.ColumnParser("series_id").GetOptionalUint64() - << ", SeasonId: " << parser.ColumnParser("season_id").GetOptionalUint64() - << ", Title: " << parser.ColumnParser("title").GetOptionalUtf8() - << ", Air date: " << parser.ColumnParser("first_aired").GetOptionalString() - << Endl; + std::cout << "Season" + << ", SeriesId: " << ToString(parser.ColumnParser("series_id").GetOptionalUint64()) + << ", SeasonId: " << ToString(parser.ColumnParser("season_id").GetOptionalUint64()) + << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) + << ", Air date: " << ToString(parser.ColumnParser("first_aired").GetOptionalString()) + << std::endl; } } } @@ -601,7 +601,7 @@ bool Run(const TDriver& driver, const std::string& path) { ScanQuerySelect(client, path); } catch (const TYdbErrorException& e) { - Cerr << "Execution failed due to fatal error:" << Endl; + std::cerr << "Execution failed due to fatal error:" << std::endl; PrintStatus(e.Status); return false; } diff --git a/examples/bulk_upsert_simple/main.cpp b/examples/bulk_upsert_simple/main.cpp index b6b73ba81bd..1da60cde20e 100644 --- a/examples/bulk_upsert_simple/main.cpp +++ b/examples/bulk_upsert_simple/main.cpp @@ -4,11 +4,6 @@ #include -Y_DECLARE_OUT_SPEC(, NYdb::TStatus, stream, value) { - stream << "Status: " << value.GetStatus() << Endl; - value.GetIssues().PrintTo(stream); -} - constexpr size_t BATCH_SIZE = 1000; struct TLogMessage { @@ -58,14 +53,14 @@ bool WriteLogBatch(NYdb::NTable::TTableClient& tableClient, const std::string& t auto status = tableClient.RetryOperationSync(bulkUpsertOperation, retrySettings); if (!status.IsSuccess()) { - Cerr << Endl << "Write failed with status: " << (const NYdb::TStatus&)status << Endl; + std::cerr << std::endl << "Write failed with status: " << (const NYdb::TStatus&)status << std::endl; return false; } return true; } bool CreateLogTable(NYdb::NTable::TTableClient& client, const std::string& table) { - Cerr << "Create table " << table << "\n"; + std::cerr << "Create table " << table << "\n"; NYdb::NTable::TRetryOperationSettings settings; auto status = client.RetryOperationSync([&table](NYdb::NTable::TSession session) { @@ -82,7 +77,7 @@ bool CreateLogTable(NYdb::NTable::TTableClient& client, const std::string& table }, settings); if (!status.IsSuccess()) { - Cerr << "Create table failed with status: " << status << Endl; + std::cerr << "Create table failed with status: " << status << std::endl; return false; } return true; @@ -105,10 +100,10 @@ bool Run(const NYdb::TDriver &driver, const std::string &table, ui32 batchCount) if (!WriteLogBatch(client, table, logBatch, writeRetrySettings)) { return false; } - Cerr << "."; + std::cerr << "."; } - Cerr << Endl << "Done." << Endl; + std::cerr << std::endl << "Done." << std::endl; return true; } diff --git a/examples/pagination/pagination.cpp b/examples/pagination/pagination.cpp index 659bab796a1..1feb8e9a7f8 100644 --- a/examples/pagination/pagination.cpp +++ b/examples/pagination/pagination.cpp @@ -22,8 +22,8 @@ static void ThrowOnError(const TStatus& status) { } static void PrintStatus(const TStatus& status) { - Cerr << "Status: " << status.GetStatus() << Endl; - status.GetIssues().PrintTo(Cerr); + std::cerr << "Status: " << ToString(status.GetStatus()) << std::endl; + status.GetIssues().PrintTo(std::cerr); } static std::string JoinPath(const std::string& basePath, const std::string& path) { @@ -150,7 +150,7 @@ bool SelectPaging(TTableClient client, const std::string& path, ui64 pageLimit, do { lastCity = parser.ColumnParser("city").GetOptionalUtf8().value(); lastNumber = parser.ColumnParser("number").GetOptionalUint32().value(); - Cout << lastCity << ", Школа №" << lastNumber << ", Адрес: " << parser.ColumnParser("address").GetOptionalUtf8() << Endl; + std::cout << lastCity << ", Школа №" << lastNumber << ", Адрес: " << ToString(parser.ColumnParser("address").GetOptionalUtf8()) << std::endl; } while (parser.TryNextRow()); return true; } @@ -171,17 +171,17 @@ bool Run(const TDriver& driver, const std::string& path) { ui32 page = 0; bool pageNotEmpty = true; - Cout << "> Pagination, Limit=" << limit << Endl; + std::cout << "> Pagination, Limit=" << limit << std::endl; // show first MaxPages=10 pages: while (pageNotEmpty && page <= MaxPages) { ++page; - Cout << "> Page " << page << ":" << Endl; + std::cout << "> Page " << page << ":" << std::endl; pageNotEmpty = SelectPaging(client, path, limit, lastCity, lastNumber); } } catch (const TYdbErrorException& e) { - Cerr << "Execution failed due to fatal error:" << Endl; + std::cerr << "Execution failed due to fatal error:" << std::endl; PrintStatus(e.Status); return false; } diff --git a/examples/secondary_index/main.cpp b/examples/secondary_index/main.cpp index 2a70ada3bc2..0cb1934ede4 100644 --- a/examples/secondary_index/main.cpp +++ b/examples/secondary_index/main.cpp @@ -29,7 +29,7 @@ int main(int argc, char** argv) { ECmd cmd = ParseCmd(*argv); if (cmd == ECmd::NONE) { - Cerr << "Unsupported command '" << *argv << "'" << Endl; + std::cerr << "Unsupported command '" << *argv << "'" << std::endl; return 1; } @@ -61,7 +61,7 @@ int main(int argc, char** argv) { return RunDeleteSeries(driver, prefix, argc, argv); } } catch (const TYdbErrorException& e) { - Cerr << "Execution failed: " << e << Endl; + std::cerr << "Execution failed: " << e << std::endl; return 1; } diff --git a/examples/secondary_index/secondary_index.h b/examples/secondary_index/secondary_index.h index 9bb06b854fb..13fafac685b 100644 --- a/examples/secondary_index/secondary_index.h +++ b/examples/secondary_index/secondary_index.h @@ -45,10 +45,10 @@ class TYdbErrorException : public yexception { : Status(std::move(status)) { } - friend IOutputStream& operator<<(IOutputStream& out, const TYdbErrorException& e) { - out << "Status: " << e.Status.GetStatus(); + friend std::ostream& operator<<(std::ostream& out, const TYdbErrorException& e) { + out << "Status: " << ToString(e.Status.GetStatus()); if (e.Status.GetIssues()) { - out << Endl; + out << std::endl; e.Status.GetIssues().PrintTo(out); } return out; diff --git a/examples/secondary_index/secondary_index_create.cpp b/examples/secondary_index/secondary_index_create.cpp index 4d6432293f4..3b0151a003b 100644 --- a/examples/secondary_index/secondary_index_create.cpp +++ b/examples/secondary_index/secondary_index_create.cpp @@ -35,7 +35,7 @@ static void CreateSeriesIndexTable(TTableClient& client, const std::string& pref int RunCreateTables(TDriver& driver, const std::string& prefix, int argc, char**) { if (argc > 1) { - Cerr << "Unexpected arguments after create_tables" << Endl; + std::cerr << "Unexpected arguments after create_tables" << std::endl; return 1; } diff --git a/examples/secondary_index/secondary_index_delete.cpp b/examples/secondary_index/secondary_index_delete.cpp index dfefb49ebea..3a1d6d76414 100644 --- a/examples/secondary_index/secondary_index_delete.cpp +++ b/examples/secondary_index/secondary_index_delete.cpp @@ -74,6 +74,6 @@ int RunDeleteSeries(TDriver& driver, const std::string& prefix, int argc, char** return DeleteSeries(session, prefix, seriesId, deletedCount); })); - Cout << "Deleted " << deletedCount << " rows" << Endl; + std::cout << "Deleted " << deletedCount << " rows" << std::endl; return 0; } diff --git a/examples/secondary_index/secondary_index_drop.cpp b/examples/secondary_index/secondary_index_drop.cpp index 4ab3f70ff74..c6b7f84ca67 100644 --- a/examples/secondary_index/secondary_index_drop.cpp +++ b/examples/secondary_index/secondary_index_drop.cpp @@ -14,7 +14,7 @@ static void DropTable(TTableClient& client, const std::string& path) { int RunDropTables(TDriver& driver, const std::string& prefix, int argc, char**) { if (argc > 1) { - Cerr << "Unexpected arguments after drop_tables" << Endl; + std::cerr << "Unexpected arguments after drop_tables" << std::endl; return 1; } diff --git a/examples/secondary_index/secondary_index_generate.cpp b/examples/secondary_index/secondary_index_generate.cpp index 996bc19a672..d40696005d8 100644 --- a/examples/secondary_index/secondary_index_generate.cpp +++ b/examples/secondary_index/secondary_index_generate.cpp @@ -202,6 +202,6 @@ int RunGenerateSeries(TDriver& driver, const std::string& prefix, int argc, char } executor.Wait(); - Cout << "Generated " << generated << " new series" << Endl; + std::cout << "Generated " << generated << " new series" << std::endl; return 0; } diff --git a/examples/secondary_index/secondary_index_list.cpp b/examples/secondary_index/secondary_index_list.cpp index b6c6f62ddc9..1f09a06c648 100644 --- a/examples/secondary_index/secondary_index_list.cpp +++ b/examples/secondary_index/secondary_index_list.cpp @@ -297,27 +297,27 @@ int RunListSeries(TDriver& driver, const std::string& prefix, int argc, char** a } } auto printLine = [&]() { - Cout << '+'; + std::cout << '+'; for (size_t i = 0; i < 5; ++i) { for (size_t k = 0; k < widths[i]; ++k) { - Cout << '-'; + std::cout << '-'; } - Cout << '+'; + std::cout << '+'; } - Cout << Endl; + std::cout << std::endl; }; auto printRow = [&](size_t row) { - Cout << '|'; + std::cout << '|'; for (size_t i = 0; i < 5; ++i) { - Cout << ' ' << columns[i][row]; + std::cout << ' ' << columns[i][row]; size_t printed = 1 + GetNumberOfUTF8Chars(columns[i][row]); while (printed < widths[i]) { - Cout << ' '; + std::cout << ' '; ++printed; } - Cout << '|'; + std::cout << '|'; } - Cout << Endl; + std::cout << std::endl; }; printLine(); diff --git a/examples/secondary_index/secondary_index_update.cpp b/examples/secondary_index/secondary_index_update.cpp index 7a449476a61..e15da5649a0 100644 --- a/examples/secondary_index/secondary_index_update.cpp +++ b/examples/secondary_index/secondary_index_update.cpp @@ -82,6 +82,6 @@ int RunUpdateViews(TDriver& driver, const std::string& prefix, int argc, char** return result; })); - Cout << "Updated " << updatedCount << " rows" << Endl; + std::cout << "Updated " << updatedCount << " rows" << std::endl; return 0; } diff --git a/examples/secondary_index_builtin/main.cpp b/examples/secondary_index_builtin/main.cpp index 2e26d31019d..47660778152 100644 --- a/examples/secondary_index_builtin/main.cpp +++ b/examples/secondary_index_builtin/main.cpp @@ -28,7 +28,7 @@ int main(int argc, char** argv) { TCommand cmd = Parse(command.c_str()); if (cmd == TCommand::NONE) { - Cerr << "Unsupported command: " << command << Endl; + std::cerr << "Unsupported command: " << command << std::endl; return 1; } @@ -56,7 +56,7 @@ int main(int argc, char** argv) { } } catch (const TYdbErrorException& e) { - Cerr << "Execution failed: " << e << Endl; + std::cerr << "Execution failed: " << e << std::endl; return 1; } } diff --git a/examples/secondary_index_builtin/secondary_index.h b/examples/secondary_index_builtin/secondary_index.h index 1618b446503..20a09391f80 100644 --- a/examples/secondary_index_builtin/secondary_index.h +++ b/examples/secondary_index_builtin/secondary_index.h @@ -57,10 +57,10 @@ class TYdbErrorException: public yexception { : Status(std::move(status)) { } - friend IOutputStream& operator<<(IOutputStream& out, const TYdbErrorException& e) { - out << "Status:" << e.Status.GetStatus(); + friend std::ostream& operator<<(std::ostream& out, const TYdbErrorException& e) { + out << "Status:" << ToString(e.Status.GetStatus()); if (e.Status.GetIssues()) { - out << Endl; + out << std::endl; e.Status.GetIssues().PrintTo(out); } return out; diff --git a/examples/secondary_index_builtin/secondary_index_select.cpp b/examples/secondary_index_builtin/secondary_index_select.cpp index 620dff5b2c4..ae4264ee311 100644 --- a/examples/secondary_index_builtin/secondary_index_select.cpp +++ b/examples/secondary_index_builtin/secondary_index_select.cpp @@ -55,8 +55,8 @@ int Select(TDriver& driver, const std::string& path, int argc, char **argv) { })); for (auto& item: selectResult) { - Cout << item.SeriesId << ' ' << item.Title << ' ' << item.Info << ' ' - << item.ReleaseDate << ' ' << item.Views << ' ' << item.UploadedUserId << Endl; + std::cout << item.SeriesId << ' ' << item.Title << ' ' << item.Info << ' ' + << item.ReleaseDate.ToString() << ' ' << item.Views << ' ' << item.UploadedUserId << std::endl; } return 0; diff --git a/examples/secondary_index_builtin/secondary_index_select_join.cpp b/examples/secondary_index_builtin/secondary_index_select_join.cpp index ba3872ceb81..f93a62c167e 100644 --- a/examples/secondary_index_builtin/secondary_index_select_join.cpp +++ b/examples/secondary_index_builtin/secondary_index_select_join.cpp @@ -60,7 +60,7 @@ int SelectJoin(TDriver& driver, const std::string& path, int argc, char **argv) })); for (auto& item : selectResult) { - Cout << item.SeriesId << ' ' << item.Title << Endl; + std::cout << item.SeriesId << ' ' << item.Title << std::endl; } return 0; diff --git a/examples/topic_reader/eventloop/main.cpp b/examples/topic_reader/eventloop/main.cpp index 2ef27b387ab..1cf0dae7834 100644 --- a/examples/topic_reader/eventloop/main.cpp +++ b/examples/topic_reader/eventloop/main.cpp @@ -35,7 +35,7 @@ struct TOptions { std::shared_ptr ReadSession; void StopHandler(int) { - Cerr << "Stopping session" << Endl; + std::cerr << "Stopping session" << std::endl; if (ReadSession) { ReadSession->Close(TDuration::Seconds(3)); } else { @@ -74,7 +74,7 @@ int main(int argc, const char* argv[]) { ReadSession = topicClient.CreateReadSession(settings); - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; // [BEGIN read session process events] // Event loop @@ -83,15 +83,15 @@ int main(int argc, const char* argv[]) { // Wait for next event or ten seconds future.Wait(TDuration::Seconds(10)); // future.Subscribe([](){ - // Cerr << ...; + // std::cerr << ...; // }); // Get event std::optional event = ReadSession->GetEvent(true/*block - will block if no event received yet*/); - Cerr << "Got new read session event: " << DebugString(*event) << Endl; + std::cerr << "Got new read session event: " << DebugString(*event) << std::endl; if (auto* dataEvent = std::get_if(&*event)) { for (const auto& message : dataEvent->GetMessages()) { - Cerr << "Data message: \"" << message.GetData() << "\"" << Endl; + std::cerr << "Data message: \"" << message.GetData() << "\"" << std::endl; } if (opts.CommitAfterProcessing) { diff --git a/examples/topic_reader/simple/main.cpp b/examples/topic_reader/simple/main.cpp index a72a4bb212f..5cf1fca585e 100644 --- a/examples/topic_reader/simple/main.cpp +++ b/examples/topic_reader/simple/main.cpp @@ -35,7 +35,7 @@ struct TOptions { std::shared_ptr ReadSession; void StopHandler(int) { - Cerr << "Stopping session" << Endl; + std::cerr << "Stopping session" << std::endl; if (ReadSession) { ReadSession->Close(TDuration::Seconds(3)); } else { @@ -80,13 +80,13 @@ int main(int argc, const char* argv[]) { // settings.SetSimpleDataHandlers( settings.EventHandlers_.SimpleDataHandlers( [](NYdb::NTopic::TReadSessionEvent::TDataReceivedEvent& event) { - Cerr << "Data event " << DebugString(event); + std::cerr << "Data event " << DebugString(event); }, opts.CommitAfterProcessing); ReadSession = topicClient.CreateReadSession(settings); // [END Create read session] - Cerr << "Session was created" << Endl; + std::cerr << "Session was created" << std::endl; // Wait SessionClosed event. ReadSession->GetEvent(/*block = */true); diff --git a/examples/topic_reader/transaction/application.cpp b/examples/topic_reader/transaction/application.cpp index 171d2b7d37e..f31efc13bab 100644 --- a/examples/topic_reader/transaction/application.cpp +++ b/examples/topic_reader/transaction/application.cpp @@ -37,7 +37,7 @@ void TApplication::CreateTopicReadSession(const TOptions& options) ReadSession = TopicClient->CreateReadSession(settings); - Cout << "Topic session was created" << Endl; + std::cout << "Topic session was created" << std::endl; } void TApplication::CreateTableSession() @@ -48,7 +48,7 @@ void TApplication::CreateTableSession() TableSession = result.GetSession(); - Cout << "Table session was created" << Endl; + std::cout << "Table session was created" << std::endl; } void TApplication::Run() @@ -120,7 +120,7 @@ void TApplication::CommitTransaction() auto result = Transaction->Commit(settings).GetValueSync(); - Cout << "Commit: " << static_cast(result) << Endl; + std::cout << "Commit: " << static_cast(result) << std::endl; } void TApplication::TryCommitTransaction() diff --git a/examples/topic_reader/transaction/main.cpp b/examples/topic_reader/transaction/main.cpp index 95cc49edc22..f3af9a2a0b6 100644 --- a/examples/topic_reader/transaction/main.cpp +++ b/examples/topic_reader/transaction/main.cpp @@ -9,7 +9,7 @@ std::optional App; void StopHandler(int) { - Cout << "Stopping session" << Endl; + std::cout << "Stopping session" << std::endl; if (App) { App->Stop(); } else { @@ -25,10 +25,10 @@ int main(int argc, const char* argv[]) TOptions options(argc, argv); App.emplace(options); - Cout << "Application initialized" << Endl; + std::cout << "Application initialized" << std::endl; App->Run(); - Cout << "Event loop completed" << Endl; + std::cout << "Event loop completed" << std::endl; App->Finalize(); } diff --git a/examples/ttl/ttl.cpp b/examples/ttl/ttl.cpp index aff575f49d8..a7c8861df41 100644 --- a/examples/ttl/ttl.cpp +++ b/examples/ttl/ttl.cpp @@ -211,18 +211,18 @@ static TStatus DeleteDocumentWithTimestamp(TSession session, const std::string& void AddDocument(TTableClient client, const std::string& path, const std::string& url, const std::string& html, const ui64 timestamp) { - Cout << "> AddDocument:" << Endl - << " Url: " << url << Endl - << " Timestamp: " << timestamp << Endl; + std::cout << "> AddDocument:" << std::endl + << " Url: " << url << std::endl + << " Timestamp: " << timestamp << std::endl; ThrowOnError(client.RetryOperationSync([path, url, html, timestamp](TSession session) { return AddDocumentTransaction(session, path, url, html, timestamp); })); - Cout << Endl; + std::cout << std::endl; } void ReadDocument(TTableClient client, const std::string& path, const std::string& url) { - Cout << "> ReadDocument \"" << url << "\":" << Endl; + std::cout << "> ReadDocument \"" << url << "\":" << std::endl; std::optional resultSet; ThrowOnError(client.RetryOperationSync([path, url, &resultSet] (TSession session) { return ReadDocumentTransaction(session, path, url, resultSet); @@ -230,18 +230,18 @@ void ReadDocument(TTableClient client, const std::string& path, const std::strin TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { - Cout << " DocId: " << parser.ColumnParser("doc_id").GetOptionalUint64() << Endl - << " Url: " << parser.ColumnParser("url").GetOptionalUtf8() << Endl - << " Timestamp: " << parser.ColumnParser("timestamp").GetOptionalUint64() << Endl - << " Html: " << parser.ColumnParser("html").GetOptionalUtf8() << Endl; + std::cout << " DocId: " << ToString(parser.ColumnParser("doc_id").GetOptionalUint64()) << std::endl + << " Url: " << ToString(parser.ColumnParser("url").GetOptionalUtf8()) << std::endl + << " Timestamp: " << ToString(parser.ColumnParser("timestamp").GetOptionalUint64()) << std::endl + << " Html: " << ToString(parser.ColumnParser("html").GetOptionalUtf8()) << std::endl; } else { - Cout << " Not found" << Endl; + std::cout << " Not found" << std::endl; } - Cout << Endl; + std::cout << std::endl; } void DeleteExpired(TTableClient client, const std::string& path, const ui32 queue, const ui64 timestamp) { - Cout << "> DeleteExpired from queue #" << queue << ":" << Endl; + std::cout << "> DeleteExpired from queue #" << queue << ":" << std::endl; bool empty = false; ui64 lastTimestamp = 0; ui64 lastDocId = 0; @@ -257,14 +257,14 @@ void DeleteExpired(TTableClient client, const std::string& path, const ui32 queu empty = false; lastDocId = *parser.ColumnParser("doc_id").GetOptionalUint64(); lastTimestamp = *parser.ColumnParser("timestamp").GetOptionalUint64(); - Cout << " DocId: " << lastDocId << " Timestamp: " << lastTimestamp << Endl; + std::cout << " DocId: " << lastDocId << " Timestamp: " << lastTimestamp << std::endl; ThrowOnError(client.RetryOperationSync([path, queue, lastDocId, lastTimestamp] (TSession session) { return DeleteDocumentWithTimestamp(session, path, queue, lastDocId, lastTimestamp); })); } } - Cout << Endl; + std::cout << std::endl; } /////////////////////////////////////////////////////////////////////////////// @@ -311,7 +311,7 @@ bool Run(const TDriver& driver, const std::string& path) { ReadDocument(client, path, "https://ya.ru/"); } catch (const TYdbErrorException& e) { - Cerr << "Execution failed due to fatal error:" << Endl; + std::cerr << "Execution failed due to fatal error:" << std::endl; PrintStatus(e.Status); return false; } diff --git a/examples/ttl/util.h b/examples/ttl/util.h index fe350067305..4971dedea7e 100644 --- a/examples/ttl/util.h +++ b/examples/ttl/util.h @@ -25,8 +25,8 @@ inline void ThrowOnError(const TStatus& status) { } inline void PrintStatus(const TStatus& status) { - Cerr << "Status: " << status.GetStatus() << Endl; - status.GetIssues().PrintTo(Cerr); + std::cerr << "Status: " << ToString(status.GetStatus()) << std::endl; + status.GetIssues().PrintTo(std::cerr); } inline std::string JoinPath(const std::string& basePath, const std::string& path) { diff --git a/library/cpp/blockcodecs/codecs_ut.cpp b/library/cpp/blockcodecs/codecs_ut.cpp index 73d608c77b3..556445055f5 100644 --- a/library/cpp/blockcodecs/codecs_ut.cpp +++ b/library/cpp/blockcodecs/codecs_ut.cpp @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { d.AsString(res); UNIT_ASSERT_EQUAL(NBlockCodecs::TData(res), NBlockCodecs::TData(data)); } catch (...) { - Cerr << c->Name() << "(" << res.Quote() << ")(" << std::string{NBlockCodecs::TData(data)}.Quote() << ")" << Endl; + std::cerr << c->Name() << "(" << res.Quote() << ")(" << std::string{NBlockCodecs::TData(data)}.Quote() << ")" << std::endl; throw; } @@ -183,7 +183,7 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { try { UNIT_ASSERT_EQUAL(resNew, res); } catch (...) { - Cerr << c->Name() << Endl; + std::cerr << c->Name() << std::endl; throw; } diff --git a/library/cpp/charset/wide_ut.cpp b/library/cpp/charset/wide_ut.cpp index 954e9020a82..3b8902f812d 100644 --- a/library/cpp/charset/wide_ut.cpp +++ b/library/cpp/charset/wide_ut.cpp @@ -264,10 +264,6 @@ void TConversionTest::TestRecodeIntoString() { TUtf16String copy = sUnicode; // increase ref-counter wres = NDetail::Recode(UTF8Text, sUnicode, CODES_UTF8); UNIT_ASSERT(sUnicode == UnicodeText); // same content -#ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(sUnicode.data() != wdata); // re-allocated (shared buffer supplied) - UNIT_ASSERT(sUnicode.data() == wres.data()); // same buffer -#endif UNIT_ASSERT(sUnicode.size() == wres.size()); // same content } diff --git a/library/cpp/colorizer/colors.cpp b/library/cpp/colorizer/colors.cpp index be501704c13..75212190d76 100644 --- a/library/cpp/colorizer/colors.cpp +++ b/library/cpp/colorizer/colors.cpp @@ -3,6 +3,8 @@ #include #include +#include + #if defined(_unix_) #include #endif @@ -143,11 +145,11 @@ std::string ToString(NColorizer::EAnsiCode x) { return std::string(ToStringBufC(x)); } -template<> -void Out(IOutputStream& os, TTypeTraits::TFuncParam x) { +std::ostream& operator<<(std::ostream& os, NColorizer::EAnsiCode x) { if (AutoColors(os).IsTTY()) { os << ToStringBufC(x); } + return os; } bool TColors::CalcIsTTY(FILE* file) { @@ -449,11 +451,11 @@ TColors& NColorizer::StdOut() { return *Singleton(); } -TColors& NColorizer::AutoColors(IOutputStream& os) { - if (&os == &Cerr) { +TColors& NColorizer::AutoColors(std::ostream& os) { + if (&os == &std::cerr) { return StdErr(); } - if (&os == &Cout) { + if (&os == &std::cout) { return StdOut(); } return *Singleton(); diff --git a/library/cpp/colorizer/colors.h b/library/cpp/colorizer/colors.h index 875a6f47f30..fab42b5f8ca 100644 --- a/library/cpp/colorizer/colors.h +++ b/library/cpp/colorizer/colors.h @@ -220,7 +220,7 @@ namespace NColorizer { /// Choose `TColors` depending on output stream. If passed stream is stderr/stdout, return a corresponding /// singletone. Otherwise, return a disabled singletone (which you can, but should *not* enable). - TColors& AutoColors(IOutputStream& os); + TColors& AutoColors(std::ostream& os); /// Calculate total length of all ANSI escape codes in the text. size_t TotalAnsiEscapeCodeLen(std::string_view text); diff --git a/library/cpp/colorizer/output.cpp b/library/cpp/colorizer/output.cpp index 66a56266751..017c2fd8854 100644 --- a/library/cpp/colorizer/output.cpp +++ b/library/cpp/colorizer/output.cpp @@ -8,3 +8,8 @@ template <> void Out(IOutputStream& o, const TColorHandle& h) { o << (*(h.C).*h.F)(); } + + +std::ostream& operator<<(std::ostream& o, const TColorHandle& h) { + return o << (*(h.C).*h.F)(); +} diff --git a/library/cpp/colorizer/output.h b/library/cpp/colorizer/output.h index 897d4706844..9582d9d626e 100644 --- a/library/cpp/colorizer/output.h +++ b/library/cpp/colorizer/output.h @@ -43,3 +43,5 @@ namespace NColorizer { #undef DEF } + +std::ostream& operator<<(std::ostream& o, const NColorizer::TColorHandle& h); diff --git a/library/cpp/coroutine/engine/coroutine_ut.cpp b/library/cpp/coroutine/engine/coroutine_ut.cpp index 9ec91cafb0b..e3fce345246 100644 --- a/library/cpp/coroutine/engine/coroutine_ut.cpp +++ b/library/cpp/coroutine/engine/coroutine_ut.cpp @@ -13,6 +13,8 @@ #include #include +#include + // TODO (velavokr): BALANCER-1345 add more tests on pollers class TCoroTest: public TTestBase { @@ -512,7 +514,7 @@ namespace NCoroWaitWakeLivelockBug { struct TSubState { TSubState(TState& parent, ui32 self) : Parent(parent) - , Name(TYdbStringBuilder() << "Sub" << self) + , Name(TStringBuilder() << "Sub" << self) , Self(self) { UNIT_ASSERT(self < 2); @@ -600,7 +602,7 @@ namespace NCoroTestFastPathWake { struct TSubState { TSubState(TState& parent, ui32 self) : Parent(parent) - , Name(TYdbStringBuilder() << "Sub" << self) + , Name(TStringBuilder() << "Sub" << self) {} TState& Parent; @@ -634,11 +636,11 @@ namespace NCoroTestFastPathWake { UNIT_ASSERT_VALUES_EQUAL(res.Checked(), 0); state.IoSleepRunning = false; } catch (const NUnitTest::TAssertException& ex) { - Cerr << ex.AsStrBuf() << Endl; - ex.BackTrace()->PrintTo(Cerr); + std::cerr << ex.AsStrBuf() << std::endl; + ex.BackTrace()->PrintTo(std::cerr); throw; } catch (...) { - Cerr << CurrentExceptionMessage() << Endl; + std::cerr << CurrentExceptionMessage() << std::endl; throw; } } @@ -697,11 +699,11 @@ namespace NCoroTestFastPathWake { // Check everything has ended sooner than the timeout UNIT_ASSERT(TInstant::Now() - start < TDuration::Seconds(1)); } catch (const NUnitTest::TAssertException& ex) { - Cerr << ex.AsStrBuf() << Endl; - ex.BackTrace()->PrintTo(Cerr); + std::cerr << ex.AsStrBuf() << std::endl; + ex.BackTrace()->PrintTo(std::cerr); throw; } catch (...) { - Cerr << CurrentExceptionMessage() << Endl; + std::cerr << CurrentExceptionMessage() << std::endl; throw; } } @@ -952,7 +954,7 @@ void TCoroTest::TestPollEngines() { } void TCoroTest::TestPause() { - TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing()}; + TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, std::nullopt}; int i = 0; executor.CreateOwned([&](TCont*) { @@ -1002,7 +1004,7 @@ void TCoroTest::TestOverrideTime() { }; TTime time; - TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing(), &time}; + TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, std::nullopt, &time}; executor.CreateOwned([&](TCont* cont) { UNIT_ASSERT_EQUAL(cont->Executor()->Now(), TInstant::Zero()); diff --git a/library/cpp/cppparser/parser.cpp b/library/cpp/cppparser/parser.cpp index b5d0c1205e7..72b8dc5d384 100644 --- a/library/cpp/cppparser/parser.cpp +++ b/library/cpp/cppparser/parser.cpp @@ -106,8 +106,8 @@ class TCppSaxParser::TImpl { } #if DEBUG_ME - Cerr << "char: " << ch << Endl; - Cerr << "state before: " << (unsigned int)State_ << Endl; + std::cerr << "char: " << ch << std::endl; + std::cerr << "state before: " << (unsigned int)State_ << std::endl; #endif retry: @@ -348,7 +348,7 @@ class TCppSaxParser::TImpl { } #if DEBUG_ME - Cerr << "state after: " << (unsigned int)State_ << Endl; + std::cerr << "state after: " << (unsigned int)State_ << std::endl; #endif ++data; diff --git a/library/cpp/dbg_output/auto.h b/library/cpp/dbg_output/auto.h index 8d96167f6ac..d16574938d6 100644 --- a/library/cpp/dbg_output/auto.h +++ b/library/cpp/dbg_output/auto.h @@ -2,13 +2,13 @@ #include -// int a = 1, b = 2; Cout << LabeledDump(a, b, 1 + 2); yields {"a": 1, "b": 2, "1 + 2": 3} +// int a = 1, b = 2; std::cout << LabeledDump(a, b, 1 + 2); yields {"a": 1, "b": 2, "1 + 2": 3} #define LabeledDump(...) \ '{' Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_DUMP_NONLAST__, __LABELED_DUMP_IMPL__, __VA_ARGS__)) << '}' #define __LABELED_DUMP_IMPL__(x) << "\"" #x "\": " << DbgDump(x) #define __LABELED_DUMP_NONLAST__(x) __LABELED_DUMP_IMPL__(x) << ", " -// Usage: struct TMyStruct { int A, B; }; DEFINE_DUMPER(TMyStruct, A, B); Cout << TMyStruct{3, 4}; +// Usage: struct TMyStruct { int A, B; }; DEFINE_DUMPER(TMyStruct, A, B); std::cout << TMyStruct{3, 4}; // yields {"A": 3, "B": 4} #define DEFINE_DUMPER(C, ...) \ template <> \ diff --git a/library/cpp/dbg_output/dump.h b/library/cpp/dbg_output/dump.h index c7efa105ee6..6f6f338fbf2 100644 --- a/library/cpp/dbg_output/dump.h +++ b/library/cpp/dbg_output/dump.h @@ -11,9 +11,9 @@ #include /* - * Cout << DbgDump(any) << Endl; - * Cout << DbgDumpDeep(any) << Endl; - * Cout << DbgDump(any).SetIndent(true) << Endl; + * std::cout << DbgDump(any) << std::endl; + * std::cout << DbgDumpDeep(any) << std::endl; + * std::cout << DbgDump(any).SetIndent(true) << std::endl; * * specialize TDumper for extending dumper */ diff --git a/library/cpp/diff/diff_ut.cpp b/library/cpp/diff/diff_ut.cpp index 140db6a4642..7a3ac24c952 100644 --- a/library/cpp/diff/diff_ut.cpp +++ b/library/cpp/diff/diff_ut.cpp @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa", "aaa"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa"); } @@ -61,11 +61,11 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa", "bbb"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|bbb)"); tester.Test("aaa", "bbbb"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|bbbb)"); } @@ -73,19 +73,19 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa", "abb", ""); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "a(aa|bb)"); tester.Test("aac", "abc", ""); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "a(a|b)c"); tester.Test("123", "133", ""); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "1(2|3)3"); tester.Test("[1, 2, 3]", "[1, 3, 3]", ""); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "[1, (2|3), 3]"); } @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("abcde", "accfg"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(abcde|accfg)"); } @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(DiffTokens) { std::string_view str("aaa bbb"); tester.Test(str, str); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa bbb"); } @@ -111,11 +111,11 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa bbb", "ccc ddd"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|ccc) (bbb|ddd)"); tester.Test("aaa bbb", "c d"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|c) (bbb|d)"); } @@ -123,11 +123,11 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa ccd", "abb cce"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|abb) (ccd|cce)"); tester.Test("aac cbb", "aa bb"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aac|aa) (cbb|bb)"); } @@ -135,19 +135,19 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa bbb", "bbb aaa"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(|bbb )aaa( bbb|)"); tester.Test("aaa bbb", " bbb aaa"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) bbb(| aaa)"); tester.Test(" aaa bbb ", " bbb aaa "); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(| bbb) aaa (bbb |)"); tester.Test("aaa bb", " bbb aa"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) (bb|bbb aa)"); } @@ -155,19 +155,19 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa bbb", "aaa"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa( bbb|)"); tester.Test("aaa bbb", "aaa "); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa (bbb|)"); tester.Test("aaa bbb", " bbb"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) bbb"); tester.Test("aaa bbb", "bbb"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa |)bbb"); } @@ -175,11 +175,11 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa\nabc\nbbb", "aaa\nacc\nbbb"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa\n(abc|acc)\nbbb"); tester.Test("aaa\nabc\nbbb", "aaa\nac\nbbb"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa\n(abc|ac)\nbbb"); } @@ -187,11 +187,11 @@ Y_UNIT_TEST_SUITE(DiffTokens) { TDiffTester tester; tester.Test("aaa bbb", "aaa\tbbb"); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa( |\t)bbb"); tester.Test(" aaa\tbbb\n", "\taaa\nbbb "); - //~ Cerr << tester.Result() << Endl; + //~ std::cerr << tester.Result() << std::endl; UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "( |\t)aaa(\t|\n)bbb(\n| )"); } } diff --git a/library/cpp/getopt/last_getopt_demo/demo.cpp b/library/cpp/getopt/last_getopt_demo/demo.cpp index 66f81e94547..4173ab3a71a 100644 --- a/library/cpp/getopt/last_getopt_demo/demo.cpp +++ b/library/cpp/getopt/last_getopt_demo/demo.cpp @@ -59,7 +59,7 @@ class TMain: public TMainClassArgs { .IfPresentDisableCompletion() .NoArgument() .Handler([]() { - Cerr << "last_getopt_demo 1.0.0" << Endl; + std::cerr << "last_getopt_demo 1.0.0" << std::endl; exit(0); }); @@ -208,28 +208,28 @@ class TMain: public TMainClassArgs { std::string method = ExplicitMethod_ ? ExplicitMethod_ : ImplicitMethod_; - Cerr << ST_LIGHT << "Settings:" << RESET << Endl; - Cerr << GREEN << " Background: " << RESET << Background_ << Endl; - Cerr << GREEN << " Timeout: " << RESET << Timeout_ << Endl; - Cerr << GREEN << " Method: " << RESET << method.Quote() << Endl; - Cerr << GREEN << " UserAgent: " << RESET << UserAgent_.Quote() << Endl; - Cerr << GREEN << " PostData: " << RESET << (PostData_ ? PostData_->Quote() : "Nothing") << Endl; - Cerr << GREEN << " PostFile: " << RESET << (PostFile_ ? PostFile_->Quote() : "Nothing") << Endl; + std::cerr << ST_LIGHT << "Settings:" << RESET << std::endl; + std::cerr << GREEN << " Background: " << RESET << Background_ << std::endl; + std::cerr << GREEN << " Timeout: " << RESET << Timeout_ << std::endl; + std::cerr << GREEN << " Method: " << RESET << method.Quote() << std::endl; + std::cerr << GREEN << " UserAgent: " << RESET << UserAgent_.Quote() << std::endl; + std::cerr << GREEN << " PostData: " << RESET << (PostData_ ? PostData_->Quote() : "Nothing") << std::endl; + std::cerr << GREEN << " PostFile: " << RESET << (PostFile_ ? PostFile_->Quote() : "Nothing") << std::endl; - Cerr << ST_LIGHT << "Headers:" << RESET << Endl; + std::cerr << ST_LIGHT << "Headers:" << RESET << std::endl; for (auto& header : Headers_) { - Cerr << " " << header.Quote() << Endl; + std::cerr << " " << header.Quote() << std::endl; } if (!Headers_) { - Cerr << GREEN << " no headers" << RESET << Endl; + std::cerr << GREEN << " no headers" << RESET << std::endl; } - Cerr << ST_LIGHT << "Will download the following URLs:" << RESET << Endl; + std::cerr << ST_LIGHT << "Will download the following URLs:" << RESET << std::endl; for (auto& arg : parsedOptions.GetFreeArgs()) { - Cerr << " " << arg.Quote() << Endl; + std::cerr << " " << arg.Quote() << std::endl; } if (!parsedOptions.GetFreeArgs()) { - Cerr << " no urls" << Endl; + std::cerr << " no urls" << std::endl; } return 0; } diff --git a/library/cpp/getopt/small/completer.cpp b/library/cpp/getopt/small/completer.cpp index 045c4146af7..f5a1bf73bc2 100644 --- a/library/cpp/getopt/small/completer.cpp +++ b/library/cpp/getopt/small/completer.cpp @@ -263,7 +263,7 @@ namespace NLastGetopt::NComp { } void TCustomCompleter::AddCompletion(std::string_view completion) { - Cout << completion << Endl; // this was easy =) + std::cout << completion << std::endl; // this was easy =) // TODO: support option descriptions and messages } @@ -275,12 +275,12 @@ namespace NLastGetopt::NComp { } if (!root.empty()) { - Cout << root << Sep_ << Endl; + std::cout << root << Sep_ << std::endl; } else { - Cout << Endl; + std::cout << std::endl; } - Cout << Sep_ << Endl; + std::cout << Sep_ << std::endl; GenerateCompletionParts(argc, argv, curIdx, cur, prefix, suffix, root); } diff --git a/library/cpp/getopt/small/completer_command.cpp b/library/cpp/getopt/small/completer_command.cpp index 8226c0f9de6..3a3d6cedec9 100644 --- a/library/cpp/getopt/small/completer_command.cpp +++ b/library/cpp/getopt/small/completer_command.cpp @@ -97,13 +97,13 @@ namespace NLastGetopt { .Completer(ShellChoiceCompleter()) .Handler1T([opts, command, name](std::string_view shell) { if (shell.empty()) { - Cerr << Wrap(80, MakeInfo(command, "--" + name)) << Endl; + std::cerr << Wrap(80, MakeInfo(command, "--" + name)) << std::endl; } else if (shell == "bash") { - TBashCompletionGenerator(opts).Generate(command, Cout); + TBashCompletionGenerator(opts).Generate(command, std::cout); } else if (shell == "zsh") { - TZshCompletionGenerator(opts).Generate(command, Cout); + TZshCompletionGenerator(opts).Generate(command, std::cout); } else { - Cerr << "Unknown shell name " << NUtils::Quote(shell) << Endl; + std::cerr << "Unknown shell name " << NUtils::Quote(shell) << std::endl; exit(1); } exit(0); @@ -140,11 +140,11 @@ namespace NLastGetopt { NUtils::ToLower(arg); if (arg == "bash") { - TBashCompletionGenerator(Modes_).Generate(Command_, Cout); + TBashCompletionGenerator(Modes_).Generate(Command_, std::cout); } else if (arg == "zsh") { - TZshCompletionGenerator(Modes_).Generate(Command_, Cout); + TZshCompletionGenerator(Modes_).Generate(Command_, std::cout); } else { - Cerr << "Unknown shell name " << NUtils::Quote(arg) << Endl; + std::cerr << "Unknown shell name " << NUtils::Quote(arg) << std::endl; parsedOptions.PrintUsage(); return 1; } diff --git a/library/cpp/getopt/small/completion_generator.cpp b/library/cpp/getopt/small/completion_generator.cpp index 3e418500471..e8f4925ce05 100644 --- a/library/cpp/getopt/small/completion_generator.cpp +++ b/library/cpp/getopt/small/completion_generator.cpp @@ -30,7 +30,7 @@ namespace NLastGetopt { Y_ABORT_UNLESS(opts != nullptr); } - void TZshCompletionGenerator::Generate(std::string_view command, IOutputStream& stream) { + void TZshCompletionGenerator::Generate(std::string_view command, std::ostream& stream) { TFormattedOutput out; NComp::TCompleterManager manager{command}; @@ -370,7 +370,7 @@ namespace NLastGetopt { line << "' \\"; } - void TBashCompletionGenerator::Generate(std::string_view command, IOutputStream& stream) { + void TBashCompletionGenerator::Generate(std::string_view command, std::ostream& stream) { TFormattedOutput out; NComp::TCompleterManager manager{command}; diff --git a/library/cpp/getopt/small/completion_generator.h b/library/cpp/getopt/small/completion_generator.h index 846cc9904fa..e5bafba2864 100644 --- a/library/cpp/getopt/small/completion_generator.h +++ b/library/cpp/getopt/small/completion_generator.h @@ -15,7 +15,7 @@ namespace NLastGetopt { virtual ~TCompletionGenerator() = default; public: - virtual void Generate(std::string_view command, IOutputStream& stream) = 0; + virtual void Generate(std::string_view command, std::ostream& stream) = 0; protected: std::variant Options_; @@ -26,7 +26,7 @@ namespace NLastGetopt { using TCompletionGenerator::TCompletionGenerator; public: - void Generate(std::string_view command, IOutputStream& stream) override; + void Generate(std::string_view command, std::ostream& stream) override; private: static void GenerateModesCompletion(TFormattedOutput& out, const TModChooser& chooser, NComp::TCompleterManager& manager); @@ -40,7 +40,7 @@ namespace NLastGetopt { using TCompletionGenerator::TCompletionGenerator; public: - void Generate(std::string_view command, IOutputStream& stream) override; + void Generate(std::string_view command, std::ostream& stream) override; private: static void GenerateModesCompletion(TFormattedOutput& out, const TModChooser& chooser, NComp::TCompleterManager& manager, size_t level); diff --git a/library/cpp/getopt/small/formatted_output.cpp b/library/cpp/getopt/small/formatted_output.cpp index 16b8c7681ce..9292d710766 100644 --- a/library/cpp/getopt/small/formatted_output.cpp +++ b/library/cpp/getopt/small/formatted_output.cpp @@ -3,6 +3,8 @@ #include #include +#include + namespace NLastGetopt { TFormattedOutput::IndentGuard::IndentGuard(TFormattedOutput* output) @@ -23,16 +25,16 @@ namespace NLastGetopt { return Lines_.emplace_back(IndentLevel_, TStringBuilder()).second; } - void TFormattedOutput::Print(IOutputStream& out) { + void TFormattedOutput::Print(std::ostream& out) { for (auto&[indent, line] : Lines_) { if (indent && !line.empty()) { TTempBuf buf(indent); Fill(buf.Data(), buf.Data() + indent, ' '); - out.Write(buf.Data(), indent); + out.write(buf.Data(), indent); } out << line; if (!std::string_view(line).ends_with('\n')) { - out << Endl; + out << std::endl; } } } diff --git a/library/cpp/getopt/small/formatted_output.h b/library/cpp/getopt/small/formatted_output.h index afabbbaac71..06a2dad5af3 100644 --- a/library/cpp/getopt/small/formatted_output.h +++ b/library/cpp/getopt/small/formatted_output.h @@ -22,7 +22,7 @@ namespace NLastGetopt { TStringBuilder& Line(); /// Collect all lines into a stream. - void Print(IOutputStream& out); + void Print(std::ostream& out); private: int IndentLevel_ = 0; diff --git a/library/cpp/getopt/small/last_getopt_opts.cpp b/library/cpp/getopt/small/last_getopt_opts.cpp index 466e9289212..0370445c29f 100644 --- a/library/cpp/getopt/small/last_getopt_opts.cpp +++ b/library/cpp/getopt/small/last_getopt_opts.cpp @@ -26,12 +26,12 @@ namespace NLastGetopt { static const std::string_view SPad = " "; void PrintVersionAndExit(const TOptsParser*) { - Cout << (!NLastGetoptPrivate::VersionString().empty() ? NLastGetoptPrivate::VersionString() : "program version: not linked with library/cpp/getopt") << Endl; + std::cout << (!NLastGetoptPrivate::VersionString().empty() ? NLastGetoptPrivate::VersionString() : "program version: not linked with library/cpp/getopt") << std::endl; exit(NLastGetoptPrivate::VersionString().empty()); } void PrintShortVersionAndExit(const std::string& appName) { - Cout << appName << " version " << (!NLastGetoptPrivate::ShortVersionString().empty() ? NLastGetoptPrivate::ShortVersionString() : "not linked with library/cpp/getopt") << Endl; + std::cout << appName << " version " << (!NLastGetoptPrivate::ShortVersionString().empty() ? NLastGetoptPrivate::ShortVersionString() : "not linked with library/cpp/getopt") << std::endl; exit(NLastGetoptPrivate::ShortVersionString().empty()); } @@ -323,7 +323,7 @@ namespace NLastGetopt { return result.Str(); } - void TOpts::PrintCmdLine(const std::string_view& program, IOutputStream& os, const NColorizer::TColors& colors) const { + void TOpts::PrintCmdLine(const std::string_view& program, std::ostream& os, const NColorizer::TColors& colors) const { os << colors.BoldColor() << "Usage" << colors.OldColor() << ": "; if (!CustomUsage.empty()) { os << CustomUsage; @@ -331,7 +331,7 @@ namespace NLastGetopt { os << program << " "; } if (!CustomCmdLineDescr.empty()) { - os << CustomCmdLineDescr << Endl; + os << CustomCmdLineDescr << std::endl; return; } os << "[OPTIONS]"; @@ -361,11 +361,11 @@ namespace NLastGetopt { os << " [" << TrailingArgSpec_.GetTitle(DefaultFreeArgTitle_) << "]..."; } - os << Endl; + os << std::endl; } - void TOpts::PrintUsage(const std::string_view& program, IOutputStream& osIn, const NColorizer::TColors& colors) const { - TStringStream os; + void TOpts::PrintUsage(const std::string_view& program, std::ostream& osIn, const NColorizer::TColors& colors) const { + std::stringstream os; if (!Title.empty()) os << Title << "\n\n"; @@ -404,14 +404,14 @@ namespace NLastGetopt { if (requiredOptionsSection) { if (requiredOptionsCount == 0) continue; - os << Endl << colors.BoldColor() << "Required parameters" << colors.OldColor() << ":" << Endl; + os << std::endl << colors.BoldColor() << "Required parameters" << colors.OldColor() << ":" << std::endl; } else { if (requiredOptionsCount == Opts_.size()) continue; if (requiredOptionsCount == 0) - os << Endl << colors.BoldColor() << "Options" << colors.OldColor() << ":" << Endl; + os << std::endl << colors.BoldColor() << "Options" << colors.OldColor() << ":" << std::endl; else - os << Endl << colors.BoldColor() << "Optional parameters" << colors.OldColor() << ":" << Endl; // optional options would be a tautology + os << std::endl << colors.BoldColor() << "Optional parameters" << colors.OldColor() << ":" << std::endl; // optional options would be a tautology } for (size_t i = 0; i < Opts_.size(); i++) { @@ -423,7 +423,7 @@ namespace NLastGetopt { continue; if (leftColumnSizes[i] > leftWidth && !opt->GetHelp().empty()) { - os << SPad << leftColumn[i] << Endl << SPad << leftPadding << ' '; + os << SPad << leftColumn[i] << std::endl << SPad << leftPadding << ' '; } else { os << SPad << leftColumn[i] << ' '; if (leftColumnSizes[i] < leftWidth) @@ -443,7 +443,7 @@ namespace NLastGetopt { auto choicesHelp = opt->GetChoicesHelp(); if (!choicesHelp.empty()) { if (!help.empty()) { - os << Endl << SPad << leftPadding << " "; + os << std::endl << SPad << leftPadding << " "; } os << "(values: " << choicesHelp << ")"; } @@ -451,14 +451,14 @@ namespace NLastGetopt { if (opt->HasDefaultValue()) { auto quotedDef = QuoteForHelp(opt->GetDefaultValue()); if (helpHasParagraphs) { - os << Endl << Endl << SPad << leftPadding << " "; + os << std::endl << std::endl << SPad << leftPadding << " "; os << "Default: " << colors.CyanColor() << quotedDef << colors.OldColor() << "."; } else if (help.ends_with('.')) { - os << Endl << SPad << leftPadding << " "; + os << std::endl << SPad << leftPadding << " "; os << "Default: " << colors.CyanColor() << quotedDef << colors.OldColor() << "."; } else if (!help.empty()) { if (SPad.size() + leftWidth + 1 + lastLineLength + 12 + quotedDef.size() > Wrap_) { - os << Endl << SPad << leftPadding << " "; + os << std::endl << SPad << leftPadding << " "; } else { os << " "; } @@ -468,10 +468,10 @@ namespace NLastGetopt { } } - os << Endl; + os << std::endl; if (helpHasParagraphs) { - os << Endl; + os << std::endl; } } } @@ -479,19 +479,19 @@ namespace NLastGetopt { PrintFreeArgsDesc(os, colors); for (auto& [heading, text] : Sections) { - os << Endl << colors.BoldColor() << heading << colors.OldColor() << ":" << Endl; + os << std::endl << colors.BoldColor() << heading << colors.OldColor() << ":" << std::endl; - os << SPad << Wrap(Wrap_, text, SPad) << Endl; + os << SPad << Wrap(Wrap_, text, SPad) << std::endl; } - osIn << os.Str(); + osIn << os.str(); } - void TOpts::PrintUsage(const std::string_view& program, IOutputStream& os) const { + void TOpts::PrintUsage(const std::string_view& program, std::ostream& os) const { PrintUsage(program, os, NColorizer::AutoColors(os)); } - void TOpts::PrintFreeArgsDesc(IOutputStream& os, const NColorizer::TColors& colors) const { + void TOpts::PrintFreeArgsDesc(std::ostream& os, const NColorizer::TColors& colors) const { if (0 == FreeArgsMax_) return; @@ -505,7 +505,7 @@ namespace NLastGetopt { } leftFreeWidth = Min(leftFreeWidth, size_t(30)); - os << Endl << colors.BoldColor() << "Free args" << colors.OldColor() << ":"; + os << std::endl << colors.BoldColor() << "Free args" << colors.OldColor() << ":"; os << " min: " << colors.GreenColor() << FreeArgsMin_ << colors.OldColor() << ","; os << " max: " << colors.GreenColor(); @@ -514,7 +514,7 @@ namespace NLastGetopt { } else { os << "unlimited"; } - os << colors.OldColor() << Endl; + os << colors.OldColor() << std::endl; const size_t limit = FreeArgSpecs_.empty() ? 0 : FreeArgSpecs_.rbegin()->first; for (size_t i = 0; i <= limit; ++i) { @@ -524,8 +524,8 @@ namespace NLastGetopt { auto help = FreeArgSpecs_.at(i).GetHelp(); if (!help.empty()) { auto title = GetFreeArgTitle(i); - os << SPad << colors.GreenColor() << RightPad(title, leftFreeWidth, ' ') << colors.OldColor() - << SPad << help << Endl; + os << SPad << colors.GreenColor() << ToString(RightPad(title, leftFreeWidth, ' ')) << colors.OldColor() + << SPad << help << std::endl; } } @@ -533,8 +533,8 @@ namespace NLastGetopt { auto title = TrailingArgSpec_.GetTitle(DefaultFreeArgTitle_); auto help = TrailingArgSpec_.GetHelp(); if (!help.empty()) { - os << SPad << colors.GreenColor() << RightPad(title, leftFreeWidth, ' ') << colors.OldColor() - << SPad << help << Endl; + os << SPad << colors.GreenColor() << ToString(RightPad(title, leftFreeWidth, ' ')) << colors.OldColor() + << SPad << help << std::endl; } } } diff --git a/library/cpp/getopt/small/last_getopt_opts.h b/library/cpp/getopt/small/last_getopt_opts.h index 4297b2556f5..3e0ead7b6a5 100644 --- a/library/cpp/getopt/small/last_getopt_opts.h +++ b/library/cpp/getopt/small/last_getopt_opts.h @@ -2,9 +2,10 @@ #include "last_getopt_opt.h" -#include #include +#include +#include namespace NLastGetopt { enum EArgPermutation { @@ -602,7 +603,7 @@ namespace NLastGetopt { * @param os destination stream * @param colors colorizer */ - void PrintUsage(const std::string_view& program, IOutputStream& os, const NColorizer::TColors& colors) const; + void PrintUsage(const std::string_view& program, std::ostream& os, const NColorizer::TColors& colors) const; /** * Print usage string @@ -610,7 +611,7 @@ namespace NLastGetopt { * @param program prefix of result (path to the program) * @param os destination stream */ - void PrintUsage(const std::string_view& program, IOutputStream& os = Cout) const; + void PrintUsage(const std::string_view& program, std::ostream& os = std::cout) const; /** * Get list of options in order of definition. @@ -639,7 +640,7 @@ namespace NLastGetopt { * @param os destination stream * @param colors colorizer */ - void PrintCmdLine(const std::string_view& program, IOutputStream& os, const NColorizer::TColors& colors) const; + void PrintCmdLine(const std::string_view& program, std::ostream& os, const NColorizer::TColors& colors) const; /** * Print usage helper @@ -647,7 +648,7 @@ namespace NLastGetopt { * @param os destination stream * @param colors colorizer */ - void PrintFreeArgsDesc(IOutputStream& os, const NColorizer::TColors& colors) const; + void PrintFreeArgsDesc(std::ostream& os, const NColorizer::TColors& colors) const; }; } diff --git a/library/cpp/getopt/small/last_getopt_parse_result.cpp b/library/cpp/getopt/small/last_getopt_parse_result.cpp index 42522264c33..3b566aa976d 100644 --- a/library/cpp/getopt/small/last_getopt_parse_result.cpp +++ b/library/cpp/getopt/small/last_getopt_parse_result.cpp @@ -99,7 +99,7 @@ namespace NLastGetopt { return Parser_->ProgramName_; } - void TOptsParseResult::PrintUsage(IOutputStream& os) const { + void TOptsParseResult::PrintUsage(std::ostream& os) const { Parser_->Opts_->PrintUsage(Parser_->ProgramName_, os); } @@ -162,10 +162,10 @@ namespace NLastGetopt { } void TOptsParseResult::HandleError() const { - Cerr << CurrentExceptionMessage() << Endl; + std::cerr << CurrentExceptionMessage() << std::endl; if (Parser_.Get()) { // parser initializing can fail (and we get here, see Init) if (Parser_->Opts_->FindLongOption("help") != nullptr) { - Cerr << "Try '" << Parser_->ProgramName_ << " --help' for more information." << Endl; + std::cerr << "Try '" << Parser_->ProgramName_ << " --help' for more information." << std::endl; } else { PrintUsage(); } diff --git a/library/cpp/getopt/small/last_getopt_parse_result.h b/library/cpp/getopt/small/last_getopt_parse_result.h index d786b7c0cef..09c0d09157e 100644 --- a/library/cpp/getopt/small/last_getopt_parse_result.h +++ b/library/cpp/getopt/small/last_getopt_parse_result.h @@ -165,7 +165,7 @@ namespace NLastGetopt { /** * Print usage string. */ - void PrintUsage(IOutputStream& os = Cout) const; + void PrintUsage(std::ostream& os = std::cout) const; /** * @return position in [premuted argv] of the first free argument diff --git a/library/cpp/getopt/small/last_getopt_parser.cpp b/library/cpp/getopt/small/last_getopt_parser.cpp index 335dbed5227..40025d70b5f 100644 --- a/library/cpp/getopt/small/last_getopt_parser.cpp +++ b/library/cpp/getopt/small/last_getopt_parser.cpp @@ -379,11 +379,11 @@ namespace NLastGetopt { throw usage; // don't need lineinfo, just the message } - void TOptsParser::PrintUsage(IOutputStream& os, const NColorizer::TColors& colors) const { + void TOptsParser::PrintUsage(std::ostream& os, const NColorizer::TColors& colors) const { Opts_->PrintUsage(ProgramName(), os, colors); } - void TOptsParser::PrintUsage(IOutputStream& os) const { + void TOptsParser::PrintUsage(std::ostream& os) const { PrintUsage(os, NColorizer::AutoColors(os)); } diff --git a/library/cpp/getopt/small/last_getopt_parser.h b/library/cpp/getopt/small/last_getopt_parser.h index 3a1305e8db0..5e509499366 100644 --- a/library/cpp/getopt/small/last_getopt_parser.h +++ b/library/cpp/getopt/small/last_getopt_parser.h @@ -3,7 +3,9 @@ #include "last_getopt_opts.h" #include + #include +#include namespace NLastGetopt { /** @@ -145,8 +147,8 @@ namespace NLastGetopt { return ProgramName_; } - void PrintUsage(IOutputStream& os = Cout) const; + void PrintUsage(std::ostream& os = std::cout) const; - void PrintUsage(IOutputStream& os, const NColorizer::TColors& colors) const; + void PrintUsage(std::ostream& os, const NColorizer::TColors& colors) const; }; } //namespace NLastGetopt diff --git a/library/cpp/getopt/small/modchooser.cpp b/library/cpp/getopt/small/modchooser.cpp index 03a6e31484b..9379adee798 100644 --- a/library/cpp/getopt/small/modchooser.cpp +++ b/library/cpp/getopt/small/modchooser.cpp @@ -194,7 +194,7 @@ int TModChooser::Run(const int argc, const char** argv) const { } if (modeIter == Modes.end()) { - Cerr << "Unknown mode " << NUtils::Quote(modeName) << "." << Endl; + std::cerr << "Unknown mode " << NUtils::Quote(modeName) << "." << std::endl; PrintHelp(argv[0], true); return 1; } @@ -276,12 +276,12 @@ std::string TModChooser::TMode::FormatFullName(size_t pad) const { void TModChooser::PrintHelp(const std::string& progName, bool toStdErr) const { auto baseName = TFsPath(progName).Basename(); - auto& out = toStdErr ? Cerr : Cout; + auto& out = toStdErr ? std::cerr : std::cout; const auto& colors = toStdErr ? NColorizer::StdErr() : NColorizer::StdOut(); - out << Description << Endl << Endl; - out << colors.BoldColor() << "Usage" << colors.OldColor() << ": " << baseName << " MODE [MODE_OPTIONS]" << Endl; - out << Endl; - out << colors.BoldColor() << "Modes" << colors.OldColor() << ":" << Endl; + out << Description << std::endl << std::endl; + out << colors.BoldColor() << "Usage" << colors.OldColor() << ": " << baseName << " MODE [MODE_OPTIONS]" << std::endl; + out << std::endl; + out << colors.BoldColor() << "Modes" << colors.OldColor() << ":" << std::endl; size_t maxModeLen = 0; for (const auto& [name, mode] : Modes) { if (name != mode->Name) @@ -293,10 +293,10 @@ void TModChooser::PrintHelp(const std::string& progName, bool toStdErr) const { for (const auto& unsortedMode : UnsortedModes) if (!unsortedMode->Hidden) { if (unsortedMode->Name.size()) { - out << " " << unsortedMode->FormatFullName(maxModeLen + 4) << unsortedMode->Description << Endl; + out << " " << unsortedMode->FormatFullName(maxModeLen + 4) << unsortedMode->Description << std::endl; } else { - out << SeparationString << Endl; - out << unsortedMode->Description << Endl; + out << SeparationString << std::endl; + out << unsortedMode->Description << std::endl; } } } else { @@ -305,17 +305,17 @@ void TModChooser::PrintHelp(const std::string& progName, bool toStdErr) const { continue; // this is an alias if (!mode.second->Hidden) { - out << " " << mode.second->FormatFullName(maxModeLen + 4) << mode.second->Description << Endl; + out << " " << mode.second->FormatFullName(maxModeLen + 4) << mode.second->Description << std::endl; } } } - out << Endl; - out << "To get help for specific mode type '" << baseName << " MODE " << ModesHelpOption << "'" << Endl; + out << std::endl; + out << "To get help for specific mode type '" << baseName << " MODE " << ModesHelpOption << "'" << std::endl; if (VersionHandler) - out << "To print program version type '" << baseName << " --version'" << Endl; + out << "To print program version type '" << baseName << " --version'" << std::endl; if (!SvnRevisionOptionDisabled) { - out << "To print svn revision type '" << baseName << " --svnrevision'" << Endl; + out << "To print svn revision type '" << baseName << " --svnrevision'" << std::endl; } } diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp index 73ff2a582c5..f98e0325f77 100644 --- a/library/cpp/getopt/small/opt.cpp +++ b/library/cpp/getopt/small/opt.cpp @@ -83,12 +83,12 @@ int Opt::Get(int* longOptionIndex) { } catch (const NLastGetopt::TException&) { GotError_ = true; if (Err) - Cerr << CurrentExceptionMessage() << Endl; + std::cerr << CurrentExceptionMessage() << std::endl; return '?'; } } -void Opt::DummyHelp(IOutputStream& os) { +void Opt::DummyHelp(std::ostream& os) { Opts_->PrintUsage(GetProgramName(), os); } diff --git a/library/cpp/getopt/small/opt.h b/library/cpp/getopt/small/opt.h index 86aca666667..74a96ad038f 100644 --- a/library/cpp/getopt/small/opt.h +++ b/library/cpp/getopt/small/opt.h @@ -106,7 +106,7 @@ class Opt : TNonCopyable { int GetArgC() const; const char** GetArgV() const; - void DummyHelp(IOutputStream& os = Cerr); + void DummyHelp(std::ostream& os = std::cerr); }; // call before getopt. returns non-negative int, removing it from arguments (not found: -1) diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp index 6d1bb2671a8..bcf6f0fee81 100644 --- a/library/cpp/http/fetch/httpfsm_ut.cpp +++ b/library/cpp/http/fetch/httpfsm_ut.cpp @@ -501,7 +501,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { for (size_t n = 0; n < states.size(); n++) { const std::string_view d{blob, n, 1}; int code = parser.Execute(d.data(), d.size()); - Cout << std::string(d).Quote() << " " << code << Endl; + std::cout << std::string(d).Quote() << " " << code << std::endl; UNIT_ASSERT_EQUAL(code, states[n]); } return parser; diff --git a/library/cpp/http/fetch/httpparser_ut.cpp b/library/cpp/http/fetch/httpparser_ut.cpp index 58eca2f8835..8a7af7f4a3f 100644 --- a/library/cpp/http/fetch/httpparser_ut.cpp +++ b/library/cpp/http/fetch/httpparser_ut.cpp @@ -39,7 +39,7 @@ namespace { // other functions are not really called by THttpParser void CheckDocPart(const void* buf, size_t len, THttpHeader* /* header */) { std::string s(static_cast(buf), len); - Cout << "State = " << static_cast(this)->GetState() << ", CheckDocPart(" << s.Quote() << ")\n"; + std::cout << "State = " << static_cast(this)->GetState() << ", CheckDocPart(" << s.Quote() << ")\n"; Body_ += s; } }; @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { for (size_t i = 0; i < blob.size(); ++i) { const std::string_view d{blob, i, 1}; parser.Parse((void*)d.data(), d.size()); - Cout << std::string(d).Quote() << " -> " << parser.GetState() << Endl; + std::cout << std::string(d).Quote() << " -> " << parser.GetState() << std::endl; } AssertPipelineClen(parser, hdr); UNIT_ASSERT_EQUAL(parser.Body(), "OK\r\n"); @@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { for (size_t i = 0; i < blob.size(); ++i) { const std::string_view d{blob, i, 1}; parser.Parse((void*)d.data(), d.size()); - Cout << std::string(d).Quote() << " -> " << parser.GetState() << Endl; + std::cout << std::string(d).Quote() << " -> " << parser.GetState() << std::endl; if (blob.size() / 2 - 1 <= i) // last \n sets EOF UNIT_ASSERT_EQUAL(parser.GetState(), parser.hp_eof); } diff --git a/library/cpp/http/io/list_codings/main.cpp b/library/cpp/http/io/list_codings/main.cpp index 9818d02bdfe..fe15b0d170f 100644 --- a/library/cpp/http/io/list_codings/main.cpp +++ b/library/cpp/http/io/list_codings/main.cpp @@ -3,6 +3,6 @@ int main() { for (auto codec : SupportedCodings()) { - Cout << codec << Endl; + std::cout << codec << std::endl; } } diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index d1ca9018bce..9d5fb4cd8f9 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -94,7 +94,6 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { TNetworkAddress addr("localhost", port); TSocket s(addr); - //TDebugOutput dbg; TNullOutput dbg; { @@ -140,7 +139,6 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { TNetworkAddress addr("localhost", port); TSocket s(addr); - //TDebugOutput dbg; TNullOutput dbg; { diff --git a/library/cpp/http/io/stream_ut_medium.cpp b/library/cpp/http/io/stream_ut_medium.cpp index 9f3340ac776..cd30aa1922e 100644 --- a/library/cpp/http/io/stream_ut_medium.cpp +++ b/library/cpp/http/io/stream_ut_medium.cpp @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(THttpTestMedium) { std::string s; { - std::stringOutput so(s); + TStringOutput so(s); THttpOutput ho(&so); TBufferedOutput bo(&ho, 10000); @@ -35,13 +35,13 @@ Y_UNIT_TEST_SUITE(THttpTestMedium) { UNIT_ASSERT(s.size() > 10); UNIT_ASSERT(s.find(data) == std::string::npos); } catch (...) { - Cerr << codec << " " << s << Endl; + std::cerr << codec << " " << s << std::endl; throw; } { - std::stringInput si(s); + TStringInput si(s); THttpInput hi(&si); auto res = hi.ReadAll(); diff --git a/library/cpp/http/simple/ut/https_ut.cpp b/library/cpp/http/simple/ut/https_ut.cpp index f448166cada..5f18154ffc5 100644 --- a/library/cpp/http/simple/ut/https_ut.cpp +++ b/library/cpp/http/simple/ut/https_ut.cpp @@ -7,6 +7,8 @@ #include +#include + Y_UNIT_TEST_SUITE(Https) { using TShellCommandPtr = std::unique_ptr; @@ -14,7 +16,7 @@ Y_UNIT_TEST_SUITE(Https) { const std::string data = ArcadiaSourceRoot() + "/library/cpp/http/simple/ut/https_server"; const std::string command = - TYdbStringBuilder() + TStringBuilder() << BuildRoot() << "/library/cpp/http/simple/ut/https_server/https_server" << " --port " << port << " --keyfile " << data << "/http_server.key" @@ -37,7 +39,7 @@ Y_UNIT_TEST_SUITE(Https) { client.DoGet("/ping"); break; } catch (const std::exception& e) { - Cout << "== failed to connect to new server: " << e.what() << Endl; + std::cout << "== failed to connect to new server: " << e.what() << std::endl; Sleep(TDuration::MilliSeconds(1)); } } @@ -46,7 +48,7 @@ Y_UNIT_TEST_SUITE(Https) { } static void get(TKeepAliveHttpClient & client) { - std::stringStream out; + TStringStream out; ui32 code = 0; UNIT_ASSERT_NO_EXCEPTION(code = client.DoGet("/ping", &out)); @@ -75,7 +77,7 @@ Y_UNIT_TEST_SUITE(Https) { } static void get(TSimpleHttpClient & client) { - std::stringStream out; + TStringStream out; UNIT_ASSERT_NO_EXCEPTION_C(client.DoGet("/ping", &out), out.Str()); UNIT_ASSERT_VALUES_EQUAL(out.Str(), "pong.my"); diff --git a/library/cpp/json/fuzzy_test/main.cpp b/library/cpp/json/fuzzy_test/main.cpp index a6e0a7d4376..a5ce20454ba 100644 --- a/library/cpp/json/fuzzy_test/main.cpp +++ b/library/cpp/json/fuzzy_test/main.cpp @@ -10,20 +10,20 @@ extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { NJson::TJsonValue value; NJson::ReadJsonFastTree(json, &value, true); } catch (...) { - //Cout << json << " -> " << CurrentExceptionMessage() << Endl; + //std::cout << json << " -> " << CurrentExceptionMessage() << std::endl; } try { NJson::TJsonCallbacks cb; NJson::ReadJsonFast(json, &cb); } catch (...) { - //Cout << json << " -> " << CurrentExceptionMessage() << Endl; + //std::cout << json << " -> " << CurrentExceptionMessage() << std::endl; } try { NJson::ValidateJson(json); } catch (...) { - //Cout << json << " -> " << CurrentExceptionMessage() << Endl; + //std::cout << json << " -> " << CurrentExceptionMessage() << std::endl; } return 0; diff --git a/library/cpp/json/ut/json_reader_fast_ut.cpp b/library/cpp/json/ut/json_reader_fast_ut.cpp index ee95ea99db0..7ba5b265bc9 100644 --- a/library/cpp/json/ut/json_reader_fast_ut.cpp +++ b/library/cpp/json/ut/json_reader_fast_ut.cpp @@ -5,6 +5,8 @@ #include #include +#include + namespace NJson { namespace NTest { enum ETestEvent { @@ -157,9 +159,9 @@ namespace NJson { UNIT_ASSERT_VALUES_EQUAL_C(e[i].Str, Events[i].Str, std::format("'{}' {}", str, i)); } } catch (const yexception&) { - Clog << "Exception at '" << str << "'" << Endl; + std::cerr << "Exception at '" << str << "'" << std::endl; for (const auto& event : Events) { - Clog << event.ToString() << Endl; + std::cerr << event.ToString() << std::endl; } throw; diff --git a/library/cpp/json/writer/README.md b/library/cpp/json/writer/README.md index a20489f32ee..0986cf62c81 100644 --- a/library/cpp/json/writer/README.md +++ b/library/cpp/json/writer/README.md @@ -10,7 +10,7 @@ Use it like this: json.BeginList() .WriteString("