Skip to content

Commit

Permalink
Replaced Cout, Cerr, Clog (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gazizonoki authored and Jlucblu committed Apr 5, 2024
1 parent e579884 commit 92bcf97
Show file tree
Hide file tree
Showing 169 changed files with 830 additions and 2,384 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
34 changes: 17 additions & 17 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 @@ -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);
Expand All @@ -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());
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 All @@ -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);
Expand All @@ -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();
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: " << ToString(res2.GetStatus()) << ": " << res2.GetIssues().ToString() << std::endl;
UNIT_ASSERT_VALUES_EQUAL_C(res2.GetStatus(), EStatus::TIMEOUT, res2.GetIssues().ToString());
}

Expand All @@ -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
Expand All @@ -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<TDriver> driver(std::in_place, config);
std::optional<TClient> client(std::in_place, *driver);
Expand All @@ -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();
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: " << ToString(res2.GetStatus()) << ": " << res2.GetIssues().ToString() << std::endl;
UNIT_ASSERT_VALUES_EQUAL_C(res2.GetStatus(), EStatus::CLIENT_CANCELLED, res2.GetIssues().ToString());
}

Expand Down
16 changes: 8 additions & 8 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 Expand Up @@ -127,9 +127,9 @@ Y_UNIT_TEST_SUITE(CppGrpcClientSimpleTest) {
};

std::vector<std::string> 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);
Expand All @@ -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
Expand All @@ -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();
Expand Down
Loading

0 comments on commit 92bcf97

Please sign in to comment.