diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 638fe5dec..a89498338 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -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 diff --git a/td/telegram/Logging.cpp b/td/telegram/Logging.cpp index 9bea786a1..730a576cf 100644 --- a/td/telegram/Logging.cpp +++ b/td/telegram/Logging.cpp @@ -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 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)}; +static const std::map 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(get_difference)}; #undef ADD_TAG Status Logging::set_current_stream(td_api::object_ptr stream) { diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 2199d70e7..98014e3f7 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -47,6 +47,8 @@ namespace td { +int VERBOSITY_NAME(get_difference) = VERBOSITY_NAME(INFO); + class OnUpdate { UpdatesManager *manager_; tl_object_ptr &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(td_)); @@ -748,7 +750,7 @@ void UpdatesManager::on_get_updates_state(tl_object_ptrunread_count; if (get_pts() == std::numeric_limits::max()) { @@ -929,8 +931,9 @@ void UpdatesManager::process_get_difference_updates( vector> &&new_messages, vector> &&new_encrypted_messages, int32 qts, vector> &&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 &&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; diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 473589527..3daea0083 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -23,6 +23,8 @@ namespace td { +extern int VERBOSITY_NAME(get_difference); + class Td; class UpdatesManager : public Actor {