From 20bfcaa9793bafed9e56b694edbf4f0b364bf640 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Tue, 12 Feb 2019 19:17:20 +0300 Subject: [PATCH] Use LOG_CHECK where it is necessary GitOrigin-RevId: a8bd17cc2ee6e43dcea52bb25aef9ee1f91c7ec4 --- benchmark/bench_http.cpp | 2 +- td/mtproto/HttpTransport.cpp | 2 +- td/mtproto/RawConnection.cpp | 2 +- td/mtproto/SessionConnection.cpp | 2 +- td/telegram/AnimationsManager.cpp | 6 +- td/telegram/CallActor.cpp | 2 +- td/telegram/ContactsManager.cpp | 6 +- td/telegram/DocumentsManager.cpp | 2 +- td/telegram/MessageEntity.cpp | 2 +- td/telegram/MessagesDb.cpp | 8 +- td/telegram/MessagesManager.cpp | 102 +++++++++--------- td/telegram/RequestActor.h | 2 +- td/telegram/SecretChatActor.cpp | 14 +-- td/telegram/StickersManager.hpp | 2 +- td/telegram/TdDb.cpp | 2 +- td/telegram/cli.cpp | 2 +- td/telegram/files/FileDownloader.cpp | 4 +- td/telegram/files/FileGenerateManager.cpp | 2 +- td/telegram/files/FileLocation.h | 10 +- td/telegram/files/FileManager.cpp | 4 +- td/telegram/files/PartsManager.cpp | 10 +- td/telegram/logevent/LogEvent.h | 2 +- td/telegram/net/ConnectionCreator.cpp | 4 +- td/telegram/net/NetQueryCreator.cpp | 2 +- td/telegram/net/NetStatsManager.cpp | 2 +- td/telegram/net/PublicRsaKeyShared.cpp | 2 +- td/telegram/net/Session.cpp | 2 +- tdactor/td/actor/impl/Actor.h | 4 +- tdactor/td/actor/impl/ActorInfo.h | 2 +- tdactor/td/actor/impl/Scheduler-decl.h | 1 - tdactor/td/actor/impl/Scheduler.cpp | 10 +- tdactor/td/actor/impl/Scheduler.h | 4 +- tdactor/test/actors_main.cpp | 2 +- tdactor/test/actors_simple.cpp | 2 +- tddb/td/db/SqliteDb.cpp | 4 +- tddb/td/db/binlog/Binlog.cpp | 4 +- tddb/td/db/binlog/BinlogEvent.cpp | 2 +- .../db/binlog/detail/BinlogEventsProcessor.h | 2 +- tdutils/td/utils/BufferedUdp.h | 2 +- tdutils/td/utils/Heap.h | 2 +- tdutils/td/utils/ObjectPool.h | 2 +- tdutils/td/utils/OrderedEventsProcessor.h | 2 +- tdutils/td/utils/SharedObjectPool.h | 2 +- tdutils/td/utils/Status.h | 8 +- tdutils/td/utils/TimedStat.h | 2 +- tdutils/td/utils/Variant.h | 2 +- tdutils/td/utils/buffer.h | 2 +- tdutils/td/utils/misc.h | 4 +- tdutils/td/utils/port/detail/Iocp.cpp | 2 +- tdutils/td/utils/port/detail/Select.cpp | 4 +- tdutils/td/utils/tests.h | 4 +- tdutils/td/utils/tl_helpers.h | 10 +- tdutils/td/utils/tl_parsers.cpp | 2 +- tdutils/test/MpmcQueue.cpp | 8 +- tdutils/test/MpscLinkQueue.cpp | 6 +- tdutils/test/pq.cpp | 6 +- test/secret.cpp | 2 +- test/tdclient.cpp | 8 +- 58 files changed, 161 insertions(+), 158 deletions(-) diff --git a/benchmark/bench_http.cpp b/benchmark/bench_http.cpp index 381c9d3f..ca26d6cc 100644 --- a/benchmark/bench_http.cpp +++ b/benchmark/bench_http.cpp @@ -27,7 +27,7 @@ class HttpClient : public HttpOutboundConnection::Callback { IPAddress addr; addr.init_ipv4_port("127.0.0.1", 8082).ensure(); auto fd = SocketFd::open(addr); - CHECK(fd.is_ok()) << fd.error(); + LOG_CHECK(fd.is_ok()) << fd.error(); connection_ = create_actor("Connect", fd.move_as_ok(), SslStream{}, std::numeric_limits::max(), 0, 0, ActorOwn(actor_id(this))); diff --git a/td/mtproto/HttpTransport.cpp b/td/mtproto/HttpTransport.cpp index df1a3a3f..832c88d7 100644 --- a/td/mtproto/HttpTransport.cpp +++ b/td/mtproto/HttpTransport.cpp @@ -72,7 +72,7 @@ void Transport::write(BufferWriter &&message, bool quick_ack) { Slice src = r_head.ok(); // LOG(DEBUG) << src; MutableSlice dst = message.prepare_prepend(); - CHECK(dst.size() >= src.size()) << dst.size() << " >= " << src.size(); + LOG_CHECK(dst.size() >= src.size()) << dst.size() << " >= " << src.size(); std::memcpy(dst.end() - src.size(), src.begin(), src.size()); message.confirm_prepend(src.size()); output_->append(message.as_buffer_slice()); diff --git a/td/mtproto/RawConnection.cpp b/td/mtproto/RawConnection.cpp index add181d7..e4da95d0 100644 --- a/td/mtproto/RawConnection.cpp +++ b/td/mtproto/RawConnection.cpp @@ -74,7 +74,7 @@ Status RawConnection::flush_read(const AuthKey &auth_key, Callback &callback) { new_packet.as_slice().copy_from(packet.as_slice()); packet = std::move(new_packet); } - CHECK(is_aligned_pointer<4>(packet.as_slice().ubegin())) + LOG_CHECK(is_aligned_pointer<4>(packet.as_slice().ubegin())) << packet.as_slice().ubegin() << ' ' << packet.size() << ' ' << wait_size; if (wait_size != 0) { constexpr size_t MAX_PACKET_SIZE = (1 << 22) + 1024; diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index 47793f31..b8ef01ca 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -742,7 +742,7 @@ void SessionConnection::send_crypto(const Storer &storer, uint64 quick_ack_token Result SessionConnection::send_query(BufferSlice buffer, bool gzip_flag, int64 message_id, uint64 invoke_after_id, bool use_quick_ack) { - CHECK(mode_ != Mode::HttpLongPoll) << "LongPoll connection is only for http_wait"; + LOG_CHECK(mode_ != Mode::HttpLongPoll) << "LongPoll connection is only for http_wait"; if (message_id == 0) { message_id = auth_data_->next_message_id(Time::now_cached()); } diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index f256f07e..b3170b40 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -151,7 +151,7 @@ tl_object_ptr AnimationsManager::get_animation_object(FileId } auto &animation = animations_[file_id]; - CHECK(animation != nullptr) << source << " " << file_id << " " + LOG_CHECK(animation != nullptr) << source << " " << file_id << " " << static_cast(td_->file_manager_->get_file_view(file_id).get_type()); // TODO can we make that function const? animation->is_changed = false; @@ -589,7 +589,7 @@ int32 AnimationsManager::get_saved_animations_hash(const char *source) const { CHECK(animation != nullptr); auto file_view = td_->file_manager_->get_file_view(animation_id); CHECK(file_view.has_remote_location()); - CHECK(file_view.remote_location().is_document()) << source << " " << file_view.remote_location(); + LOG_CHECK(file_view.remote_location().is_document()) << source << " " << file_view.remote_location(); auto id = static_cast(file_view.remote_location().get_id()); numbers.push_back(static_cast(id >> 32)); numbers.push_back(static_cast(id & 0xFFFFFFFF)); @@ -619,7 +619,7 @@ void AnimationsManager::send_save_gif_query(FileId animation_id, bool unsave, Pr // TODO invokeAfter and log event auto file_view = td_->file_manager_->get_file_view(animation_id); CHECK(file_view.has_remote_location()); - CHECK(file_view.remote_location().is_document()) << file_view.remote_location(); + LOG_CHECK(file_view.remote_location().is_document()) << file_view.remote_location(); CHECK(!file_view.remote_location().is_web()); td_->create_handler(std::move(promise)) ->send(animation_id, file_view.remote_location().as_input_document(), unsave); diff --git a/td/telegram/CallActor.cpp b/td/telegram/CallActor.cpp index b4954b60..703fabdc 100644 --- a/td/telegram/CallActor.cpp +++ b/td/telegram/CallActor.cpp @@ -312,7 +312,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallRequested &call) { } tl_object_ptr CallActor::get_input_phone_call(const char *source) { - CHECK(is_call_id_inited_) << source; + LOG_CHECK(is_call_id_inited_) << source; return make_tl_object(call_id_, call_access_hash_); } diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 9abc6220..c3baeeb7 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -5208,7 +5208,7 @@ void ContactsManager::on_binlog_user_event(BinlogEvent &&event) { binlog_erase(G()->td_db()->get_binlog(), event.id_); return; // TODO fix bug in Binlog and remove that fix } - CHECK(u->first_name.empty() && u->last_name.empty()) << user_id << " " << u->debug_source; + LOG_CHECK(u->first_name.empty() && u->last_name.empty()) << user_id << " " << u->debug_source; *u = std::move(log_event.u); // users come from binlog before all other events, so just add them u->logevent_id = event.id_; @@ -5257,7 +5257,7 @@ void ContactsManager::save_user_to_database_impl(User *u, UserId user_id, string void ContactsManager::on_save_user_to_database(UserId user_id, bool success) { User *u = get_user(user_id); CHECK(u != nullptr); - CHECK(u->is_being_saved) << user_id << " " << u->is_saved << " " << u->is_status_saved << " " + LOG_CHECK(u->is_being_saved) << user_id << " " << u->is_saved << " " << u->is_status_saved << " " << load_user_from_database_queries_.count(user_id) << " " << u->is_received << " " << u->is_deleted << " " << u->is_bot << " " << u->is_changed << " " << u->need_send_update << " " << u->is_status_changed << " " << u->is_name_changed << " " << u->is_username_changed @@ -5691,7 +5691,7 @@ void ContactsManager::on_binlog_channel_event(BinlogEvent &&event) { binlog_erase(G()->td_db()->get_binlog(), event.id_); return; // TODO fix bug in Binlog and remove that fix } - CHECK(c->status.is_banned()) << channel_id << " " << c->debug_source; + LOG_CHECK(c->status.is_banned()) << channel_id << " " << c->debug_source; *c = std::move(log_event.c); // channels come from binlog before all other events, so just add them c->logevent_id = event.id_; diff --git a/td/telegram/DocumentsManager.cpp b/td/telegram/DocumentsManager.cpp index 5133afb2..e47ab748 100644 --- a/td/telegram/DocumentsManager.cpp +++ b/td/telegram/DocumentsManager.cpp @@ -52,7 +52,7 @@ tl_object_ptr DocumentsManager::get_document_object(FileId fil LOG(INFO) << "Return document " << file_id << " object"; auto &document = documents_[file_id]; - CHECK(document != nullptr) << tag("file_id", file_id); + LOG_CHECK(document != nullptr) << tag("file_id", file_id); document->is_changed = false; return make_tl_object(document->file_name, document->mime_type, get_photo_size_object(td_->file_manager_.get(), &document->thumbnail), diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 80371c00..bc0ecebb 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -1661,7 +1661,7 @@ vector> get_input_message_entities(co break; case MessageEntity::Type::MentionName: { auto input_user = contacts_manager->get_input_user(entity.user_id); - CHECK(input_user != nullptr) << source; + LOG_CHECK(input_user != nullptr) << source; result.push_back(make_tl_object(entity.offset, entity.length, std::move(input_user))); break; diff --git a/td/telegram/MessagesDb.cpp b/td/telegram/MessagesDb.cpp index 53e4aecf..e5bf47cb 100644 --- a/td/telegram/MessagesDb.cpp +++ b/td/telegram/MessagesDb.cpp @@ -431,7 +431,7 @@ class MessagesDbImpl : public MessagesDbSyncInterface { MessageId last_message_id, int32 date) override { int64 left_message_id = first_message_id.get(); int64 right_message_id = last_message_id.get(); - CHECK(left_message_id <= right_message_id) << first_message_id << " " << last_message_id; + LOG_CHECK(left_message_id <= right_message_id) << first_message_id << " " << last_message_id; TRY_RESULT(first_messages, get_messages_inner(get_messages_stmt_.asc_stmt_, dialog_id.get(), left_message_id - 1, 1)); if (!first_messages.empty()) { @@ -661,7 +661,7 @@ class MessagesDbImpl : public MessagesDbSyncInterface { Result> get_messages_from_index(DialogId dialog_id, MessageId from_message_id, int32 index_mask, int32 offset, int32 limit) { CHECK(index_mask != 0); - CHECK(index_mask < (1 << MESSAGES_DB_INDEX_COUNT)) << tag("index_mask", index_mask); + LOG_CHECK(index_mask < (1 << MESSAGES_DB_INDEX_COUNT)) << tag("index_mask", index_mask); int index_i = -1; for (int i = 0; i < MESSAGES_DB_INDEX_COUNT; i++) { if (index_mask == (1 << i)) { @@ -679,7 +679,7 @@ class MessagesDbImpl : public MessagesDbSyncInterface { Result get_calls(MessagesDbCallsQuery query) override { CHECK(query.index_mask != 0); - CHECK(query.index_mask < (1 << MESSAGES_DB_INDEX_COUNT)) << tag("index_mask", query.index_mask); + LOG_CHECK(query.index_mask < (1 << MESSAGES_DB_INDEX_COUNT)) << tag("index_mask", query.index_mask); int index_i = -1; for (int i = 0; i < MESSAGES_DB_INDEX_COUNT; i++) { if (query.index_mask == (1 << i)) { @@ -754,7 +754,7 @@ class MessagesDbImpl : public MessagesDbSyncInterface { Result> get_messages_impl(GetMessagesStmt &stmt, DialogId dialog_id, MessageId from_message_id, int32 offset, int32 limit) { - CHECK(dialog_id.is_valid()) << dialog_id; + LOG_CHECK(dialog_id.is_valid()) << dialog_id; CHECK(from_message_id.is_valid()); LOG(INFO) << "Loading messages in " << dialog_id << " from " << from_message_id << " with offset = " << offset diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index fcbadeb0..d48276db 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -3872,7 +3872,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) { parser.set_error("Wrong first_database_message_id_by_index table size"); return; } - CHECK(static_cast(size) <= first_database_message_id_by_index.size()) + LOG_CHECK(static_cast(size) <= first_database_message_id_by_index.size()) << size << " " << first_database_message_id_by_index.size(); for (int32 i = 0; i < size; i++) { parse(first_database_message_id_by_index[i], parser); @@ -3938,7 +3938,7 @@ void MessagesManager::CallsDbState::parse(ParserT &parser) { using td::parse; int32 size; parse(size, parser); - CHECK(static_cast(size) <= first_calls_database_message_id_by_index.size()) + LOG_CHECK(static_cast(size) <= first_calls_database_message_id_by_index.size()) << size << " " << first_calls_database_message_id_by_index.size(); for (int32 i = 0; i < size; i++) { parse(first_calls_database_message_id_by_index[i], parser); @@ -5002,7 +5002,7 @@ bool MessagesManager::update_message_views(DialogId dialog_id, Message *m, int32 bool MessagesManager::update_message_contains_unread_mention(Dialog *d, Message *m, bool contains_unread_mention, const char *source) { - CHECK(m != nullptr) << source; + LOG_CHECK(m != nullptr) << source; if (!contains_unread_mention && m->contains_unread_mention) { remove_message_notification_id(d, m, true); // should be called before contains_unread_mention is updated @@ -5368,7 +5368,7 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p if (d == nullptr || pts_count > 0) { process_channel_update(std::move(update)); - CHECK(!running_get_channel_difference(dialog_id)) << '"' << active_get_channel_differencies_[dialog_id] << '"'; + LOG_CHECK(!running_get_channel_difference(dialog_id)) << '"' << active_get_channel_differencies_[dialog_id] << '"'; } else { LOG_IF(INFO, update->get_id() != dummyUpdate::ID) << "Skip useless channel update from " << source << ": " << to_string(update); @@ -5583,7 +5583,7 @@ bool MessagesManager::update_dialog_notification_settings(DialogId dialog_id, if (is_changed) { Dialog *d = get_dialog(dialog_id); - CHECK(d != nullptr) << "Wrong " << dialog_id << " in update_dialog_notification_settings"; + LOG_CHECK(d != nullptr) << "Wrong " << dialog_id << " in update_dialog_notification_settings"; bool was_muted = is_dialog_muted(d); bool was_dialog_mentions_disabled = is_dialog_mention_notifications_disabled(d); update_dialog_unmute_timeout(d, current_settings->use_default_mute_until, current_settings->mute_until, @@ -6733,7 +6733,7 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_ } is_dialog_updated = true; } else { - CHECK(d->last_new_message_id.is_valid()) + LOG_CHECK(d->last_new_message_id.is_valid()) << dialog_id << " " << from_the_end << " " << d->first_database_message_id << " " << d->last_database_message_id << " " << first_added_message_id << " " << last_added_message_id << " " << d->last_message_id << " " << d->last_new_message_id << " " << d->have_full_history << " " @@ -6773,7 +6773,7 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_ } } } - CHECK(d->first_database_message_id.is_valid()) + LOG_CHECK(d->first_database_message_id.is_valid()) << dialog_id << " " << from_the_end << " " << d->first_database_message_id << " " << d->last_database_message_id << " " << first_added_message_id << " " << last_added_message_id << " " << d->last_message_id << " " << d->last_new_message_id << " " << d->have_full_history << " " << prev_last_new_message_id << " " @@ -7952,7 +7952,7 @@ void MessagesManager::read_channel_message_content_from_updates(Dialog *d, Messa } bool MessagesManager::read_message_content(Dialog *d, Message *m, bool is_local_read, const char *source) { - CHECK(m != nullptr) << source; + LOG_CHECK(m != nullptr) << source; bool is_mention_read = update_message_contains_unread_mention(d, m, false, "read_message_content"); bool is_content_read = update_opened_message_content(m->content.get()) | ttl_on_open(d, m, Time::now(), is_local_read); @@ -8556,7 +8556,8 @@ void MessagesManager::ttl_unregister_message(DialogId dialog_id, const Message * TtlNode ttl_node(dialog_id, message->message_id); auto it = ttl_nodes_.find(ttl_node); - CHECK(it != ttl_nodes_.end()) << dialog_id << " " << message->message_id << " " << source << " " << G()->close_flag(); + LOG_CHECK(it != ttl_nodes_.end()) << dialog_id << " " << message->message_id << " " << source << " " + << G()->close_flag(); auto *heap_node = it->as_heap_node(); if (heap_node->in_heap()) { ttl_heap_.erase(heap_node); @@ -9350,7 +9351,7 @@ void MessagesManager::fix_message_info_dialog_id(MessageInfo &message_info) cons MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message( tl_object_ptr message_ptr, const char *source) const { LOG(DEBUG) << "Receive from " << source << " " << to_string(message_ptr); - CHECK(message_ptr != nullptr) << source; + LOG_CHECK(message_ptr != nullptr) << source; int32 constructor_id = message_ptr->get_id(); MessageInfo message_info; @@ -9758,7 +9759,7 @@ void MessagesManager::set_dialog_last_database_message_id(Dialog *d, MessageId l } void MessagesManager::set_dialog_last_new_message_id(Dialog *d, MessageId last_new_message_id, const char *source) { - CHECK(last_new_message_id.get() > d->last_new_message_id.get()) + LOG_CHECK(last_new_message_id.get() > d->last_new_message_id.get()) << last_new_message_id << " " << d->last_new_message_id << " " << source; CHECK(d->dialog_id.get_type() == DialogType::SecretChat || last_new_message_id.is_server()); if (!d->last_new_message_id.is_valid()) { @@ -9900,7 +9901,7 @@ void MessagesManager::set_dialog_is_pinned(Dialog *d, bool is_pinned) { if (is_pinned != was_pinned) { LOG(INFO) << "Set " << d->dialog_id << " is pinned to " << is_pinned; - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_is_pinned"; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_is_pinned"; update_dialog_pos(d, false, "set_dialog_is_pinned", false); DialogDate dialog_date(d->order, d->dialog_id); send_closure(G()->td(), &Td::send_update, @@ -9917,7 +9918,7 @@ void MessagesManager::set_dialog_reply_markup(Dialog *d, MessageId message_id) { d->need_restore_reply_markup = false; if (d->reply_markup_message_id.is_valid() || message_id.is_valid()) { - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_reply_markup"; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_reply_markup"; d->reply_markup_message_id = message_id; send_closure(G()->td(), &Td::send_update, make_tl_object(d->dialog_id.get(), message_id.get())); @@ -14410,7 +14411,8 @@ void MessagesManager::on_get_history_from_database(DialogId dialog_id, MessageId added_new_message = true; } if (next_message != nullptr && !next_message->have_previous) { - CHECK(m->message_id.get() < next_message->message_id.get()) << m->message_id << ' ' << next_message->message_id; + LOG_CHECK(m->message_id.get() < next_message->message_id.get()) + << m->message_id << ' ' << next_message->message_id; LOG(INFO) << "Fix have_previous for " << next_message->message_id; next_message->have_previous = true; attach_message_to_previous( @@ -14455,7 +14457,7 @@ void MessagesManager::on_get_history_from_database(DialogId dialog_id, MessageId if (last_added_message_id.get() < d->first_database_message_id.get() || !d->first_database_message_id.is_valid()) { CHECK(next_message != nullptr); - CHECK(had_full_history || d->have_full_history) + LOG_CHECK(had_full_history || d->have_full_history) << had_full_history << ' ' << d->have_full_history << ' ' << next_message->message_id << ' ' << last_added_message_id << ' ' << d->first_database_message_id << ' ' << debug_first_message_id << ' ' << d->last_database_message_id << ' ' << debug_last_database_message_id; @@ -15727,7 +15729,7 @@ void MessagesManager::do_send_message_group(int64 media_album_id) { pending_message_group_sends_.erase(it); return; } - CHECK(request.finished_count == request.message_ids.size()) + LOG_CHECK(request.finished_count == request.message_ids.size()) << request.finished_count << " " << request.message_ids.size(); pending_message_group_sends_.erase(it); @@ -17640,7 +17642,7 @@ Result MessagesManager::add_local_message( bool need_update_dialog_pos = false; auto result = add_message_to_dialog(d, std::move(m), true, &need_update, &need_update_dialog_pos, "add local message"); - CHECK(result != nullptr) << message_id << " " << debug_add_message_to_dialog_fail_reason_; + LOG_CHECK(result != nullptr) << message_id << " " << debug_add_message_to_dialog_fail_reason_; if (is_message_auto_read(dialog_id, result->is_outgoing)) { if (result->is_outgoing) { @@ -18604,8 +18606,8 @@ void MessagesManager::send_update_message_content(DialogId dialog_id, MessageId const MessageContent *content, int32 message_date, bool is_content_secret, const char *source) const { LOG(INFO) << "Send updateMessageContent for " << message_id << " in " << dialog_id << " from " << source; - CHECK(have_dialog(dialog_id)) << "Send updateMessageContent in unknown " << dialog_id << " from " << source - << " with load count " << loaded_dialogs_.count(dialog_id); + LOG_CHECK(have_dialog(dialog_id)) << "Send updateMessageContent in unknown " << dialog_id << " from " << source + << " with load count " << loaded_dialogs_.count(dialog_id); auto content_object = get_message_content_object(content, td_, message_date, is_content_secret); send_closure( G()->td(), &Td::send_update, @@ -18623,7 +18625,7 @@ void MessagesManager::send_update_message_edited(DialogId dialog_id, const Messa void MessagesManager::send_update_delete_messages(DialogId dialog_id, vector &&message_ids, bool is_permanent, bool from_cache) const { if (!message_ids.empty()) { - CHECK(have_dialog(dialog_id)) << "Wrong " << dialog_id << " in send_update_delete_messages"; + LOG_CHECK(have_dialog(dialog_id)) << "Wrong " << dialog_id << " in send_update_delete_messages"; send_closure(G()->td(), &Td::send_update, make_tl_object(dialog_id.get(), std::move(message_ids), is_permanent, from_cache)); @@ -18639,7 +18641,7 @@ void MessagesManager::send_update_new_chat(Dialog *d) { void MessagesManager::send_update_chat_draft_message(const Dialog *d) { CHECK(d != nullptr); - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_draft_message"; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_draft_message"; on_dialog_updated(d->dialog_id, "send_update_chat_draft_message"); send_closure(G()->td(), &Td::send_update, make_tl_object( @@ -18654,7 +18656,8 @@ void MessagesManager::send_update_chat_last_message(Dialog *d, const char *sourc void MessagesManager::send_update_chat_last_message_impl(const Dialog *d, const char *source) const { CHECK(d != nullptr); - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_last_message from " << source; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_last_message from " + << source; LOG(INFO) << "Send updateChatLastMessage in " << d->dialog_id << " to " << d->last_message_id << " from " << source; auto update = make_tl_object( d->dialog_id.get(), get_message_object(d->dialog_id, get_message(d, d->last_message_id)), @@ -18739,7 +18742,8 @@ void MessagesManager::send_update_unread_chat_count(DialogId dialog_id, bool for void MessagesManager::send_update_chat_read_inbox(const Dialog *d, bool force, const char *source) { CHECK(d != nullptr); if (!td_->auth_manager_->is_bot()) { - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_read_inbox from " << source; + LOG_CHECK(d->is_update_new_chat_sent) + << "Wrong " << d->dialog_id << " in send_update_chat_read_inbox from " << source; on_dialog_updated(d->dialog_id, source); if (!force && (running_get_difference_ || running_get_channel_difference(d->dialog_id) || get_channel_difference_to_logevent_id_.count(d->dialog_id) != 0)) { @@ -18760,7 +18764,7 @@ void MessagesManager::send_update_chat_read_inbox(const Dialog *d, bool force, c void MessagesManager::send_update_chat_read_outbox(const Dialog *d) { CHECK(d != nullptr); if (!td_->auth_manager_->is_bot()) { - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_read_outbox"; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_read_outbox"; on_dialog_updated(d->dialog_id, "send_update_chat_read_outbox"); send_closure( G()->td(), &Td::send_update, @@ -18771,7 +18775,7 @@ void MessagesManager::send_update_chat_read_outbox(const Dialog *d) { void MessagesManager::send_update_chat_unread_mention_count(const Dialog *d) { CHECK(d != nullptr); if (!td_->auth_manager_->is_bot()) { - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_unread_mention_count"; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_unread_mention_count"; LOG(INFO) << "Update unread mention message count in " << d->dialog_id << " to " << d->unread_mention_count; on_dialog_updated(d->dialog_id, "send_update_chat_unread_mention_count"); send_closure(G()->td(), &Td::send_update, @@ -18903,8 +18907,8 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI if (date <= 0) { LOG(ERROR) << "Receive " << new_message_id << " in " << dialog_id << " with wrong date " << date; } else { - CHECK(sent_message->date > 0) << old_message_id << ' ' << sent_message->message_id << ' ' << sent_message->date - << ' ' << date; + LOG_CHECK(sent_message->date > 0) << old_message_id << ' ' << sent_message->message_id << ' ' << sent_message->date + << ' ' << date; sent_message->date = date; CHECK(d->last_message_id != old_message_id); } @@ -18928,8 +18932,8 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI bool need_update = true; Message *m = add_message_to_dialog(d, std::move(sent_message), true, &need_update, &need_update_dialog_pos, source); - CHECK(m != nullptr) << dialog_id << " " << have_input_peer(dialog_id, AccessRights::Read) << " " - << debug_add_message_to_dialog_fail_reason_ << " " << source; + LOG_CHECK(m != nullptr) << dialog_id << " " << have_input_peer(dialog_id, AccessRights::Read) << " " + << debug_add_message_to_dialog_fail_reason_ << " " << source; send_update_message_send_succeeded(d, old_message_id, m); if (need_update_dialog_pos) { @@ -19282,7 +19286,7 @@ MessageId MessagesManager::get_next_message_id(Dialog *d, int32 type) { int64 base = (last + MessageId::TYPE_MASK + 1) & ~MessageId::TYPE_MASK; d->last_assigned_message_id = MessageId(base + type); - CHECK(d->last_assigned_message_id.is_valid()) << d->last_assigned_message_id; + LOG_CHECK(d->last_assigned_message_id.is_valid()) << d->last_assigned_message_id; return d->last_assigned_message_id; } @@ -19333,8 +19337,8 @@ void MessagesManager::fail_send_message(FullMessageId full_message_id, int error bool need_update = false; Message *m = add_message_to_dialog(dialog_id, std::move(message), false, &need_update, &need_update_dialog_pos, "fail_send_message"); - CHECK(m != nullptr) << "Failed to add failed to send " << new_message_id << " to " << dialog_id << " due to " - << debug_add_message_to_dialog_fail_reason_; + LOG_CHECK(m != nullptr) << "Failed to add failed to send " << new_message_id << " to " << dialog_id << " due to " + << debug_add_message_to_dialog_fail_reason_; LOG(INFO) << "Send updateMessageSendFailed for " << full_message_id; d->yet_unsent_message_id_to_persistent_message_id.emplace(old_message_id, m->message_id); @@ -19475,7 +19479,7 @@ void MessagesManager::set_dialog_is_marked_as_unread(Dialog *d, bool is_marked_a on_dialog_updated(d->dialog_id, "set_dialog_is_marked_as_unread"); LOG(INFO) << "Set " << d->dialog_id << " is marked as unread to " << is_marked_as_unread; - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_is_marked_as_unread"; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_is_marked_as_unread"; send_closure(G()->td(), &Td::send_update, make_tl_object(d->dialog_id.get(), is_marked_as_unread)); @@ -19523,7 +19527,7 @@ void MessagesManager::set_dialog_pinned_message_id(Dialog *d, MessageId pinned_m on_dialog_updated(d->dialog_id, "set_dialog_pinned_message_id"); LOG(INFO) << "Set " << d->dialog_id << " pinned message to " << pinned_message_id; - CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_pinned_message_id"; + LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_pinned_message_id"; send_closure(G()->td(), &Td::send_update, make_tl_object(d->dialog_id.get(), pinned_message_id.get())); } @@ -21419,7 +21423,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq } // there must be no two recursive calls to add_message_to_dialog - CHECK(!d->being_added_message_id.is_valid()) << d->being_added_message_id << " " << message_id << " " << source; + LOG_CHECK(!d->being_added_message_id.is_valid()) << d->being_added_message_id << " " << message_id << " " << source; d->being_added_message_id = message_id; if (d->new_secret_chat_notification_id.is_valid()) { @@ -21865,7 +21869,7 @@ void MessagesManager::add_message_to_database(const Dialog *d, const Message *m, CHECK(d != nullptr); CHECK(m != nullptr); MessageId message_id = m->message_id; - CHECK(message_id.is_server() || message_id.is_local()) << source; + LOG_CHECK(message_id.is_server() || message_id.is_local()) << source; LOG(INFO) << "Add " << FullMessageId(d->dialog_id, message_id) << " to database from " << source; @@ -22076,9 +22080,9 @@ void MessagesManager::attach_message_to_previous(Dialog *d, MessageId message_id Message *message = *it; CHECK(message != nullptr); CHECK(message->message_id == message_id); - CHECK(message->have_previous) << d->dialog_id << " " << message_id << " " << source; + LOG_CHECK(message->have_previous) << d->dialog_id << " " << message_id << " " << source; --it; - CHECK(*it != nullptr) << d->dialog_id << " " << message_id << " " << source; + LOG_CHECK(*it != nullptr) << d->dialog_id << " " << message_id << " " << source; LOG(INFO) << "Attach " << message_id << " to the previous " << (*it)->message_id; if ((*it)->have_next) { message->have_next = true; @@ -22093,9 +22097,9 @@ void MessagesManager::attach_message_to_next(Dialog *d, MessageId message_id, co Message *message = *it; CHECK(message != nullptr); CHECK(message->message_id == message_id); - CHECK(message->have_next) << d->dialog_id << " " << message_id << " " << source; + LOG_CHECK(message->have_next) << d->dialog_id << " " << message_id << " " << source; ++it; - CHECK(*it != nullptr) << d->dialog_id << " " << message_id << " " << source; + LOG_CHECK(*it != nullptr) << d->dialog_id << " " << message_id << " " << source; LOG(INFO) << "Attach " << message_id << " to the next " << (*it)->message_id; if ((*it)->have_previous) { message->have_previous = true; @@ -22472,16 +22476,16 @@ MessageId MessagesManager::get_message_id_by_random_id(Dialog *d, int64 random_i debug_add_message_to_dialog_fail_reason_ = "not called"; Message *m = on_get_message_from_database(d->dialog_id, d, r_value.ok(), "get_message_id_by_random_id"); if (m != nullptr) { - CHECK(m->random_id == random_id) + LOG_CHECK(m->random_id == random_id) << random_id << " " << m->random_id << " " << d->random_id_to_message_id[random_id] << " " << d->random_id_to_message_id[m->random_id] << " " << m->message_id << " " << source << " " << m->from_database << get_message(d, m->message_id) << " " << m << " " << debug_add_message_to_dialog_fail_reason_; - CHECK(d->random_id_to_message_id.count(random_id)) + LOG_CHECK(d->random_id_to_message_id.count(random_id)) << source << " " << random_id << " " << m->message_id << " " << m->is_failed_to_send << " " << m->is_outgoing << " " << m->from_database << " " << get_message(d, m->message_id) << " " << m << " " << debug_add_message_to_dialog_fail_reason_; - CHECK(d->random_id_to_message_id[random_id] == m->message_id) + LOG_CHECK(d->random_id_to_message_id[random_id] == m->message_id) << source << " " << random_id << " " << d->random_id_to_message_id[random_id] << " " << m->message_id << " " << m->is_failed_to_send << " " << m->is_outgoing << " " << m->from_database << " " << get_message(d, m->message_id) << " " << m << " " << debug_add_message_to_dialog_fail_reason_; @@ -22891,7 +22895,7 @@ void MessagesManager::add_dialog_last_database_message(Dialog *d, unique_ptrright == nullptr); auto message_id = last_database_message->message_id; - CHECK(d->last_database_message_id == message_id) + LOG_CHECK(d->last_database_message_id == message_id) << message_id << " " << d->last_database_message_id << " " << d->debug_set_dialog_last_database_message_id; if (!have_input_peer(d->dialog_id, AccessRights::Read)) { @@ -23283,7 +23287,7 @@ MessagesManager::Dialog *MessagesManager::get_dialog_force(DialogId dialog_id) { if (r_value.is_ok()) { LOG(INFO) << "Loaded " << dialog_id << " from database"; auto d = on_load_dialog_from_database(dialog_id, r_value.move_as_ok()); - CHECK(d == nullptr || d->dialog_id == dialog_id) << d->dialog_id << " " << dialog_id; + LOG_CHECK(d == nullptr || d->dialog_id == dialog_id) << d->dialog_id << " " << dialog_id; return d; } else { LOG(INFO) << "Failed to load " << dialog_id << " from database: " << r_value.error().message(); @@ -23302,8 +23306,8 @@ unique_ptr MessagesManager::parse_dialog(DialogId dialo if (status.is_error() || !d->dialog_id.is_valid() || d->dialog_id != dialog_id) { // can't happen unless database is broken, but has been seen in the wild // if dialog_id is invalid, we can't repair the dialog - CHECK(dialog_id.is_valid()) << "Can't repair " << dialog_id << ' ' << d->dialog_id << ' ' << status << ' ' - << format::as_hex_dump<4>(value.as_slice()); + LOG_CHECK(dialog_id.is_valid()) << "Can't repair " << dialog_id << ' ' << d->dialog_id << ' ' << status << ' ' + << format::as_hex_dump<4>(value.as_slice()); LOG(ERROR) << "Repair broken " << dialog_id << ' ' << format::as_hex_dump<4>(value.as_slice()); @@ -23549,7 +23553,7 @@ void MessagesManager::process_get_channel_difference_updates( } } } - CHECK(!running_get_channel_difference(dialog_id)) << '"' << active_get_channel_differencies_[dialog_id] << '"'; + LOG_CHECK(!running_get_channel_difference(dialog_id)) << '"' << active_get_channel_differencies_[dialog_id] << '"'; if (need_repair_unread_count) { repair_channel_server_unread_count(get_dialog(dialog_id)); @@ -23796,7 +23800,7 @@ void MessagesManager::on_get_channel_difference( void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool success) { LOG(INFO) << "After " << (success ? "un" : "") << "successful get channel difference in " << dialog_id; - CHECK(!running_get_channel_difference(dialog_id)) << '"' << active_get_channel_differencies_[dialog_id] << '"'; + LOG_CHECK(!running_get_channel_difference(dialog_id)) << '"' << active_get_channel_differencies_[dialog_id] << '"'; auto logevent_it = get_channel_difference_to_logevent_id_.find(dialog_id); if (logevent_it != get_channel_difference_to_logevent_id_.end()) { diff --git a/td/telegram/RequestActor.h b/td/telegram/RequestActor.h index cbb0808e..2984cb88 100644 --- a/td/telegram/RequestActor.h +++ b/td/telegram/RequestActor.h @@ -151,4 +151,4 @@ class RequestOnceActor : public RequestActor<> { } }; -} // namespace td \ No newline at end of file +} // namespace td diff --git a/td/telegram/SecretChatActor.cpp b/td/telegram/SecretChatActor.cpp index 5e784b4b..049290cd 100644 --- a/td/telegram/SecretChatActor.cpp +++ b/td/telegram/SecretChatActor.cpp @@ -173,7 +173,7 @@ void SecretChatActor::replay_inbound_message(unique_ptrmessage_id > last_binlog_message_id_) + LOG_CHECK(message->message_id > last_binlog_message_id_) << tag("last_binlog_message_id", last_binlog_message_id_) << tag("message_id", message->message_id); last_binlog_message_id_ = message->message_id; check_status(do_inbound_message_decrypted(std::move(message))); @@ -190,7 +190,7 @@ void SecretChatActor::replay_outbound_message(unique_ptrmessage_id > last_binlog_message_id_) + LOG_CHECK(message->message_id > last_binlog_message_id_) << tag("last_binlog_message_id", last_binlog_message_id_) << tag("message_id", message->message_id); last_binlog_message_id_ = message->message_id; do_outbound_message_impl(std::move(message), Promise<>()); @@ -310,8 +310,8 @@ void SecretChatActor::send_message_impl(tl_object_ptr config_state_.his_layer) { return promise.set_error(Status::Error(400, "Message is not supported by the other side")); } - CHECK(binlog_replay_finish_flag_) << "Trying to send message before binlog replay is finished: " - << to_string(*message) << to_string(file); + LOG_CHECK(binlog_replay_finish_flag_) << "Trying to send message before binlog replay is finished: " + << to_string(*message) << to_string(file); int64 random_id = 0; downcast_call(*message, [&](auto &x) { random_id = x.random_id_; }); @@ -1055,7 +1055,7 @@ void SecretChatActor::do_outbound_message_impl(unique_ptrcrc = crc64(binlog_event->encrypted_message.as_slice()); LOG(INFO) << "Do outbound message: " << *binlog_event << tag("crc", binlog_event->crc); auto &state_id_ref = random_id_to_outbound_message_state_token_[binlog_event->random_id]; - CHECK(state_id_ref == 0) << "Random id collision"; + LOG_CHECK(state_id_ref == 0) << "Random id collision"; state_id_ref = outbound_message_states_.create(); const uint64 state_id = state_id_ref; auto *state = outbound_message_states_.get(state_id); @@ -2094,7 +2094,7 @@ Status SecretChatActor::on_inbound_action(secret_api::decryptedMessageActionTypi // Perfect Forward Secrecy void SecretChatActor::on_outbound_action(secret_api::decryptedMessageActionRequestKey &request_key) { - CHECK(pfs_state_.state == PfsState::WaitSendRequest || pfs_state_.state == PfsState::SendRequest) << pfs_state_; + LOG_CHECK(pfs_state_.state == PfsState::WaitSendRequest || pfs_state_.state == PfsState::SendRequest) << pfs_state_; pfs_state_.state = PfsState::WaitRequestResponse; on_pfs_state_changed(); } @@ -2145,7 +2145,7 @@ Status SecretChatActor::on_inbound_action(secret_api::decryptedMessageActionRequ if (pfs_state_.state != PfsState::Empty) { return Status::Error("Unexpected RequestKey"); } - CHECK(pfs_state_.other_auth_key.empty()) << "TODO: got requestKey, before old key is dropped"; + LOG_CHECK(pfs_state_.other_auth_key.empty()) << "TODO: got requestKey, before old key is dropped"; pfs_state_.state = PfsState::SendAccept; pfs_state_.handshake = DhHandshake(); pfs_state_.exchange_id = request_key.exchange_id_; diff --git a/td/telegram/StickersManager.hpp b/td/telegram/StickersManager.hpp index 7e26eb4f..d6293634 100644 --- a/td/telegram/StickersManager.hpp +++ b/td/telegram/StickersManager.hpp @@ -62,7 +62,7 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, T &parser) { PARSE_FLAG(has_sticker_set_access_hash); PARSE_FLAG(in_sticker_set_stored); END_PARSE_FLAGS(); - CHECK(in_sticker_set_stored == in_sticker_set) + LOG_CHECK(in_sticker_set_stored == in_sticker_set) << in_sticker_set << " " << in_sticker_set_stored << " " << parser.version() << " " << sticker->is_mask << " " << has_sticker_set_access_hash << " " << format::as_hex_dump<4>(parser.template fetch_string_raw(parser.get_left_len())); diff --git a/td/telegram/TdDb.cpp b/td/telegram/TdDb.cpp index f61478d3..3b86a19b 100644 --- a/td/telegram/TdDb.cpp +++ b/td/telegram/TdDb.cpp @@ -216,7 +216,7 @@ void TdDb::do_close(Promise<> on_finished, bool destroy_flag) { mpas.add_promise(PromiseCreator::lambda( [promise = std::move(on_finished), sql_connection = std::move(sql_connection_), destroy_flag](Unit) mutable { if (sql_connection) { - CHECK(sql_connection.unique()) << sql_connection.use_count(); + LOG_CHECK(sql_connection.unique()) << sql_connection.use_count(); if (destroy_flag) { sql_connection->close_and_destroy(); } else { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 501b3989..8e6f38d7 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -590,7 +590,7 @@ class CliClient final : public Actor { from_json(object, as_json_value).ensure(); CHECK(object != nullptr); auto as_json_str2 = json_encode(ToJson(object)); - CHECK(as_json_str == as_json_str2) << "\n" << tag("a", as_json_str) << "\n" << tag("b", as_json_str2); + LOG_CHECK(as_json_str == as_json_str2) << "\n" << tag("a", as_json_str) << "\n" << tag("b", as_json_str2); // LOG(INFO) << "on_result [" << generation << "][id=" << id << "] " << as_json_str; if (generation != generation_) { diff --git a/td/telegram/files/FileDownloader.cpp b/td/telegram/files/FileDownloader.cpp index fcbe6fc5..94fb3b66 100644 --- a/td/telegram/files/FileDownloader.cpp +++ b/td/telegram/files/FileDownloader.cpp @@ -77,7 +77,7 @@ Result FileDownloader::init() { if (result_fd.is_ok()) { bitmask = Bitmask(Bitmask::Decode{}, partial.ready_bitmask_); if (encryption_key_.is_secret()) { - CHECK(partial.iv_.size() == 32) << partial.iv_.size(); + LOG_CHECK(partial.iv_.size() == 32) << partial.iv_.size(); encryption_key_.mutable_iv() = as(partial.iv_.data()); next_part_ = narrow_cast(bitmask.get_ready_parts(0)); } @@ -342,7 +342,7 @@ Result FileDownloader::process_part(Part part, NetQueryPtr net_query) { ctr_state.decrypt(bytes.as_slice(), bytes.as_slice()); } if (encryption_key_.is_secret()) { - CHECK(next_part_ == part.id) << tag("expected part.id", next_part_) << "!=" << tag("part.id", part.id); + LOG_CHECK(next_part_ == part.id) << tag("expected part.id", next_part_) << "!=" << tag("part.id", part.id); CHECK(!next_part_stop_); next_part_++; if (part.size % 16 != 0) { diff --git a/td/telegram/files/FileGenerateManager.cpp b/td/telegram/files/FileGenerateManager.cpp index dde24be1..d251a476 100644 --- a/td/telegram/files/FileGenerateManager.cpp +++ b/td/telegram/files/FileGenerateManager.cpp @@ -389,7 +389,7 @@ void FileGenerateManager::generate_file(uint64 query_id, FullGenerateFileLocatio CHECK(query_id != 0); auto it_flag = query_id_to_query_.insert(std::make_pair(query_id, Query{})); - CHECK(it_flag.second) << "Query id must be unique"; + LOG_CHECK(it_flag.second) << "Query id must be unique"; auto parent = actor_shared(this, query_id); Slice file_id_query = "#file_id#"; diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index e813316f..7d188e0a 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -455,7 +455,7 @@ class FullRemoteFileLocation { #define as_input_web_file_location() as_input_web_file_location_impl(__FILE__, __LINE__) tl_object_ptr as_input_web_file_location_impl(const char *file, int line) const { - CHECK(is_web()) << file << ' ' << line; + LOG_CHECK(is_web()) << file << ' ' << line; return make_tl_object(web().url_, web().access_hash_); } @@ -484,15 +484,15 @@ class FullRemoteFileLocation { #define as_input_document() as_input_document_impl(__FILE__, __LINE__) tl_object_ptr as_input_document_impl(const char *file, int line) const { - CHECK(is_common()) << file << ' ' << line; - CHECK(is_document()) << file << ' ' << line; + LOG_CHECK(is_common()) << file << ' ' << line; + LOG_CHECK(is_document()) << file << ' ' << line; return make_tl_object(common().id_, common().access_hash_, BufferSlice(FileReferenceView(file_reference_).upload())); } #define as_input_photo() as_input_photo_impl(__FILE__, __LINE__) tl_object_ptr as_input_photo_impl(const char *file, int line) const { - CHECK(is_photo()) << file << ' ' << line; + LOG_CHECK(is_photo()) << file << ' ' << line; return make_tl_object(photo().id_, photo().access_hash_, BufferSlice(FileReferenceView(file_reference_).upload())); } @@ -504,7 +504,7 @@ class FullRemoteFileLocation { #define as_input_secure_file() as_input_secure_file_impl(__FILE__, __LINE__) tl_object_ptr as_input_secure_file_impl(const char *file, int line) const { - CHECK(is_secure()) << file << ' ' << line; + LOG_CHECK(is_secure()) << file << ' ' << line; return make_tl_object(common().id_, common().access_hash_); } diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 67997d61..2a6cb148 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -761,7 +761,7 @@ Status FileManager::check_local_location(FileNodePtr node) { } FileManager::FileIdInfo *FileManager::get_file_id_info(FileId file_id) { - CHECK(0 <= file_id.get() && file_id.get() < static_cast(file_id_info_.size())) + LOG_CHECK(0 <= file_id.get() && file_id.get() < static_cast(file_id_info_.size())) << file_id << " " << file_id_info_.size(); return &file_id_info_[file_id.get()]; } @@ -1344,7 +1344,7 @@ Result FileManager::merge(FileId x_file_id, FileId y_file_id, bool no_sy for (auto file_id : other_node->file_ids_) { auto file_id_info = get_file_id_info(file_id); - CHECK(file_id_info->node_id_ == node_ids[other_node_i]) + LOG_CHECK(file_id_info->node_id_ == node_ids[other_node_i]) << node_ids[node_i] << " " << node_ids[other_node_i] << " " << file_id << " " << file_id_info->node_id_; file_id_info->node_id_ = node_ids[node_i]; send_updates_flag |= file_id_info->send_updates_flag_; diff --git a/td/telegram/files/PartsManager.cpp b/td/telegram/files/PartsManager.cpp index d389692c..c0e8dccf 100644 --- a/td/telegram/files/PartsManager.cpp +++ b/td/telegram/files/PartsManager.cpp @@ -90,7 +90,7 @@ Status PartsManager::init(int64 size, int64 expected_size, bool is_size_final, s if (size == 0) { return init_no_size(part_size, ready_parts); } - CHECK(size > 0) << tag("size", size); + LOG_CHECK(size > 0) << tag("size", size); unknown_size_flag_ = false; size_ = size; @@ -107,8 +107,8 @@ Status PartsManager::init(int64 size, int64 expected_size, bool is_size_final, s CHECK(part_size_ <= MAX_PART_SIZE); } } - CHECK(1 <= size_) << tag("size_", size_); - CHECK(!use_part_count_limit || calc_part_count(expected_size_, part_size_) <= MAX_PART_COUNT) + LOG_CHECK(1 <= size_) << tag("size_", size_); + LOG_CHECK(!use_part_count_limit || calc_part_count(expected_size_, part_size_) <= MAX_PART_COUNT) << tag("size_", size_) << tag("expected_size", size_) << tag("is_size_final", is_size_final) << tag("part_size_", part_size_) << tag("ready_parts", ready_parts.size()); part_count_ = static_cast(calc_part_count(size_, part_size_)); @@ -220,7 +220,7 @@ Status PartsManager::set_known_prefix(size_t size, bool is_ready) { } else { part_count_ = static_cast(size / part_size_); } - CHECK(static_cast(part_count_) >= part_status_.size()) + LOG_CHECK(static_cast(part_count_) >= part_status_.size()) << size << " " << is_ready << " " << part_count_ << " " << part_size_ << " " << part_status_.size(); part_status_.resize(part_count_); if (use_part_count_limit_ && calc_part_count(expected_size_, part_size_) > MAX_PART_COUNT) { @@ -323,7 +323,7 @@ void PartsManager::init_common(const std::vector &ready_parts) { part_status_ = vector(part_count_); for (auto i : ready_parts) { - CHECK(0 <= i && i < part_count_) << tag("i", i) << tag("part_count", part_count_); + LOG_CHECK(0 <= i && i < part_count_) << tag("i", i) << tag("part_count", part_count_); part_status_[i] = PartStatus::Ready; bitmask_.set(i); auto part = get_part(i); diff --git a/td/telegram/logevent/LogEvent.h b/td/telegram/logevent/LogEvent.h index a1d10f73..898004de 100644 --- a/td/telegram/logevent/LogEvent.h +++ b/td/telegram/logevent/LogEvent.h @@ -212,7 +212,7 @@ class LogEventParser : public WithVersion> { public: explicit LogEventParser(Slice data) : WithVersion>(data) { set_version(fetch_int()); - CHECK(version() < static_cast(Version::Next)) << "Wrong version " << version(); + LOG_CHECK(version() < static_cast(Version::Next)) << "Wrong version " << version(); set_context(G()); } }; diff --git a/td/telegram/net/ConnectionCreator.cpp b/td/telegram/net/ConnectionCreator.cpp index 8d026a88..55b0e2e7 100644 --- a/td/telegram/net/ConnectionCreator.cpp +++ b/td/telegram/net/ConnectionCreator.cpp @@ -212,7 +212,7 @@ void Proxy::parse(T &parser) { parse(port_, parser); parse(secret_, parser); } else { - CHECK(type_ == Proxy::Type::None) << static_cast(type_); + LOG_CHECK(type_ == Proxy::Type::None) << static_cast(type_); } } @@ -1230,7 +1230,7 @@ void ConnectionCreator::start_up() { proxy_last_used_date_[proxy_id] = last_used; proxy_last_used_saved_date_[proxy_id] = last_used; } else { - CHECK(!ends_with(info.first, "_max_id")) << info.first; + LOG_CHECK(!ends_with(info.first, "_max_id")) << info.first; int32 proxy_id = info.first == "proxy" ? 1 : to_integer_safe(Slice(info.first).substr(5)).move_as_ok(); CHECK(proxies_.count(proxy_id) == 0); log_event_parse(proxies_[proxy_id], info.second).ensure(); diff --git a/td/telegram/net/NetQueryCreator.cpp b/td/telegram/net/NetQueryCreator.cpp index 5e02685a..a17a5ae6 100644 --- a/td/telegram/net/NetQueryCreator.cpp +++ b/td/telegram/net/NetQueryCreator.cpp @@ -18,7 +18,7 @@ NetQueryCreator::Ptr NetQueryCreator::create(uint64 id, const Storer &storer, Dc double total_timeout_limit) { BufferSlice slice(storer.size()); auto real_size = storer.store(slice.as_slice().ubegin()); - CHECK(real_size == slice.size()) << real_size << " " << slice.size() << " " + LOG_CHECK(real_size == slice.size()) << real_size << " " << slice.size() << " " << format::as_hex_dump<4>(Slice(slice.as_slice())); // TODO: magic constant diff --git a/td/telegram/net/NetStatsManager.cpp b/td/telegram/net/NetStatsManager.cpp index 9a8198a3..88e5b504 100644 --- a/td/telegram/net/NetStatsManager.cpp +++ b/td/telegram/net/NetStatsManager.cpp @@ -43,7 +43,7 @@ static void parse(NetStatsData &net_stats, T &parser) { } void NetStatsManager::init() { - CHECK(!empty()) << G()->close_flag(); + LOG_CHECK(!empty()) << G()->close_flag(); class NetStatsInternalCallback : public NetStats::Callback { public: NetStatsInternalCallback(ActorId parent, size_t id) : parent_(std::move(parent)), id_(id) { diff --git a/td/telegram/net/PublicRsaKeyShared.cpp b/td/telegram/net/PublicRsaKeyShared.cpp index c811ed3d..7d26677e 100644 --- a/td/telegram/net/PublicRsaKeyShared.cpp +++ b/td/telegram/net/PublicRsaKeyShared.cpp @@ -20,7 +20,7 @@ PublicRsaKeyShared::PublicRsaKeyShared(DcId dc_id, bool is_test) : dc_id_(dc_id) } auto add_pem = [this](CSlice pem) { auto r_rsa = RSA::from_pem(pem); - CHECK(r_rsa.is_ok()) << r_rsa.error() << " " << pem; + LOG_CHECK(r_rsa.is_ok()) << r_rsa.error() << " " << pem; if (r_rsa.is_ok()) { this->add_rsa(r_rsa.move_as_ok()); diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index d22ffeda..c7711223 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -851,7 +851,7 @@ void Session::connection_send_query(ConnectionInfo *info, NetQueryPtr &&net_quer << tag("invoke_after", format::as_hex(invoke_after_id)); net_query->set_message_id(message_id); net_query->cancel_slot_.clear_event(); - CHECK(sent_queries_.find(message_id) == sent_queries_.end()) << message_id; + LOG_CHECK(sent_queries_.find(message_id) == sent_queries_.end()) << message_id; net_query->debug_unknown = false; net_query->debug_ack = 0; if (!net_query->cancel_slot_.empty()) { diff --git a/tdactor/td/actor/impl/Actor.h b/tdactor/td/actor/impl/Actor.h index b0c86185..18b3e25f 100644 --- a/tdactor/td/actor/impl/Actor.h +++ b/tdactor/td/actor/impl/Actor.h @@ -115,7 +115,7 @@ inline ActorId<> Actor::actor_id() { } template ActorId Actor::actor_id(SelfT *self) { - CHECK(static_cast(self) == this) + LOG_CHECK(static_cast(self) == this) << self << " " << static_cast(self) << " " << this << " " << empty(); return ActorId(info_.get_weak()); } @@ -125,7 +125,7 @@ inline ActorShared<> Actor::actor_shared() { } template ActorShared Actor::actor_shared(SelfT *self, uint64 id) { - CHECK(static_cast(self) == this) + LOG_CHECK(static_cast(self) == this) << self << " " << static_cast(self) << " " << this << " " << empty(); return ActorShared(actor_id(self), id); } diff --git a/tdactor/td/actor/impl/ActorInfo.h b/tdactor/td/actor/impl/ActorInfo.h index 4c510bad..0c4e91d5 100644 --- a/tdactor/td/actor/impl/ActorInfo.h +++ b/tdactor/td/actor/impl/ActorInfo.h @@ -169,7 +169,7 @@ inline CSlice ActorInfo::get_name() const { inline void ActorInfo::start_run() { VLOG(actor) << "start_run: " << *this; - CHECK(!is_running_) << "Recursive call of actor " << tag("name", get_name()); + LOG_CHECK(!is_running_) << "Recursive call of actor " << tag("name", get_name()); is_running_ = true; } inline void ActorInfo::finish_run() { diff --git a/tdactor/td/actor/impl/Scheduler-decl.h b/tdactor/td/actor/impl/Scheduler-decl.h index f8c86318..95798e11 100644 --- a/tdactor/td/actor/impl/Scheduler-decl.h +++ b/tdactor/td/actor/impl/Scheduler-decl.h @@ -5,7 +5,6 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #pragma once - #include "td/actor/impl/Actor-decl.h" #include "td/actor/impl/ActorId-decl.h" #include "td/actor/impl/EventFull-decl.h" diff --git a/tdactor/td/actor/impl/Scheduler.cpp b/tdactor/td/actor/impl/Scheduler.cpp index 3939b44e..b83c9c17 100644 --- a/tdactor/td/actor/impl/Scheduler.cpp +++ b/tdactor/td/actor/impl/Scheduler.cpp @@ -160,7 +160,7 @@ EventGuard::~EventGuard() { swap_context(info); CHECK(info->is_lite() || save_context_ == info->get_context()); #ifdef TD_DEBUG - CHECK(info->is_lite() || save_log_tag2_ == info->get_name().c_str()) + LOG_CHECK(info->is_lite() || save_log_tag2_ == info->get_name().c_str()) << info->is_lite() << " " << info->empty() << " " << info->is_migrating() << " " << save_log_tag2_ << " " << info->get_name() << " " << scheduler_->close_flag_; #endif @@ -307,8 +307,8 @@ void Scheduler::register_migrated_actor(ActorInfo *actor_info) { VLOG(actor) << "Register migrated actor: " << tag("name", *actor_info) << tag("ptr", actor_info) << tag("actor_count", actor_count_); actor_count_++; - CHECK(actor_info->is_migrating()) << *actor_info << " " << actor_count_ << " " << sched_id_ << " " - << actor_info->migrate_dest() << " " << actor_info->is_running() << close_flag_; + LOG_CHECK(actor_info->is_migrating()) << *actor_info << " " << actor_count_ << " " << sched_id_ << " " + << actor_info->migrate_dest() << " " << actor_info->is_running() << close_flag_; CHECK(sched_id_ == actor_info->migrate_dest()); // CHECK(!actor_info->is_running()); actor_info->finish_migrate(); @@ -358,7 +358,7 @@ void Scheduler::do_stop_actor(Actor *actor) { } void Scheduler::do_stop_actor(ActorInfo *actor_info) { CHECK(!actor_info->is_migrating()); - CHECK(actor_info->migrate_dest() == sched_id_) << actor_info->migrate_dest() << " " << sched_id_; + LOG_CHECK(actor_info->migrate_dest() == sched_id_) << actor_info->migrate_dest() << " " << sched_id_; ObjectPool::OwnerPtr owner_ptr; if (!actor_info->is_lite()) { EventGuard guard(this, actor_info); @@ -476,7 +476,7 @@ void Scheduler::run_mailbox() { //LOG(ERROR) << *actor_info; //cnt++; //} - //CHECK(cnt == actor_count_) << cnt << " vs " << actor_count_; + //LOG_CHECK(cnt == actor_count_) << cnt << " vs " << actor_count_; } Timestamp Scheduler::run_timeout() { diff --git a/tdactor/td/actor/impl/Scheduler.h b/tdactor/td/actor/impl/Scheduler.h index 3945444d..140cfbd6 100644 --- a/tdactor/td/actor/impl/Scheduler.h +++ b/tdactor/td/actor/impl/Scheduler.h @@ -104,7 +104,7 @@ ActorOwn Scheduler::register_actor_impl(Slice name, ActorT *actor_ptr, A #if TD_THREAD_UNSUPPORTED || TD_EVENTFD_UNSUPPORTED sched_id = 0; #endif - CHECK(sched_id == sched_id_ || (0 <= sched_id && sched_id < static_cast(outbound_queues_.size()))) << sched_id; + LOG_CHECK(sched_id == sched_id_ || (0 <= sched_id && sched_id < static_cast(outbound_queues_.size()))) << sched_id; auto info = actor_info_pool_->create_empty(); VLOG(actor) << "Create actor: " << tag("name", name) << tag("ptr", *info) << tag("context", context()) << tag("this", this) << tag("actor_count", actor_count_); @@ -140,7 +140,7 @@ inline void Scheduler::destroy_actor(ActorInfo *actor_info) { VLOG(actor) << "Destroy actor: " << tag("name", *actor_info) << tag("ptr", actor_info) << tag("actor_count", actor_count_); - CHECK(actor_info->migrate_dest() == sched_id_) << actor_info->migrate_dest() << " " << sched_id_; + LOG_CHECK(actor_info->migrate_dest() == sched_id_) << actor_info->migrate_dest() << " " << sched_id_; cancel_actor_timeout(actor_info); actor_info->get_list_node()->remove(); // called by ObjectPool diff --git a/tdactor/test/actors_main.cpp b/tdactor/test/actors_main.cpp index 7de744d3..f75727c0 100644 --- a/tdactor/test/actors_main.cpp +++ b/tdactor/test/actors_main.cpp @@ -58,7 +58,7 @@ struct Query { Query(Query &&) = default; Query &operator=(Query &&) = default; ~Query() { - CHECK(todo.empty()) << "Query lost"; + LOG_CHECK(todo.empty()) << "Query lost"; } int next_pow() { CHECK(!todo.empty()); diff --git a/tdactor/test/actors_simple.cpp b/tdactor/test/actors_simple.cpp index 8ecee96c..15994891 100644 --- a/tdactor/test/actors_simple.cpp +++ b/tdactor/test/actors_simple.cpp @@ -289,7 +289,7 @@ class OpenClose final : public Actor { ObserverBase *observer = reinterpret_cast(123); if (cnt_ > 0) { auto r_file_fd = FileFd::open("server", FileFd::Read | FileFd::Create); - CHECK(r_file_fd.is_ok()) << r_file_fd.error(); + LOG_CHECK(r_file_fd.is_ok()) << r_file_fd.error(); auto file_fd = r_file_fd.move_as_ok(); { PollableFd pollable_fd = file_fd.get_poll_info().extract_pollable_fd(observer); } file_fd.close(); diff --git a/tddb/td/db/SqliteDb.cpp b/tddb/td/db/SqliteDb.cpp index 60ef1704..e777679b 100644 --- a/tddb/td/db/SqliteDb.cpp +++ b/tddb/td/db/SqliteDb.cpp @@ -208,7 +208,7 @@ Status SqliteDb::change_key(CSlice path, const DbKey &new_db_key, const DbKey &o } TRY_RESULT(new_db, open_with_key(path, new_db_key)); - CHECK(new_db.user_version().ok() == user_version) << new_db.user_version().ok() << " " << user_version; + LOG_CHECK(new_db.user_version().ok() == user_version) << new_db.user_version().ok() << " " << user_version; return Status::OK(); } Status SqliteDb::destroy(Slice path) { @@ -221,7 +221,7 @@ Result SqliteDb::get_statement(CSlice statement) { if (rc != SQLITE_OK) { return Status::Error(PSLICE() << "Failed to prepare SQLite " << tag("statement", statement) << raw_->last_error()); } - CHECK(stmt != nullptr) << statement; + LOG_CHECK(stmt != nullptr) << statement; return SqliteStatement(stmt, raw_); } diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index 7ae798ac..be277f2e 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -547,7 +547,7 @@ Status Binlog::load_binlog(const Callback &callback, const Callback &debug_callb fd_.truncate_to_current_position(offset).ensure(); db_key_used_ = false; // force reindex } - CHECK(IGNORE_ERASE_HACK || fd_size_ == offset) << fd_size << " " << fd_size_ << " " << offset; + LOG_CHECK(IGNORE_ERASE_HACK || fd_size_ == offset) << fd_size << " " << fd_size_ << " " << offset; binlog_reader_ptr_ = nullptr; state_ = State::Run; @@ -651,7 +651,7 @@ void Binlog::do_reindex() { auto finish_time = Clocks::monotonic(); auto finish_size = fd_size_; auto finish_events = fd_events_; - CHECK(fd_size_ == detail::file_size(path_)) + LOG_CHECK(fd_size_ == detail::file_size(path_)) << fd_size_ << ' ' << detail::file_size(path_) << ' ' << fd_events_ << ' ' << path_; double ratio = static_cast(start_size) / static_cast(finish_size + 1); diff --git a/tddb/td/db/binlog/BinlogEvent.cpp b/tddb/td/db/binlog/BinlogEvent.cpp index ac63519d..5336870d 100644 --- a/tddb/td/db/binlog/BinlogEvent.cpp +++ b/tddb/td/db/binlog/BinlogEvent.cpp @@ -18,7 +18,7 @@ int32 VERBOSITY_NAME(binlog) = VERBOSITY_NAME(DEBUG) + 8; Status BinlogEvent::init(BufferSlice &&raw_event, bool check_crc) { TlParser parser(raw_event.as_slice()); size_ = parser.fetch_int(); - CHECK(size_ == raw_event.size()) << size_ << " " << raw_event.size() << debug_info_; + LOG_CHECK(size_ == raw_event.size()) << size_ << " " << raw_event.size() << debug_info_; id_ = parser.fetch_long(); type_ = parser.fetch_int(); flags_ = parser.fetch_int(); diff --git a/tddb/td/db/binlog/detail/BinlogEventsProcessor.h b/tddb/td/db/binlog/detail/BinlogEventsProcessor.h index c1d25f11..0b74e974 100644 --- a/tddb/td/db/binlog/detail/BinlogEventsProcessor.h +++ b/tddb/td/db/binlog/detail/BinlogEventsProcessor.h @@ -23,7 +23,7 @@ class BinlogEventsProcessor { template void for_each(CallbackT &&callback) { for (size_t i = 0; i < ids_.size(); i++) { - CHECK(i == 0 || ids_[i - 1] < ids_[i]) << ids_[i - 1] << " " << events_[i - 1].public_to_string() << " " + LOG_CHECK(i == 0 || ids_[i - 1] < ids_[i]) << ids_[i - 1] << " " << events_[i - 1].public_to_string() << " " << ids_[i] << " " << events_[i].public_to_string(); if ((ids_[i] & 1) == 0) { callback(events_[i]); diff --git a/tdutils/td/utils/BufferedUdp.h b/tdutils/td/utils/BufferedUdp.h index eeaef274..4c7df9a4 100644 --- a/tdutils/td/utils/BufferedUdp.h +++ b/tdutils/td/utils/BufferedUdp.h @@ -87,7 +87,7 @@ class UdpReader { helpers_[i].init_inbound_message(messages_[i]); } for (size_t i = cnt; i < messages_.size(); i++) { - CHECK(messages_[i].data.size() == 2048) + LOG_CHECK(messages_[i].data.size() == 2048) << " cnt = " << cnt << " i = " << i << " size = " << messages_[i].data.size() << " status = " << status; } if (status.is_error() && !UdpSocketFd::is_critical_read_error(status)) { diff --git a/tdutils/td/utils/Heap.h b/tdutils/td/utils/Heap.h index ee13416f..a7595ccf 100644 --- a/tdutils/td/utils/Heap.h +++ b/tdutils/td/utils/Heap.h @@ -81,7 +81,7 @@ class KHeap { void check() const { for (size_t i = 0; i < array_.size(); i++) { for (size_t j = i * K + 1; j < i * K + 1 + K && j < array_.size(); j++) { - CHECK(array_[i].key_ <= array_[j].key_) << i << " " << j; + LOG_CHECK(array_[i].key_ <= array_[j].key_) << i << " " << j; } } } diff --git a/tdutils/td/utils/ObjectPool.h b/tdutils/td/utils/ObjectPool.h index 441268e7..05b22362 100644 --- a/tdutils/td/utils/ObjectPool.h +++ b/tdutils/td/utils/ObjectPool.h @@ -189,7 +189,7 @@ class ObjectPool { delete to_delete; storage_count_--; } - CHECK(storage_count_.load() == 0) << storage_count_.load(); + LOG_CHECK(storage_count_.load() == 0) << storage_count_.load(); } private: diff --git a/tdutils/td/utils/OrderedEventsProcessor.h b/tdutils/td/utils/OrderedEventsProcessor.h index 34a6837f..e5648603 100644 --- a/tdutils/td/utils/OrderedEventsProcessor.h +++ b/tdutils/td/utils/OrderedEventsProcessor.h @@ -37,7 +37,7 @@ class OrderedEventsProcessor { } template void add(SeqNo seq_no, FromDataT &&data, FunctionT &&function) { - CHECK(seq_no >= begin_) << seq_no << ">=" << begin_; // or ignore? + LOG_CHECK(seq_no >= begin_) << seq_no << ">=" << begin_; // or ignore? if (seq_no == begin_) { // run now begin_++; diff --git a/tdutils/td/utils/SharedObjectPool.h b/tdutils/td/utils/SharedObjectPool.h index ebe0e90f..9bd4800e 100644 --- a/tdutils/td/utils/SharedObjectPool.h +++ b/tdutils/td/utils/SharedObjectPool.h @@ -192,7 +192,7 @@ class SharedObjectPool { while (free_queue_reader_.read()) { free_cnt++; } - CHECK(free_cnt == allocated_.size()) << free_cnt << " " << allocated_.size(); + LOG_CHECK(free_cnt == allocated_.size()) << free_cnt << " " << allocated_.size(); } template diff --git a/tdutils/td/utils/Status.h b/tdutils/td/utils/Status.h index 1bbddc27..b4bdd11e 100644 --- a/tdutils/td/utils/Status.h +++ b/tdutils/td/utils/Status.h @@ -404,19 +404,19 @@ class Result { return std::move(status_); } const T &ok() const { - CHECK(status_.is_ok()) << status_; + LOG_CHECK(status_.is_ok()) << status_; return value_; } T &ok_ref() { - CHECK(status_.is_ok()) << status_; + LOG_CHECK(status_.is_ok()) << status_; return value_; } const T &ok_ref() const { - CHECK(status_.is_ok()) << status_; + LOG_CHECK(status_.is_ok()) << status_; return value_; } T move_as_ok() { - CHECK(status_.is_ok()) << status_; + LOG_CHECK(status_.is_ok()) << status_; return std::move(value_); } diff --git a/tdutils/td/utils/TimedStat.h b/tdutils/td/utils/TimedStat.h index 9088626c..0f9efbca 100644 --- a/tdutils/td/utils/TimedStat.h +++ b/tdutils/td/utils/TimedStat.h @@ -48,7 +48,7 @@ class TimedStat { void update(double &now) { if (now < next_timestamp_) { - // CHECK(now >= next_timestamp_ * (1 - 1e-14)) << now << " " << next_timestamp_; + // LOG_CHECK(now >= next_timestamp_ * (1 - 1e-14)) << now << " " << next_timestamp_; now = next_timestamp_; } if (duration_ == 0) { diff --git a/tdutils/td/utils/Variant.h b/tdutils/td/utils/Variant.h index 53408a6b..5a6efa7a 100644 --- a/tdutils/td/utils/Variant.h +++ b/tdutils/td/utils/Variant.h @@ -170,7 +170,7 @@ class Variant { template void init_empty(T &&t) { - CHECK(offset_ == npos) << offset_ + LOG_CHECK(offset_ == npos) << offset_ #if TD_CLANG || TD_GCC << ' ' << __PRETTY_FUNCTION__ #endif diff --git a/tdutils/td/utils/buffer.h b/tdutils/td/utils/buffer.h index 0d81538e..87899389 100644 --- a/tdutils/td/utils/buffer.h +++ b/tdutils/td/utils/buffer.h @@ -602,7 +602,7 @@ class ChainBufferReader { } ChainBufferReader cut_head(size_t offset) TD_WARN_UNUSED_RESULT { - CHECK(offset <= size()) << offset << " " << size(); + LOG_CHECK(offset <= size()) << offset << " " << size(); auto it = begin_.clone(); it.advance(offset); return cut_head(std::move(it)); diff --git a/tdutils/td/utils/misc.h b/tdutils/td/utils/misc.h index 2e744b75..77b350e3 100644 --- a/tdutils/td/utils/misc.h +++ b/tdutils/td/utils/misc.h @@ -339,8 +339,8 @@ class NarrowCast { static_assert(std::is_integral::value, "expected integral type to cast from"); auto r = R(a); - CHECK(A(r) == a) << static_cast(a) << " " << static_cast(r) << " " << file_ << " " << line_; - CHECK((is_same_signedness::value) || ((static_cast(r) < RT{}) == (static_cast(a) < AT{}))) + LOG_CHECK(A(r) == a) << static_cast(a) << " " << static_cast(r) << " " << file_ << " " << line_; + LOG_CHECK((is_same_signedness::value) || ((static_cast(r) < RT{}) == (static_cast(a) < AT{}))) << static_cast(a) << " " << static_cast(r) << " " << file_ << " " << line_; return r; diff --git a/tdutils/td/utils/port/detail/Iocp.cpp b/tdutils/td/utils/port/detail/Iocp.cpp index 463b7e86..17171c52 100644 --- a/tdutils/td/utils/port/detail/Iocp.cpp +++ b/tdutils/td/utils/port/detail/Iocp.cpp @@ -73,7 +73,7 @@ void Iocp::subscribe(const NativeFd &native_fd, Callback *callback) { auto error = OS_ERROR("CreateIoCompletionPort"); LOG(FATAL) << error; } - CHECK(iocp_handle == iocp_handle_.fd()) << iocp_handle << " " << iocp_handle_.fd(); + LOG_CHECK(iocp_handle == iocp_handle_.fd()) << iocp_handle << " " << iocp_handle_.fd(); } void Iocp::post(size_t size, Callback *callback, WSAOVERLAPPED *overlapped) { diff --git a/tdutils/td/utils/port/detail/Select.cpp b/tdutils/td/utils/port/detail/Select.cpp index 46a6d285..db9fe84e 100644 --- a/tdutils/td/utils/port/detail/Select.cpp +++ b/tdutils/td/utils/port/detail/Select.cpp @@ -35,7 +35,7 @@ void Select::subscribe(PollableFd fd, PollFlags flags) { CHECK(it.fd.native_fd().fd() != native_fd); } fds_.push_back(FdInfo{std::move(fd), flags}); - CHECK(0 <= native_fd && native_fd < FD_SETSIZE) << native_fd << " " << FD_SETSIZE; + LOG_CHECK(0 <= native_fd && native_fd < FD_SETSIZE) << native_fd << " " << FD_SETSIZE; FD_SET(native_fd, &all_fd_); if (native_fd > max_fd_) { max_fd_ = native_fd; @@ -47,7 +47,7 @@ void Select::unsubscribe(PollableFdRef fd) { int native_fd = fd_locked.native_fd().fd(); fd_locked.release_as_list_node(); - CHECK(0 <= native_fd && native_fd < FD_SETSIZE) << native_fd << " " << FD_SETSIZE; + LOG_CHECK(0 <= native_fd && native_fd < FD_SETSIZE) << native_fd << " " << FD_SETSIZE; FD_CLR(native_fd, &all_fd_); FD_CLR(native_fd, &read_fd_); FD_CLR(native_fd, &write_fd_); diff --git a/tdutils/td/utils/tests.h b/tdutils/td/utils/tests.h index 2bb8ed80..36c7962d 100644 --- a/tdutils/td/utils/tests.h +++ b/tdutils/td/utils/tests.h @@ -136,12 +136,12 @@ inline vector rand_split(string str) { template void assert_eq_impl(const T1 &expected, const T2 &got, const char *file, int line) { - CHECK(expected == got) << tag("expected", expected) << tag("got", got) << " in " << file << " at line " << line; + LOG_CHECK(expected == got) << tag("expected", expected) << tag("got", got) << " in " << file << " at line " << line; } template void assert_true_impl(const T &got, const char *file, int line) { - CHECK(got) << "Expected true in " << file << " at line " << line; + LOG_CHECK(got) << "Expected true in " << file << " at line " << line; } } // namespace td diff --git a/tdutils/td/utils/tl_helpers.h b/tdutils/td/utils/tl_helpers.h index f59a1469..bd075d83 100644 --- a/tdutils/td/utils/tl_helpers.h +++ b/tdutils/td/utils/tl_helpers.h @@ -45,15 +45,15 @@ #define END_PARSE_FLAGS() \ CHECK(bit_offset_parse < 31); \ - CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) \ + LOG_CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) \ << flags_parse << " " << bit_offset_parse << " " << parser.version(); \ } \ while (false) -#define END_PARSE_FLAGS_GENERIC() \ - CHECK(bit_offset_parse < 31); \ - CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) << flags_parse << " " << bit_offset_parse; \ - } \ +#define END_PARSE_FLAGS_GENERIC() \ + CHECK(bit_offset_parse < 31); \ + LOG_CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) << flags_parse << " " << bit_offset_parse; \ + } \ while (false) namespace td { diff --git a/tdutils/td/utils/tl_parsers.cpp b/tdutils/td/utils/tl_parsers.cpp index abd46eab..b4e6c86f 100644 --- a/tdutils/td/utils/tl_parsers.cpp +++ b/tdutils/td/utils/tl_parsers.cpp @@ -21,7 +21,7 @@ void TlParser::set_error(const string &error_message) { } else { data = empty_data; CHECK(error_pos != std::numeric_limits::max()); - CHECK(data_len == 0) << data_len << " " << left_len << " " << data << " " << &empty_data[0] << " " << error_pos + LOG_CHECK(data_len == 0) << data_len << " " << left_len << " " << data << " " << &empty_data[0] << " " << error_pos << " " << error; CHECK(left_len == 0); } diff --git a/tdutils/test/MpmcQueue.cpp b/tdutils/test/MpmcQueue.cpp index 090cbb9c..6bafd149 100644 --- a/tdutils/test/MpmcQueue.cpp +++ b/tdutils/test/MpmcQueue.cpp @@ -68,7 +68,7 @@ TEST(OneValue, stress) { if (set_status) { CHECK(get_status); CHECK(from.empty()); - CHECK(to == "hello") << to; + LOG_CHECK(to == "hello") << to; } else { CHECK(!get_status); CHECK(from == "hello"); @@ -122,7 +122,7 @@ TEST(MpmcQueue, simple) { } for (int i = 0; i < 100; i++) { int x = q.pop(0); - CHECK(x == i) << x << " expected " << i; + LOG_CHECK(x == i) << x << " expected " << i; } } } @@ -189,7 +189,7 @@ TEST(MpmcQueue, multi_thread) { from[data.from] = data.value; } } - CHECK(all.size() == n * qn) << all.size(); + LOG_CHECK(all.size() == n * qn) << all.size(); std::sort(all.begin(), all.end(), [](const auto &a, const auto &b) { return std::tie(a.from, a.value) < std::tie(b.from, b.value); }); for (size_t i = 0; i < n * qn; i++) { @@ -201,6 +201,6 @@ TEST(MpmcQueue, multi_thread) { for (size_t id = 0; id < n + m + 1; id++) { q.gc(id); } - CHECK(q.hazard_pointers_to_delele_size_unsafe() == 0) << q.hazard_pointers_to_delele_size_unsafe(); + LOG_CHECK(q.hazard_pointers_to_delele_size_unsafe() == 0) << q.hazard_pointers_to_delele_size_unsafe(); } #endif //!TD_THREAD_UNSUPPORTED diff --git a/tdutils/test/MpscLinkQueue.cpp b/tdutils/test/MpscLinkQueue.cpp index 2576da6e..5a74ed81 100644 --- a/tdutils/test/MpscLinkQueue.cpp +++ b/tdutils/test/MpscLinkQueue.cpp @@ -48,7 +48,7 @@ TEST(MpscLinkQueue, one_thread) { while (auto node = reader.read()) { v.push_back(node.value().value()); } - CHECK((v == std::vector{1, 2, 3, 4})) << td::format::as_array(v); + LOG_CHECK((v == std::vector{1, 2, 3, 4})) << td::format::as_array(v); v.clear(); queue.push(create_node(5)); @@ -56,7 +56,7 @@ TEST(MpscLinkQueue, one_thread) { while (auto node = reader.read()) { v.push_back(node.value().value()); } - CHECK((v == std::vector{5})) << td::format::as_array(v); + LOG_CHECK((v == std::vector{5})) << td::format::as_array(v); } { @@ -70,7 +70,7 @@ TEST(MpscLinkQueue, one_thread) { while (auto node = reader.read()) { v.push_back(node.value().value()); } - CHECK((v == std::vector{3, 2, 1, 0})) << td::format::as_array(v); + LOG_CHECK((v == std::vector{3, 2, 1, 0})) << td::format::as_array(v); } } diff --git a/tdutils/test/pq.cpp b/tdutils/test/pq.cpp index db5f89fb..4b275eea 100644 --- a/tdutils/test/pq.cpp +++ b/tdutils/test/pq.cpp @@ -80,13 +80,13 @@ static void test_pq(uint64 first, uint64 second) { std::string p_str, q_str; int err = td::pq_factorize(pq_str, &p_str, &q_str); - CHECK(err == 0) << first << " * " << second; + LOG_CHECK(err == 0) << first << " * " << second; BigNum p_res = BigNum::from_binary(p_str); BigNum q_res = BigNum::from_binary(q_str); - CHECK(p_str == p.to_binary()) << td::tag("got", p_res.to_decimal()) << td::tag("expected", first); - CHECK(q_str == q.to_binary()) << td::tag("got", q_res.to_decimal()) << td::tag("expected", second); + LOG_CHECK(p_str == p.to_binary()) << td::tag("got", p_res.to_decimal()) << td::tag("expected", first); + LOG_CHECK(q_str == q.to_binary()) << td::tag("got", q_res.to_decimal()) << td::tag("expected", second); } #endif diff --git a/test/secret.cpp b/test/secret.cpp index bb5584d2..3a8e3827 100644 --- a/test/secret.cpp +++ b/test/secret.cpp @@ -203,7 +203,7 @@ static void downcast_call(TlBufferParser &p, F &&f) { case messages_sendEncryptedService::ID: return f(*make_tl_object(p)); default: - CHECK(0) << id; + LOG_CHECK(0) << id; UNREACHABLE(); } } diff --git a/test/tdclient.cpp b/test/tdclient.cpp index b3d18075..3d5e0cab 100644 --- a/test/tdclient.cpp +++ b/test/tdclient.cpp @@ -38,7 +38,7 @@ namespace td { template static void check_td_error(T &result) { - CHECK(result->get_id() != td_api::error::ID) << to_string(result); + LOG_CHECK(result->get_id() != td_api::error::ID) << to_string(result); } class TestClient : public Actor { @@ -235,9 +235,9 @@ class DoAuthentication : public Task { on_authorization_ready(); return; default: - CHECK(false) << "Unexpected authorization state " << to_string(authorization_state); + LOG_CHECK(false) << "Unexpected authorization state " << to_string(authorization_state); } - send_query(std::move(function), [](auto res) { CHECK(res->get_id() == td_api::ok::ID) << to_string(res); }); + send_query(std::move(function), [](auto res) { LOG_CHECK(res->get_id() == td_api::ok::ID) << to_string(res); }); } void on_authorization_ready() { LOG(INFO) << "GOT AUTHORIZED"; @@ -345,7 +345,7 @@ class CheckTestA : public Task { auto messageText = move_tl_object_as(message->content_); auto text = messageText->text_->text_; if (text.substr(0, tag_.size()) == tag_) { - CHECK(text > previous_text_) << tag("now", text) << tag("previous", previous_text_); + LOG_CHECK(text > previous_text_) << tag("now", text) << tag("previous", previous_text_); previous_text_ = text; cnt_--; LOG(INFO) << "GOT " << tag("text", text) << tag("left", cnt_);