From c6f96c617b83a24f421f5bbd178ce4f6cfa0ee28 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 16 Mar 2019 16:24:39 +0300 Subject: [PATCH] Improve debug logging. GitOrigin-RevId: 08507bf19e76bf2cd1d4692c6d4941a042624ec7 --- td/telegram/MessagesManager.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index a65c8e28..7b043c71 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -8488,7 +8488,8 @@ void MessagesManager::set_dialog_last_read_inbox_message_id(Dialog *d, MessageId } total_count -= static_cast(d->pending_new_message_notifications.size()); if (total_count < 0) { - LOG(ERROR) << "Total message notification count is negative in " << d->dialog_id; + LOG(ERROR) << "Total message notification count is " << total_count << " in " << d->dialog_id << " with " + << d->pending_new_message_notifications.size() << " pending new message notifications"; total_count = 0; } send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification_group, @@ -18205,10 +18206,12 @@ MessagesManager::MessageNotificationGroup MessagesManager::get_message_notificat << " unread messages"; result.dialog_id = d->dialog_id; result.total_count = get_dialog_pending_notification_count(d, from_mentions); - result.total_count -= static_cast(from_mentions ? d->pending_new_mention_notifications.size() - : d->pending_new_message_notifications.size()); + auto pending_notification_count = + from_mentions ? d->pending_new_mention_notifications.size() : d->pending_new_message_notifications.size(); + result.total_count -= static_cast(pending_notification_count); if (result.total_count < 0) { - LOG(ERROR) << "Total notification count is negative in " << d->dialog_id; + LOG(ERROR) << "Total notification count is " << result.total_count << " in " << d->dialog_id << " with " + << pending_notification_count << " pending new notifications"; result.total_count = 0; } if (d->new_secret_chat_notification_id.is_valid()) { @@ -18691,7 +18694,8 @@ void MessagesManager::update_dialog_mention_notification_count(const Dialog *d) auto total_count = get_dialog_pending_notification_count(d, true) - static_cast(d->pending_new_mention_notifications.size()); if (total_count < 0) { - LOG(ERROR) << "Total mention notification count is negative in " << d->dialog_id; + LOG(ERROR) << "Total mention notification count is " << total_count << " in " << d->dialog_id << " with " + << d->pending_new_mention_notifications << " pending new mention notifications"; total_count = 0; } send_closure_later(G()->notification_manager(), &NotificationManager::set_notification_total_count,