Improve logging.

This commit is contained in:
levlam 2021-11-08 17:11:35 +03:00
parent 6de2763fac
commit b0eca77c9a
8 changed files with 19 additions and 23 deletions

View File

@ -104,7 +104,7 @@ class SaveAutoDownloadSettingsQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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()); promise_.set_value(Unit());
} }

View File

@ -2935,7 +2935,7 @@ class GetChannelsQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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(); auto chats_ptr = result_ptr.move_as_ok();
int32 constructor_id = chats_ptr->get_id(); int32 constructor_id = chats_ptr->get_id();
switch (constructor_id) { switch (constructor_id) {

View File

@ -106,7 +106,7 @@ class GetInlineBotResultsQuery final : public Td::ResultHandler {
} else if (status.message() == "BOT_RESPONSE_TIMEOUT") { } else if (status.message() == "BOT_RESPONSE_TIMEOUT") {
status = Status::Error(502, "The bot is not responding"); 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); td_->inline_queries_manager_->on_get_inline_query_results(dialog_id_, bot_user_id_, query_hash_, nullptr);
promise_.set_error(std::move(status)); promise_.set_error(std::move(status));

View File

@ -458,7 +458,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
} }
auto result = result_ptr.move_as_ok(); 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()) { switch (result->get_id()) {
case telegram_api::urlAuthResultRequest::ID: { case telegram_api::urlAuthResultRequest::ID: {
auto request = telegram_api::move_object_as<telegram_api::urlAuthResultRequest>(result); auto request = telegram_api::move_object_as<telegram_api::urlAuthResultRequest>(result);
@ -486,7 +486,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
void on_error(Status status) final { void on_error(Status status) final {
if (!dialog_id_.is_valid() || if (!dialog_id_.is_valid() ||
!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "RequestUrlAuthQuery")) { !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<td_api::loginUrlInfoOpen>(url_, false)); promise_.set_value(td_api::make_object<td_api::loginUrlInfoOpen>(url_, false));
} }
@ -547,7 +547,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler {
void on_error(Status status) final { void on_error(Status status) final {
if (!dialog_id_.is_valid() || if (!dialog_id_.is_valid() ||
!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "AcceptUrlAuthQuery")) { !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)); promise_.set_error(std::move(status));
} }

View File

@ -1583,13 +1583,7 @@ class ClearAllDraftsQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); return on_error(result_ptr.move_as_error());
} }
bool result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for ClearAllDraftsQuery: " << result_ptr.ok();
if (!result) {
LOG(INFO) << "Receive false for ClearAllDraftsQuery";
} else {
LOG(INFO) << "All draft messages has been cleared";
}
promise_.set_value(Unit()); 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")); 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]; auto &promises = get_dialog_notification_settings_queries_[dialog_id];
promises.push_back(std::move(promise)); promises.push_back(std::move(promise));
if (promises.size() != 1) { if (promises.size() != 1) {

View File

@ -290,7 +290,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
} }
auto payment_form = result_ptr.move_as_ok(); 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"); 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(); 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<td_api::validatedOrderInfo>( promise_.set_value(make_tl_object<td_api::validatedOrderInfo>(
std::move(validated_order_info->id_), std::move(validated_order_info->id_),
@ -412,7 +412,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler {
} }
auto payment_result = result_ptr.move_as_ok(); 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()) { switch (payment_result->get_id()) {
case telegram_api::payments_paymentResult::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(); 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"); 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(); 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_))); promise_.set_value(convert_order_info(std::move(saved_info->saved_info_)));
} }

View File

@ -391,7 +391,7 @@ class UpdateStatusQuery final : public Td::ResultHandler {
} }
bool result = result_ptr.ok(); bool result = result_ptr.ok();
LOG(INFO) << "UpdateStatus returned " << result; LOG(INFO) << "Receive result for UpdateStatusQuery: " << result;
td_->on_update_status_success(!is_offline_); td_->on_update_status_success(!is_offline_);
} }

View File

@ -183,9 +183,12 @@ void HttpConnectionBase::loop() {
state_ = State::Close; state_ = State::Close;
} }
if (state_ == State::Close) { if (state_ == State::Close) {
LOG_IF(INFO, fd_.need_flush_write()) << "Close nonempty connection"; if (fd_.need_flush_write()) {
LOG_IF(INFO, want_read && (!fd_.input_buffer().empty() || current_query_->type_ != HttpQuery::Type::Empty)) LOG(INFO) << "Close nonempty connection";
<< "Close connection while reading request/response"; }
if (want_read && (!fd_.input_buffer().empty() || current_query_->type_ != HttpQuery::Type::Empty)) {
LOG(INFO) << "Close connection while reading request/response";
}
return stop(); return stop();
} }
} }