Improve log and error messages.

This commit is contained in:
levlam 2022-10-05 21:29:05 +03:00
parent c6c8fdcb10
commit 7ff1ec04b1
10 changed files with 28 additions and 29 deletions

View File

@ -66,7 +66,7 @@ function split_file($file, $chunks, $undo) {
}
if (!file_exists($cpp_name)) {
echo "ERROR: skip unexisting file $cpp_name".PHP_EOL;
echo "ERROR: skip nonexistent file $cpp_name".PHP_EOL;
return;
}

View File

@ -212,14 +212,14 @@ abstract class TlDocumentationGenerator
$known_fields[$field_name] = $field_type;
continue;
}
$this->printError("Have no info about field `$field_name`");
$this->printError("Have no documentation for field `$field_name`");
}
foreach ($info as $name => $value) {
if (!$value) {
$this->printError("info[$name] for $class_name is empty");
$this->printError("Documentation for field $name of $class_name is empty");
} elseif (($value[0] < 'A' || $value[0] > 'Z') && ($value[0] < '0' || $value[0] > '9')) {
$this->printError("info[$name] for $class_name doesn't begins with capital letter");
$this->printError("Documentation for field $name of $class_name doesn't begin with a capital letter");
}
}
@ -235,7 +235,7 @@ abstract class TlDocumentationGenerator
}
foreach (array_diff_key($info, $known_fields) as $field_name => $field_info) {
$this->printError("Have info about unexisted field `$field_name`");
$this->printError("Have info about nonexistent field `$field_name`");
}
if (array_keys($info) !== array_keys($known_fields)) {

View File

@ -176,7 +176,7 @@ void CallbackQueriesManager::on_new_query(int32 flags, int64 callback_query_id,
LOG(ERROR) << "Receive new callback query from invalid " << sender_user_id << " in " << dialog_id;
return;
}
LOG_IF(ERROR, !td_->contacts_manager_->have_user(sender_user_id)) << "Have no info about " << sender_user_id;
LOG_IF(ERROR, !td_->contacts_manager_->have_user(sender_user_id)) << "Receive unknown " << sender_user_id;
if (!td_->auth_manager_->is_bot()) {
LOG(ERROR) << "Receive new callback query";
return;
@ -208,7 +208,7 @@ void CallbackQueriesManager::on_new_inline_query(
LOG(ERROR) << "Receive new callback query from invalid " << sender_user_id;
return;
}
LOG_IF(ERROR, !td_->contacts_manager_->have_user(sender_user_id)) << "Have no info about " << sender_user_id;
LOG_IF(ERROR, !td_->contacts_manager_->have_user(sender_user_id)) << "Receive unknown " << sender_user_id;
if (!td_->auth_manager_->is_bot()) {
LOG(ERROR) << "Receive new callback query";
return;

View File

@ -8710,7 +8710,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
User *u = get_user_force(user_id);
if (u == nullptr && Slice(source) != Slice("GetUsersQuery")) {
// userEmpty should be received only through getUsers for unexisting users
// userEmpty should be received only through getUsers for nonexistent users
LOG(ERROR) << "Have no information about " << user_id << ", but received userEmpty from " << source;
}
return;
@ -16814,7 +16814,7 @@ td_api::object_ptr<td_api::updateUser> ContactsManager::get_update_unknown_user_
int64 ContactsManager::get_user_id_object(UserId user_id, const char *source) const {
if (user_id.is_valid() && get_user(user_id) == nullptr && unknown_users_.count(user_id) == 0) {
LOG(ERROR) << "Have no info about " << user_id << " from " << source;
LOG(ERROR) << "Have no information about " << user_id << " from " << source;
unknown_users_.insert(user_id);
send_closure(G()->td(), &Td::send_update, get_update_unknown_user_object(user_id));
}
@ -16922,7 +16922,7 @@ td_api::object_ptr<td_api::updateBasicGroup> ContactsManager::get_update_unknown
int64 ContactsManager::get_basic_group_id_object(ChatId chat_id, const char *source) const {
if (chat_id.is_valid() && get_chat(chat_id) == nullptr && unknown_chats_.count(chat_id) == 0) {
LOG(ERROR) << "Have no info about " << chat_id << " from " << source;
LOG(ERROR) << "Have no information about " << chat_id << " from " << source;
unknown_chats_.insert(chat_id);
send_closure(G()->td(), &Td::send_update, get_update_unknown_basic_group_object(chat_id));
}
@ -16981,7 +16981,7 @@ int64 ContactsManager::get_supergroup_id_object(ChannelId channel_id, const char
if (have_min_channel(channel_id)) {
LOG(INFO) << "Have only min " << channel_id << " received from " << source;
} else {
LOG(ERROR) << "Have no info about " << channel_id << " received from " << source;
LOG(ERROR) << "Have no information about " << channel_id << " received from " << source;
}
unknown_channels_.insert(channel_id);
send_closure(G()->td(), &Td::send_update, get_update_unknown_supergroup_object(channel_id));
@ -17055,7 +17055,7 @@ td_api::object_ptr<td_api::updateSecretChat> ContactsManager::get_update_unknown
int32 ContactsManager::get_secret_chat_id_object(SecretChatId secret_chat_id, const char *source) const {
if (secret_chat_id.is_valid() && get_secret_chat(secret_chat_id) == nullptr &&
unknown_secret_chats_.count(secret_chat_id) == 0) {
LOG(ERROR) << "Have no info about " << secret_chat_id << " from " << source;
LOG(ERROR) << "Have no information about " << secret_chat_id << " from " << source;
unknown_secret_chats_.insert(secret_chat_id);
send_closure(G()->td(), &Td::send_update, get_update_unknown_secret_chat_object(secret_chat_id));
}

View File

@ -411,7 +411,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
LOG(ERROR) << "Receive invalid " << user_id;
continue;
}
LOG_IF(ERROR, !td_->contacts_manager_->have_user(user_id)) << "Have no info about " << user_id;
LOG_IF(ERROR, !td_->contacts_manager_->have_user(user_id)) << "Receive unknown " << user_id;
DialogId actor_dialog_id;
auto action = get_chat_event_action_object(td_, channel_id_, std::move(event->action_), actor_dialog_id);

View File

@ -2028,7 +2028,7 @@ void InlineQueriesManager::on_new_query(int64 query_id, UserId sender_user_id, L
LOG(ERROR) << "Receive new inline query from invalid " << sender_user_id;
return;
}
LOG_IF(ERROR, !td_->contacts_manager_->have_user(sender_user_id)) << "Have no info about " << sender_user_id;
LOG_IF(ERROR, !td_->contacts_manager_->have_user(sender_user_id)) << "Receive unknown " << sender_user_id;
if (!td_->auth_manager_->is_bot()) {
LOG(ERROR) << "Receive new inline query";
return;
@ -2067,7 +2067,7 @@ void InlineQueriesManager::on_chosen_result(
LOG(ERROR) << "Receive chosen inline query result from invalid " << user_id;
return;
}
LOG_IF(ERROR, !td_->contacts_manager_->have_user(user_id)) << "Have no info about " << user_id;
LOG_IF(ERROR, !td_->contacts_manager_->have_user(user_id)) << "Receive unknown " << user_id;
if (!td_->auth_manager_->is_bot()) {
LOG(ERROR) << "Receive chosen inline query result";
return;

View File

@ -551,19 +551,19 @@ unique_ptr<MessageReactions> MessageReactions::get_message_reactions(
if (dialog_type == DialogType::User) {
auto user_id = dialog_id.get_user_id();
if (!td->contacts_manager_->have_min_user(user_id)) {
LOG(ERROR) << "Have no info about " << user_id;
LOG(ERROR) << "Receive unknown " << user_id;
continue;
}
} else if (dialog_type == DialogType::Channel) {
auto channel_id = dialog_id.get_channel_id();
auto min_channel = td->contacts_manager_->get_min_channel(channel_id);
if (min_channel == nullptr) {
LOG(ERROR) << "Have no info about reacted " << channel_id;
LOG(ERROR) << "Receive unknown reacted " << channel_id;
continue;
}
recent_chooser_min_channels.emplace_back(channel_id, *min_channel);
} else {
LOG(ERROR) << "Have no info about reacted " << dialog_id;
LOG(ERROR) << "Receive unknown reacted " << dialog_id;
continue;
}
}

View File

@ -56,19 +56,19 @@ MessageReplyInfo::MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageRe
if (dialog_type == DialogType::User) {
auto replier_user_id = dialog_id.get_user_id();
if (!td->contacts_manager_->have_min_user(replier_user_id)) {
LOG(ERROR) << "Have no info about replied " << replier_user_id;
LOG(ERROR) << "Receive unknown replied " << replier_user_id;
continue;
}
} else if (dialog_type == DialogType::Channel) {
auto replier_channel_id = dialog_id.get_channel_id();
auto min_channel = td->contacts_manager_->get_min_channel(replier_channel_id);
if (min_channel == nullptr) {
LOG(ERROR) << "Have no info about replied " << replier_channel_id;
LOG(ERROR) << "Receive unknown replied " << replier_channel_id;
continue;
}
replier_min_channels.emplace_back(replier_channel_id, *min_channel);
} else {
LOG(ERROR) << "Have no info about replied " << dialog_id;
LOG(ERROR) << "Receive unknown replied " << dialog_id;
continue;
}
}

View File

@ -94,7 +94,7 @@ vector<DialogId> get_message_sender_dialog_ids(Td *td,
}
if (dialog_id.get_type() == DialogType::User) {
if (!td->contacts_manager_->have_user(dialog_id.get_user_id())) {
LOG(ERROR) << "Have no info about " << dialog_id.get_user_id();
LOG(ERROR) << "Receive unknown " << dialog_id.get_user_id();
continue;
}
} else {

View File

@ -2844,7 +2844,7 @@ class GetRecentLocationsQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, int32 limit) {
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Have no info about the chat"));
return on_error(Status::Error(400, "Chat is not accessible"));
}
dialog_id_ = dialog_id;
@ -27004,7 +27004,7 @@ void MessagesManager::do_send_bot_start_message(UserId bot_user_id, DialogId dia
? make_tl_object<telegram_api::inputPeerEmpty>()
: get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_send_message_fail(random_id, Status::Error(400, "Have no info about the chat"));
return on_send_message_fail(random_id, Status::Error(400, "Chat is not accessible"));
}
auto r_bot_input_user = td_->contacts_manager_->get_input_user(bot_user_id);
if (r_bot_input_user.is_error()) {
@ -36870,8 +36870,7 @@ void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source
td_->contacts_manager_->have_min_channel(dialog_id.get_channel_id())) {
LOG(INFO) << "Created " << dialog_id << " for min-channel from " << source;
} else {
LOG(ERROR) << "Have no info about " << dialog_id << " received from " << source
<< ", but forced to create it";
LOG(ERROR) << "Forced to create unknown " << dialog_id << " from " << source;
}
} else if (!expect_no_access) {
LOG(ERROR) << "Have no access to " << dialog_id << " received from " << source << ", but forced to create it";
@ -38141,7 +38140,7 @@ unique_ptr<MessagesManager::Dialog> MessagesManager::parse_dialog(DialogId dialo
send_get_dialog_query(dialog_id, Auto(), 0, source);
}
} else {
LOG(ERROR) << "Have no info about " << dialog_id << " from " << source << " to repair it";
LOG(ERROR) << "Can't repair unknown " << dialog_id << " from " << source;
}
}
CHECK(dialog_id == d->dialog_id);
@ -38679,7 +38678,7 @@ void MessagesManager::get_channel_difference(DialogId dialog_id, int32 pts, bool
auto input_channel = td_->contacts_manager_->get_input_channel(dialog_id.get_channel_id());
if (input_channel == nullptr) {
LOG(ERROR) << "Skip running channels.getDifference for " << dialog_id << " from " << source
<< " because have no info about the chat";
<< " because the channel is unknown";
after_get_channel_difference(dialog_id, false);
return;
}
@ -40047,7 +40046,7 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
auto dialog_id = log_event.dialog_id_;
CHECK(dialog_id.get_type() == DialogType::SecretChat);
if (!td_->contacts_manager_->have_secret_chat_force(dialog_id.get_secret_chat_id())) {
LOG(ERROR) << "Have no info about " << dialog_id;
LOG(ERROR) << "Can't read history in unknown " << dialog_id;
binlog_erase(G()->td_db()->get_binlog(), event.id_);
break;
}