Add logging for a CHECK.

GitOrigin-RevId: dadde241811ab890935ba24c7b3af937393d1185
This commit is contained in:
levlam 2019-03-20 05:57:36 +03:00
parent f8162c04e2
commit c09d5dfbc2
3 changed files with 28 additions and 1 deletions

View File

@ -652,7 +652,9 @@ void NotificationManager::try_reuse_notification_group_id(NotificationGroupId gr
auto group_it = get_group(group_id);
if (group_it != groups_.end()) {
CHECK(group_it->first.last_notification_date == 0);
CHECK(group_it->second.total_count == 0);
LOG_CHECK(group_it->second.total_count == 0)
<< running_get_difference_ << " " << pending_notification_update_count_ << " "
<< pending_updates_[group_id.get()].size() << " " << group_it->first << " " << group_it->second;
CHECK(group_it->second.notifications.empty());
CHECK(group_it->second.pending_notifications.empty());
CHECK(!group_it->second.is_being_loaded_from_database);

View File

@ -25,6 +25,7 @@
#include "td/utils/logging.h"
#include "td/utils/Status.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/Time.h"
#include <functional>
#include <map>
@ -140,6 +141,13 @@ class NotificationManager : public Actor {
bool is_silent = false;
NotificationId notification_id;
unique_ptr<NotificationType> type;
friend StringBuilder &operator<<(StringBuilder &string_builder, const PendingNotification &pending_notification) {
return string_builder << "PendingNotification[" << pending_notification.notification_id << " of type "
<< pending_notification.type << " sent at " << pending_notification.date
<< " with settings from " << pending_notification.settings_dialog_id
<< ", is_silent = " << pending_notification.is_silent << "]";
}
};
struct NotificationGroup {
@ -152,6 +160,16 @@ class NotificationManager : public Actor {
double pending_notifications_flush_time = 0;
vector<PendingNotification> pending_notifications;
friend StringBuilder &operator<<(StringBuilder &string_builder, const NotificationGroup &notification_group) {
return string_builder << "NotificationGroup[" << notification_group.type << " with total "
<< notification_group.total_count << " notifications " << notification_group.notifications
<< " + " << notification_group.pending_notifications
<< ", is_loaded_from_database = " << notification_group.is_loaded_from_database
<< ", is_being_loaded_from_database = " << notification_group.is_being_loaded_from_database
<< ", pending_notifications_flush_time = "
<< notification_group.pending_notifications_flush_time << ", now = " << Time::now() << "]";
}
};
enum class SyncState : int32 { NotSynced, Pending, Completed };

View File

@ -46,6 +46,13 @@ inline StringBuilder &operator<<(StringBuilder &string_builder, const Notificati
return notification_type.to_string_builder(string_builder);
}
inline StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr<NotificationType> &notification_type) {
if (notification_type == nullptr) {
return string_builder << "null";
}
return string_builder << *notification_type;
}
unique_ptr<NotificationType> create_new_message_notification(MessageId message_id);
unique_ptr<NotificationType> create_new_secret_chat_notification();