From b0eca77c9ac80557b2d01fd4589692a4bf3d7d09 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 8 Nov 2021 17:11:35 +0300 Subject: [PATCH] Improve logging. --- td/telegram/AutoDownloadSettings.cpp | 2 +- td/telegram/ContactsManager.cpp | 2 +- td/telegram/InlineQueriesManager.cpp | 2 +- td/telegram/LinkManager.cpp | 6 +++--- td/telegram/MessagesManager.cpp | 9 +-------- td/telegram/Payments.cpp | 10 +++++----- td/telegram/Td.cpp | 2 +- tdnet/td/net/HttpConnectionBase.cpp | 9 ++++++--- 8 files changed, 19 insertions(+), 23 deletions(-) diff --git a/td/telegram/AutoDownloadSettings.cpp b/td/telegram/AutoDownloadSettings.cpp index 873e57493..5cd77af53 100644 --- a/td/telegram/AutoDownloadSettings.cpp +++ b/td/telegram/AutoDownloadSettings.cpp @@ -104,7 +104,7 @@ class SaveAutoDownloadSettingsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - LOG(INFO) << "SaveAutoDownloadSettingsQuery returned " << result_ptr.ok(); + LOG(INFO) << "Receive result for SaveAutoDownloadSettingsQuery: " << result_ptr.ok(); promise_.set_value(Unit()); } diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index e28064bf9..f5499c069 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -2935,7 +2935,7 @@ class GetChannelsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - // LOG(INFO) << "Receive result for GetChannelsQuery query: " << to_string(result_ptr.ok()); + // LOG(INFO) << "Receive result for GetChannelsQuery: " << to_string(result_ptr.ok()); auto chats_ptr = result_ptr.move_as_ok(); int32 constructor_id = chats_ptr->get_id(); switch (constructor_id) { diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 3de99c5f3..0f23d5dc2 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -106,7 +106,7 @@ class GetInlineBotResultsQuery final : public Td::ResultHandler { } else if (status.message() == "BOT_RESPONSE_TIMEOUT") { status = Status::Error(502, "The bot is not responding"); } - LOG(INFO) << "Inline query returned error " << status; + LOG(INFO) << "Receive error for GetInlineBotResultsQuery: " << status; td_->inline_queries_manager_->on_get_inline_query_results(dialog_id_, bot_user_id_, query_hash_, nullptr); promise_.set_error(std::move(status)); diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index 91f54c2e6..d377ebead 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -458,7 +458,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler { } auto result = result_ptr.move_as_ok(); - LOG(INFO) << "Receive " << to_string(result); + LOG(INFO) << "Receive result for RequestUrlAuthQuery: " << to_string(result); switch (result->get_id()) { case telegram_api::urlAuthResultRequest::ID: { auto request = telegram_api::move_object_as(result); @@ -486,7 +486,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler { void on_error(Status status) final { if (!dialog_id_.is_valid() || !td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "RequestUrlAuthQuery")) { - LOG(INFO) << "RequestUrlAuthQuery returned " << status; + LOG(INFO) << "Receive error for RequestUrlAuthQuery: " << status; } promise_.set_value(td_api::make_object(url_, false)); } @@ -547,7 +547,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler { void on_error(Status status) final { if (!dialog_id_.is_valid() || !td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "AcceptUrlAuthQuery")) { - LOG(INFO) << "AcceptUrlAuthQuery returned " << status; + LOG(INFO) << "Receive error for AcceptUrlAuthQuery: " << status; } promise_.set_error(std::move(status)); } diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index accfca466..fb7dbc52a 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -1583,13 +1583,7 @@ class ClearAllDraftsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - bool result = result_ptr.move_as_ok(); - if (!result) { - LOG(INFO) << "Receive false for ClearAllDraftsQuery"; - } else { - LOG(INFO) << "All draft messages has been cleared"; - } - + LOG(INFO) << "Receive result for ClearAllDraftsQuery: " << result_ptr.ok(); promise_.set_value(Unit()); } @@ -31204,7 +31198,6 @@ void MessagesManager::send_get_dialog_notification_settings_query(DialogId dialo return promise.set_error(Status::Error(400, "Can't access the chat")); } - LOG(INFO) << "Send GetDialogNotifySettingsQuery for " << dialog_id; auto &promises = get_dialog_notification_settings_queries_[dialog_id]; promises.push_back(std::move(promise)); if (promises.size() != 1) { diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 3537a3fa0..e53362391 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -290,7 +290,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler { } auto payment_form = result_ptr.move_as_ok(); - LOG(INFO) << "Receive payment form: " << to_string(payment_form); + LOG(INFO) << "Receive result for GetPaymentFormQuery: " << to_string(payment_form); td_->contacts_manager_->on_get_users(std::move(payment_form->users_), "GetPaymentFormQuery"); @@ -357,7 +357,7 @@ class ValidateRequestedInfoQuery final : public Td::ResultHandler { } auto validated_order_info = result_ptr.move_as_ok(); - LOG(INFO) << "Receive validated order info: " << to_string(validated_order_info); + LOG(INFO) << "Receive result for ValidateRequestedInfoQuery: " << to_string(validated_order_info); promise_.set_value(make_tl_object( std::move(validated_order_info->id_), @@ -412,7 +412,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler { } auto payment_result = result_ptr.move_as_ok(); - LOG(INFO) << "Receive payment result: " << to_string(payment_result); + LOG(INFO) << "Receive result for SendPaymentFormQuery: " << to_string(payment_result); switch (payment_result->get_id()) { case telegram_api::payments_paymentResult::ID: { @@ -466,7 +466,7 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler { } auto payment_receipt = result_ptr.move_as_ok(); - LOG(INFO) << "Receive payment receipt: " << to_string(payment_receipt); + LOG(INFO) << "Receive result for GetPaymentReceiptQuery: " << to_string(payment_receipt); td_->contacts_manager_->on_get_users(std::move(payment_receipt->users_), "GetPaymentReceiptQuery"); @@ -515,7 +515,7 @@ class GetSavedInfoQuery final : public Td::ResultHandler { } auto saved_info = result_ptr.move_as_ok(); - LOG(INFO) << "Receive saved info: " << to_string(saved_info); + LOG(INFO) << "Receive result for GetSavedInfoQuery: " << to_string(saved_info); promise_.set_value(convert_order_info(std::move(saved_info->saved_info_))); } diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 99f017f58..83c77e609 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -391,7 +391,7 @@ class UpdateStatusQuery final : public Td::ResultHandler { } bool result = result_ptr.ok(); - LOG(INFO) << "UpdateStatus returned " << result; + LOG(INFO) << "Receive result for UpdateStatusQuery: " << result; td_->on_update_status_success(!is_offline_); } diff --git a/tdnet/td/net/HttpConnectionBase.cpp b/tdnet/td/net/HttpConnectionBase.cpp index e95055599..a4e428535 100644 --- a/tdnet/td/net/HttpConnectionBase.cpp +++ b/tdnet/td/net/HttpConnectionBase.cpp @@ -183,9 +183,12 @@ void HttpConnectionBase::loop() { state_ = State::Close; } if (state_ == State::Close) { - LOG_IF(INFO, fd_.need_flush_write()) << "Close nonempty connection"; - LOG_IF(INFO, want_read && (!fd_.input_buffer().empty() || current_query_->type_ != HttpQuery::Type::Empty)) - << "Close connection while reading request/response"; + if (fd_.need_flush_write()) { + LOG(INFO) << "Close nonempty connection"; + } + if (want_read && (!fd_.input_buffer().empty() || current_query_->type_ != HttpQuery::Type::Empty)) { + LOG(INFO) << "Close connection while reading request/response"; + } return stop(); } }