Skip to content

Commit

Permalink
Replace Cout, Cerr and Clog
Browse files Browse the repository at this point in the history
  • Loading branch information
Gazizonoki committed Apr 1, 2024
1 parent 13f22b2 commit 29d3942
Show file tree
Hide file tree
Showing 100 changed files with 609 additions and 558 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ bool TGRpcConnectionsImpl::StartStatCollecting(NMonitoring::IMetricRegistry* sen
if (auto ptr = dynamic_cast<NMonitoring::TMetricRegistry*>(sensorsRegistry)) {
MetricRegistryPtr_ = ptr;
} else {
Cerr << "Unknown IMetricRegistry impl" << Endl;
std::cerr << "Unknown IMetricRegistry impl" << std::endl;
return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions client/impl/ydb_internal/retry/retry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
20 changes: 10 additions & 10 deletions client/ydb_coordination/coordination_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -50,7 +50,7 @@ namespace {
{
Y_UNUSED(context);

Cerr << "Session stream started" << Endl;
std::cerr << "Session stream started" << std::endl;

Ydb::Coordination::SessionRequest request;

Expand All @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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: " << 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());
Expand All @@ -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
Expand Down Expand Up @@ -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: " << state << std::endl;
})
.OnStopped([stoppedPromise]() mutable {
stoppedPromise.SetValue();
Expand All @@ -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: " << res2.GetStatus() << ": " << res2.GetIssues().ToString() << std::endl;
UNIT_ASSERT_VALUES_EQUAL_C(res2.GetStatus(), EStatus::TIMEOUT, res2.GetIssues().ToString());
}

Expand Down Expand Up @@ -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: " << state << std::endl;
})
.OnStopped([stoppedPromise]() mutable {
stoppedPromise.SetValue();
Expand All @@ -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: " << res2.GetStatus() << ": " << res2.GetIssues().ToString() << std::endl;
UNIT_ASSERT_VALUES_EQUAL_C(res2.GetStatus(), EStatus::CLIENT_CANCELLED, res2.GetIssues().ToString());
}

Expand Down
4 changes: 2 additions & 2 deletions client/ydb_driver/driver_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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");
Expand Down
46 changes: 23 additions & 23 deletions client/ydb_federated_topic/ut/basic_usage_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<NYdb::NFederatedTopic::TReadSessionEvent::TEvent> event = ReadSession->GetEvent(false);
Expand Down Expand Up @@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) {
ReadSession->WaitEvent().Wait();
// Get event
std::optional<NYdb::NFederatedTopic::TReadSessionEvent::TEvent> 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<NYdb::NFederatedTopic::TReadSessionEvent::TStartPartitionSessionEvent>(&*event);
Y_ASSERT(startPartitionSessionEvent);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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<TReadSessionEvent::TDataReceivedEvent>(&e)) {
dataEvent->Commit();
} else if (auto* startPartitionSessionEvent = std::get_if<TReadSessionEvent::TStartPartitionSessionEvent>(&e)) {
Expand Down Expand Up @@ -343,7 +343,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));
auto event = ReadSession->GetEvent(false);
Expand All @@ -363,11 +363,11 @@ Y_UNIT_TEST_SUITE(BasicUsage) {
ReadSession->WaitEvent().Wait();
event = ReadSession->GetEvent(false);
UNIT_ASSERT(event.Defined());
Cerr << ">>> Got event: " << DebugString(*event) << Endl;
std::cerr << ">>> Got event: " << DebugString(*event) << std::endl;
UNIT_ASSERT(std::holds_alternative<NTopic::TSessionClosedEvent>(*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);
Expand All @@ -384,10 +384,10 @@ Y_UNIT_TEST_SUITE(BasicUsage) {

event = ReadSession2->GetEvent(true);
UNIT_ASSERT(event.Defined());
Cerr << ">>> Got event: " << DebugString(*event) << Endl;
std::cerr << ">>> Got event: " << DebugString(*event) << std::endl;
UNIT_ASSERT(std::holds_alternative<TReadSessionEvent::TStartPartitionSessionEvent>(*event));

// Cerr << ">>> Got event: " << DebugString(*event) << Endl;
// std::cerr << ">>> Got event: " << DebugString(*event) << std::endl;
// UNIT_ASSERT(std::holds_alternative<NTopic::TSessionClosedEvent>(*event));
}

Expand All @@ -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<NYdb::NFederatedTopic::TReadSessionEvent::TEvent> 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<NYdb::NFederatedTopic::TReadSessionEvent::TStartPartitionSessionEvent>(&*event);
Y_ASSERT(startPartitionSessionEvent);
Expand Down Expand Up @@ -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) {
Expand All @@ -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));

Expand Down Expand Up @@ -548,20 +548,20 @@ 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<NYdb::NTopic::TWriteSessionEvent::TReadyToAcceptEvent>(&*event);
Y_ASSERT(readyToAcceptEvent);
WriteSession->Write(std::move(readyToAcceptEvent->ContinuationToken), NTopic::TWriteMessage("hello"));

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<NYdb::NTopic::TWriteSessionEvent::TReadyToAcceptEvent>(&*event);
Y_ASSERT(readyToAcceptEvent);
Expand All @@ -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<NYdb::NTopic::TWriteSessionEvent::TAcksEvent>(&*event);
Y_ASSERT(acksEvent);
Expand Down
2 changes: 1 addition & 1 deletion client/ydb_federated_topic/ut/fds_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions client/ydb_persqueue_core/impl/write_session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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)");
}

Expand Down
14 changes: 7 additions & 7 deletions client/ydb_persqueue_core/ut/basic_usage_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) {
auto sessionAdapter = TSimpleWriteSessionTestAdapter(
dynamic_cast<TSimpleBlockingWriteSession *>(session.get()));
if (shouldCaptureData.has_value()) {
TYdbStringBuilder msg;
TStringBuilder msg;
msg << "Session has captured " << sessionAdapter.GetAcquiredMessagesCount()
<< " messages, capturing was expected: " << *shouldCaptureData << Endl;
UNIT_ASSERT_VALUES_EQUAL_C(sessionAdapter.GetAcquiredMessagesCount() > 0, *shouldCaptureData, msg.c_str());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
Expand All @@ -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) {
Expand Down Expand Up @@ -481,7 +481,7 @@ Y_UNIT_TEST_SUITE(BasicUsage) {
.RetryPolicy(IRetryPolicy::GetNoRetryPolicy());
std::shared_ptr<IReadSession> 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&) {
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 29d3942

Please sign in to comment.