diff options
author | Innokentii Mokin <innokentii@ydb.tech> | 2024-01-23 14:19:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 14:19:37 +0300 |
commit | 0761c67911d67019f2ba62bf62e9569b6a63dde0 (patch) | |
tree | acfc24259e6315bb2eade73d4a321fb10632c0ed | |
parent | acefc40a64eea9f0caf8607fa49f4ce4aabd6411 (diff) | |
download | ydb-0761c67911d67019f2ba62bf62e9569b6a63dde0.tar.gz |
Make ydb_root_common use only stderr to avoid command output pollution (#1218)
* make ydb_root_common use only stderr to avoid command output pollution
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp | 34 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/common/progress_bar.cpp | 8 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/import/import.cpp | 2 |
3 files changed, 22 insertions, 22 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp b/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp index b2c4098692..681f63561e 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp @@ -259,7 +259,7 @@ void TClientCommandRootCommon::Parse(TConfig& config) { namespace { inline void PrintSettingFromProfile(const TString& setting, std::shared_ptr<IProfile> profile, bool explicitOption) { - Cout << "Using " << setting << " due to configuration in" << (explicitOption ? "" : " active") << " profile \"" + Cerr << "Using " << setting << " due to configuration in" << (explicitOption ? "" : " active") << " profile \"" << profile->GetName() << "\"" << (explicitOption ? " from explicit --profile option" : "") << Endl; } @@ -738,42 +738,42 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { config.SecurityToken = ReadFromFile(TokenFile, "token"); config.ChosenAuthMethod = "token"; if (IsVerbose()) { - Cout << "Using token from file provided with explicit option" << Endl; + Cerr << "Using token from file provided with explicit option" << Endl; config.ConnectionParams["token"].push_back({config.SecurityToken, "file provided with explicit --token-file option"}); } } else if (config.ParseResult->Has("iam-token-file")) { config.SecurityToken = ReadFromFile(TokenFile, "token"); config.ChosenAuthMethod = "token"; if (IsVerbose()) { - Cout << "Using IAM token from file provided with explicit option" << Endl; + Cerr << "Using IAM token from file provided with explicit option" << Endl; config.ConnectionParams["token"].push_back({config.SecurityToken, "file provided with explicit --iam-token-file option"}); } } else if (YCTokenFile) { config.YCToken = ReadFromFile(YCTokenFile, "token"); config.ChosenAuthMethod = "yc-token"; if (IsVerbose()) { - Cout << "Using Yandex.Cloud Passport token from file provided with --yc-token-file option" << Endl; + Cerr << "Using Yandex.Cloud Passport token from file provided with --yc-token-file option" << Endl; config.ConnectionParams["yc-token"].push_back({config.YCToken, "file provided with explicit --yc-token-file option"}); } } else if (UseMetadataCredentials) { config.ChosenAuthMethod = "use-metadata-credentials"; config.UseMetadataCredentials = true; if (IsVerbose()) { - Cout << "Using metadata service due to --use-metadata-credentials option" << Endl; + Cerr << "Using metadata service due to --use-metadata-credentials option" << Endl; config.ConnectionParams["use-metadata-credentials"].push_back({"true", "explicit --use-metadata-credentials option"}); } } else if (SaKeyFile) { config.SaKeyFile = SaKeyFile; config.ChosenAuthMethod = "sa-key-file"; if (IsVerbose()) { - Cout << "Using service account key file provided with --sa-key-file option" << Endl; + Cerr << "Using service account key file provided with --sa-key-file option" << Endl; config.ConnectionParams["sa-key-file"].push_back({config.SaKeyFile, "explicit --sa-key-file option"}); } } else if (UserName || PasswordFile) { if (UserName) { config.StaticCredentials.User = UserName; if (IsVerbose()) { - Cout << "Using user name provided with --user option" << Endl; + Cerr << "Using user name provided with --user option" << Endl; config.ConnectionParams["user"].push_back({UserName, "explicit --user option"}); } } @@ -783,7 +783,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { DoNotAskForPassword = true; } if (IsVerbose()) { - Cout << "Using user password from file provided with --password-file option" << Endl; + Cerr << "Using user password from file provided with --password-file option" << Endl; config.ConnectionParams["password"].push_back({config.StaticCredentials.Password, "file provided with explicit --password-file option"}); } } @@ -806,7 +806,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { if (!envIamToken.empty()) { if (!IsAuthSet) { if (IsVerbose()) { - Cout << "Using iam token from IAM_TOKEN env variable" << Endl; + Cerr << "Using iam token from IAM_TOKEN env variable" << Endl; } config.ChosenAuthMethod = "token"; config.SecurityToken = envIamToken; @@ -821,7 +821,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { if (!envYcToken.empty()) { if (!IsAuthSet) { if (IsVerbose()) { - Cout << "Using Yandex.Cloud Passport token from YC_TOKEN env variable" << Endl; + Cerr << "Using Yandex.Cloud Passport token from YC_TOKEN env variable" << Endl; } config.ChosenAuthMethod = "yc-token"; config.YCToken = envYcToken; @@ -835,7 +835,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { if (GetEnv("USE_METADATA_CREDENTIALS") == "1") { if (!IsAuthSet) { if (IsVerbose()) { - Cout << "Using metadata service due to USE_METADATA_CREDENTIALS=\"1\" env variable" << Endl; + Cerr << "Using metadata service due to USE_METADATA_CREDENTIALS=\"1\" env variable" << Endl; } config.ChosenAuthMethod = "use-metadata-credentials"; config.UseMetadataCredentials = true; @@ -850,7 +850,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { if (!envSaKeyFile.empty()) { if (!IsAuthSet) { if (IsVerbose()) { - Cout << "Using service account key file from SA_KEY_FILE env variable" << Endl; + Cerr << "Using service account key file from SA_KEY_FILE env variable" << Endl; } config.ChosenAuthMethod = "sa-key-file"; config.SaKeyFile = envSaKeyFile; @@ -867,7 +867,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { if (!envYdbToken.empty()) { if (!IsAuthSet) { if (IsVerbose()) { - Cout << "Using OAuth token from YDB_TOKEN env variable" << Endl; + Cerr << "Using OAuth token from YDB_TOKEN env variable" << Endl; } config.ChosenAuthMethod = "token"; config.SecurityToken = envYdbToken; @@ -885,7 +885,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { if (!userName.empty()) { if (!IsAuthSet) { if (IsVerbose()) { - Cout << "Using user name from YDB_USER env variable" << Endl; + Cerr << "Using user name from YDB_USER env variable" << Endl; } hasStaticCredentials = true; config.StaticCredentials.User = userName; @@ -899,7 +899,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { if (!password.empty()) { if (!IsAuthSet) { if (IsVerbose()) { - Cout << "Using user password from YDB_PASSWORD env variable" << Endl; + Cerr << "Using user password from YDB_PASSWORD env variable" << Endl; } hasStaticCredentials = true; config.StaticCredentials.Password = password; @@ -930,7 +930,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { if (ReadFromFileIfExists(tokenFile, "default token", fileContent)) { if (!IsAuthSet) { if (IsVerbose()) { - Cout << "Using auth token from default token file " << defaultTokenFile << Endl; + Cerr << "Using auth token from default token file " << defaultTokenFile << Endl; } config.ChosenAuthMethod = "token"; config.SecurityToken = fileContent; @@ -940,7 +940,7 @@ void TClientCommandRootCommon::ParseCredentials(TConfig& config) { } } else { if (!IsAuthSet && IsVerbose()) { - Cout << "No authentication methods were found. Going without authentication" << Endl; + Cerr << "No authentication methods were found. Going without authentication" << Endl; } } } diff --git a/ydb/public/lib/ydb_cli/common/progress_bar.cpp b/ydb/public/lib/ydb_cli/common/progress_bar.cpp index c2643418a2..bcdd43daa2 100644 --- a/ydb/public/lib/ydb_cli/common/progress_bar.cpp +++ b/ydb/public/lib/ydb_cli/common/progress_bar.cpp @@ -26,7 +26,7 @@ void TProgressBar::AddProgress(size_t value) { TProgressBar::~TProgressBar() { if (!Finished) { - Cout << Endl; + Cerr << Endl; } } @@ -62,12 +62,12 @@ void TProgressBar::Render() output += TString("█") * filledBarLen; output += TString("░") * (barLen - filledBarLen); output += outputEnd; - Cout << output; + Cerr << output; if (CurProgress == Capacity) { - Cout << "\n"; + Cerr << "\n"; Finished = true; } - Cout.Flush(); + Cerr.Flush(); } } // namespace NConsoleClient diff --git a/ydb/public/lib/ydb_cli/import/import.cpp b/ydb/public/lib/ydb_cli/import/import.cpp index 3677437c15..b227415b85 100644 --- a/ydb/public/lib/ydb_cli/import/import.cpp +++ b/ydb/public/lib/ydb_cli/import/import.cpp @@ -349,7 +349,7 @@ TStatus TImportFileClient::Import(const TVector<TString>& filePaths, const TStri auto finish = TInstant::Now(); auto duration = finish - start; progressBar.SetProcess(100); - Cout << "Elapsed: " << duration.SecondsFloat() << " sec\n"; + Cerr << "Elapsed: " << duration.SecondsFloat() << " sec\n"; return MakeStatus(EStatus::SUCCESS); } |