Add VLOG get_difference.

GitOrigin-RevId: afd6834f83c455d613949b59f65a3ef0ffed8cf4
This commit is contained in:
levlam 2018-11-15 20:25:54 +03:00
parent ca4c1acc90
commit 6fc90bb699
4 changed files with 24 additions and 17 deletions

View File

@ -3450,7 +3450,7 @@ setLogVerbosityLevel new_verbosity_level:int32 = Ok;
//@description Returns current verbosity level of the internal logging of TDLib. This is an offline method. Can be called before authorization. Can be called synchronously
getLogVerbosityLevel = LogVerbosityLevel;
//@description Returns list of available TDLib internal log tags. Currently returns ["td_init", "update_file", "connections", "binlog", "proxy", "net_query", "td_requests", "dc", "files", "mtproto", "raw_mtproto", "fd", "actor", "buffer", "sqlite", "notifications"]
//@description Returns list of available TDLib internal log tags, for example, ["actor", "binlog", "connections", "notifications", "proxy"]
getLogTags = LogTags;
//@description Sets the verbosity level for a specified TDLib internal log tag. This is an offline method. Can be called before authorization. Can be called synchronously

View File

@ -10,6 +10,7 @@
#include "td/telegram/net/ConnectionCreator.h"
#include "td/telegram/NotificationManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/UpdatesManager.h"
#include "tddb/td/db/binlog/BinlogEvent.h"
@ -31,11 +32,12 @@ static NullLog null_log;
#define ADD_TAG(tag) \
{ #tag, &VERBOSITY_NAME(tag) }
static const std::unordered_map<Slice, int *, SliceHash> log_tags{
static const std::map<Slice, int *> log_tags{
ADD_TAG(td_init), ADD_TAG(update_file), ADD_TAG(connections), ADD_TAG(binlog),
ADD_TAG(proxy), ADD_TAG(net_query), ADD_TAG(td_requests), ADD_TAG(dc),
ADD_TAG(files), ADD_TAG(mtproto), ADD_TAG(raw_mtproto), ADD_TAG(fd),
ADD_TAG(actor), ADD_TAG(buffer), ADD_TAG(sqlite), ADD_TAG(notifications)};
ADD_TAG(actor), ADD_TAG(buffer), ADD_TAG(sqlite), ADD_TAG(notifications),
ADD_TAG(get_difference)};
#undef ADD_TAG
Status Logging::set_current_stream(td_api::object_ptr<td_api::LogStream> stream) {

View File

@ -47,6 +47,8 @@
namespace td {
int VERBOSITY_NAME(get_difference) = VERBOSITY_NAME(INFO);
class OnUpdate {
UpdatesManager *manager_;
tl_object_ptr<telegram_api::Update> &update_;
@ -126,7 +128,7 @@ class GetDifferenceQuery : public Td::ResultHandler {
pts = 0;
}
LOG(INFO) << tag("pts", pts) << tag("qts", qts) << tag("date", date);
VLOG(get_difference) << tag("pts", pts) << tag("qts", qts) << tag("date", date);
send_query(
G()->net_query_creator().create(create_storer(telegram_api::updates_getDifference(0, pts, 0, date, qts))));
@ -238,12 +240,12 @@ void UpdatesManager::get_difference(const char *source) {
}
if (running_get_difference_) {
LOG(INFO) << "Skip running getDifference from " << source << " because it is already running";
VLOG(get_difference) << "Skip running getDifference from " << source << " because it is already running";
return;
}
running_get_difference_ = true;
LOG(INFO) << "-----BEGIN GET DIFFERENCE----- from " << source;
VLOG(get_difference) << "-----BEGIN GET DIFFERENCE----- from " << source;
before_get_difference();
@ -730,7 +732,7 @@ void UpdatesManager::on_failed_get_difference() {
}
void UpdatesManager::schedule_get_difference(const char *source) {
LOG(INFO) << "Schedule getDifference from " << source;
VLOG(get_difference) << "Schedule getDifference from " << source;
if (!retry_timeout_.has_timeout()) {
retry_timeout_.set_callback(std::move(fill_get_difference_gap));
retry_timeout_.set_callback_data(static_cast<void *>(td_));
@ -748,7 +750,7 @@ void UpdatesManager::on_get_updates_state(tl_object_ptr<telegram_api::updates_st
on_failed_get_difference();
return;
}
LOG(INFO) << "Receive " << oneline(to_string(state)) << " from " << source;
VLOG(get_difference) << "Receive " << oneline(to_string(state)) << " from " << source;
// TODO use state->unread_count;
if (get_pts() == std::numeric_limits<int32>::max()) {
@ -929,8 +931,9 @@ void UpdatesManager::process_get_difference_updates(
vector<tl_object_ptr<telegram_api::Message>> &&new_messages,
vector<tl_object_ptr<telegram_api::EncryptedMessage>> &&new_encrypted_messages, int32 qts,
vector<tl_object_ptr<telegram_api::Update>> &&other_updates) {
LOG(INFO) << "In get difference receive " << new_messages.size() << " messages, " << new_encrypted_messages.size()
<< " encrypted messages and " << other_updates.size() << " other updates";
VLOG(get_difference) << "In get difference receive " << new_messages.size() << " messages, "
<< new_encrypted_messages.size() << " encrypted messages and " << other_updates.size()
<< " other updates";
for (auto &update : other_updates) {
auto constructor_id = update->get_id();
if (constructor_id == telegram_api::updateMessageID::ID) {
@ -968,7 +971,7 @@ void UpdatesManager::process_get_difference_updates(
}
void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Difference> &&difference_ptr) {
LOG(INFO) << "----- END GET DIFFERENCE-----";
VLOG(get_difference) << "----- END GET DIFFERENCE-----";
running_get_difference_ = false;
if (difference_ptr == nullptr) {
@ -1054,7 +1057,7 @@ void UpdatesManager::after_get_difference() {
}
if (postponed_updates_.size()) {
LOG(INFO) << "Begin to apply postponed updates";
VLOG(get_difference) << "Begin to apply postponed updates";
while (!postponed_updates_.empty()) {
auto it = postponed_updates_.begin();
auto updates = std::move(it->second.updates);
@ -1064,11 +1067,11 @@ void UpdatesManager::after_get_difference() {
postponed_updates_.erase(it);
on_pending_updates(std::move(updates), updates_seq_begin, updates_seq_end, 0, "postponed updates");
if (running_get_difference_) {
LOG(INFO) << "Finish to apply postponed updates because forced to run getDifference";
VLOG(get_difference) << "Finish to apply postponed updates because forced to run getDifference";
return;
}
}
LOG(INFO) << "Finish to apply postponed updates";
VLOG(get_difference) << "Finish to apply postponed updates";
}
state_ = saved_state;

View File

@ -23,6 +23,8 @@
namespace td {
extern int VERBOSITY_NAME(get_difference);
class Td;
class UpdatesManager : public Actor {