From d2d0cb5cc02a85b21e6210cf1bf11b829924ce1d Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 5 Oct 2020 18:07:23 +0300 Subject: [PATCH] Move log tags definitions out of logging.cpp. GitOrigin-RevId: 0e74b94ec194f8ee678bb77a04d35df46702b330 --- td/mtproto/SessionConnection.cpp | 3 +++ td/mtproto/SessionConnection.h | 3 +++ td/mtproto/Transport.cpp | 3 +++ td/mtproto/Transport.h | 3 +++ td/telegram/Logging.cpp | 10 ++++++++++ td/telegram/Td.cpp | 5 +++-- td/telegram/Td.h | 1 + td/telegram/cli.cpp | 3 ++- td/telegram/files/FileLoader.cpp | 2 +- td/telegram/files/FileLoaderActor.h | 3 +-- td/telegram/files/FileLoaderUtils.cpp | 2 ++ td/telegram/files/FileLoaderUtils.h | 2 ++ td/telegram/files/PartsManager.cpp | 8 ++++++++ td/telegram/files/ResourceManager.cpp | 4 ++++ td/telegram/files/ResourceManager.h | 2 ++ td/telegram/net/DcAuthManager.cpp | 2 ++ td/telegram/net/DcAuthManager.h | 2 ++ td/telegram/net/NetQuery.cpp | 2 ++ td/telegram/net/NetQuery.h | 2 ++ td/telegram/net/Session.cpp | 1 + tdactor/td/actor/impl/Scheduler-decl.h | 2 ++ tdactor/td/actor/impl/Scheduler.cpp | 2 ++ tddb/td/db/SqliteStatement.cpp | 2 ++ tddb/td/db/SqliteStatement.h | 2 ++ tdutils/td/utils/logging.cpp | 10 ---------- tdutils/td/utils/logging.h | 10 ---------- tdutils/td/utils/port/detail/NativeFd.cpp | 3 ++- tdutils/td/utils/port/detail/NativeFd.h | 3 +++ 28 files changed, 70 insertions(+), 27 deletions(-) diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index 8c94fb8d7..7ee267f5e 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -32,6 +32,9 @@ #include namespace td { + +int VERBOSITY_NAME(mtproto) = VERBOSITY_NAME(DEBUG) + 7; + namespace mtproto_api { const int32 msg_container::ID; diff --git a/td/mtproto/SessionConnection.h b/td/mtproto/SessionConnection.h index 05a147056..7aa6e6b65 100644 --- a/td/mtproto/SessionConnection.h +++ b/td/mtproto/SessionConnection.h @@ -25,6 +25,9 @@ #include namespace td { + +extern int VERBOSITY_NAME(mtproto); + namespace mtproto_api { class rpc_error; diff --git a/td/mtproto/Transport.cpp b/td/mtproto/Transport.cpp index a2dadbc02..62db5190e 100644 --- a/td/mtproto/Transport.cpp +++ b/td/mtproto/Transport.cpp @@ -21,6 +21,9 @@ #include namespace td { + +int VERBOSITY_NAME(raw_mtproto) = VERBOSITY_NAME(DEBUG) + 10; + namespace mtproto { #pragma pack(push, 4) diff --git a/td/mtproto/Transport.h b/td/mtproto/Transport.h index 5daca4892..aeb1e95ea 100644 --- a/td/mtproto/Transport.h +++ b/td/mtproto/Transport.h @@ -17,6 +17,9 @@ #include namespace td { + +extern int VERBOSITY_NAME(raw_mtproto); + namespace mtproto { class AuthKey; diff --git a/td/telegram/Logging.cpp b/td/telegram/Logging.cpp index 921e79d20..97c57fa78 100644 --- a/td/telegram/Logging.cpp +++ b/td/telegram/Logging.cpp @@ -6,23 +6,33 @@ // #include "td/telegram/Logging.h" +#include "td/mtproto/SessionConnection.h" +#include "td/mtproto/Transport.h" + #include "td/telegram/ConfigManager.h" #include "td/telegram/FileReferenceManager.h" #include "td/telegram/files/FileGcWorker.h" +#include "td/telegram/files/FileLoaderUtils.h" #include "td/telegram/files/FileManager.h" #include "td/telegram/net/ConnectionCreator.h" +#include "td/telegram/net/DcAuthManager.h" +#include "td/telegram/net/NetQuery.h" #include "td/telegram/NotificationManager.h" #include "td/telegram/Td.h" #include "td/telegram/UpdatesManager.h" #include "td/db/binlog/BinlogEvent.h" +#include "td/db/SqliteStatement.h" #include "td/net/GetHostByNameActor.h" #include "td/net/TransparentProxy.h" +#include "td/actor/actor.h" + #include "td/utils/FileLog.h" #include "td/utils/logging.h" #include "td/utils/misc.h" +#include "td/utils/port/detail/NativeFd.h" #include #include diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index befd94d47..86e63719a 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -138,6 +138,9 @@ namespace td { +int VERBOSITY_NAME(td_init) = VERBOSITY_NAME(DEBUG) + 3; +int VERBOSITY_NAME(td_requests) = VERBOSITY_NAME(INFO); + void Td::ResultHandler::set_td(Td *new_td) { CHECK(td == nullptr); td = new_td; @@ -4132,8 +4135,6 @@ class Td::UploadFileCallback : public FileManager::UploadCallback { } }; -int VERBOSITY_NAME(td_init) = VERBOSITY_NAME(DEBUG) + 3; - template void Td::complete_pending_preauthentication_requests(const T &func) { for (auto &request : pending_preauthentication_requests_) { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 923f0c693..11102e3d8 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -77,6 +77,7 @@ class WebPagesManager; namespace td { extern int VERBOSITY_NAME(td_init); +extern int VERBOSITY_NAME(td_requests); // Td may start closing after explicit "close" or "destroy" query. // Or it may start closing by itself, because authorization is lost. diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 4b829fcc0..95533a81c 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -14,6 +14,7 @@ #include "td/telegram/ClientActor.h" #include "td/telegram/Log.h" #include "td/telegram/td_api_json.h" +#include "td/telegram/Td.h" // for VERBOSITY_NAME(td_requests) #include "td/utils/base64.h" #include "td/utils/buffer.h" @@ -4229,7 +4230,7 @@ class CliClient final : public Actor { LOG(ERROR) << r_cpu_stats.error(); } else { auto stats = r_cpu_stats.move_as_ok(); - LOG(ERROR) << cpu_counter_ << ", total ticks = " << stats.total_ticks_ + LOG(ERROR) << cpu_counter_.load() << ", total ticks = " << stats.total_ticks_ << ", user ticks = " << stats.process_user_ticks_ << ", system ticks = " << stats.process_system_ticks_; } diff --git a/td/telegram/files/FileLoader.cpp b/td/telegram/files/FileLoader.cpp index f4ed1f865..c93c29644 100644 --- a/td/telegram/files/FileLoader.cpp +++ b/td/telegram/files/FileLoader.cpp @@ -6,6 +6,7 @@ // #include "td/telegram/files/FileLoader.h" +#include "td/telegram/files/FileLoaderUtils.h" #include "td/telegram/files/ResourceManager.h" #include "td/telegram/Global.h" #include "td/telegram/net/NetQueryDispatcher.h" @@ -18,7 +19,6 @@ #include "td/utils/ScopeGuard.h" #include -#include namespace td { diff --git a/td/telegram/files/FileLoaderActor.h b/td/telegram/files/FileLoaderActor.h index 3164e133b..a9a707970 100644 --- a/td/telegram/files/FileLoaderActor.h +++ b/td/telegram/files/FileLoaderActor.h @@ -14,12 +14,11 @@ namespace td { -class LocalFileLocation; class ResourceManager; class FileLoaderActor : public NetQueryCallback { public: - virtual void set_resource_manager(ActorShared) = 0; + virtual void set_resource_manager(ActorShared resource_manager) = 0; virtual void update_priority(int8 priority) = 0; virtual void update_resources(const ResourceState &other) = 0; diff --git a/td/telegram/files/FileLoaderUtils.cpp b/td/telegram/files/FileLoaderUtils.cpp index 17b8c3e86..143479960 100644 --- a/td/telegram/files/FileLoaderUtils.cpp +++ b/td/telegram/files/FileLoaderUtils.cpp @@ -25,6 +25,8 @@ namespace td { +int VERBOSITY_NAME(files) = VERBOSITY_NAME(DEBUG) + 2; + namespace { Result> try_create_new_file(Result result_name) { TRY_RESULT(name, std::move(result_name)); diff --git a/td/telegram/files/FileLoaderUtils.h b/td/telegram/files/FileLoaderUtils.h index 32a10cf4c..526b37dc3 100644 --- a/td/telegram/files/FileLoaderUtils.h +++ b/td/telegram/files/FileLoaderUtils.h @@ -19,6 +19,8 @@ namespace td { +extern int VERBOSITY_NAME(files); + Result> open_temp_file(FileType file_type) TD_WARN_UNUSED_RESULT; Result create_from_temp(CSlice temp_path, CSlice dir, CSlice name) TD_WARN_UNUSED_RESULT; diff --git a/td/telegram/files/PartsManager.cpp b/td/telegram/files/PartsManager.cpp index 78e764f92..3777fd729 100644 --- a/td/telegram/files/PartsManager.cpp +++ b/td/telegram/files/PartsManager.cpp @@ -6,6 +6,8 @@ // #include "td/telegram/files/PartsManager.h" +#include "td/telegram/files/FileLoaderUtils.h" + #include "td/utils/format.h" #include "td/utils/logging.h" #include "td/utils/misc.h" @@ -150,12 +152,14 @@ bool PartsManager::unchecked_ready() { << ", checked_prefix_size = " << checked_prefix_size_; return !unknown_size_flag_ && ready_size_ == size_; } + bool PartsManager::may_finish() { if (is_streaming_limit_reached()) { return true; } return ready(); } + bool PartsManager::ready() { return unchecked_ready() && (!need_check_ || checked_prefix_size_ == size_); } @@ -213,9 +217,11 @@ int32 PartsManager::get_ready_prefix_count() { } return res; } + int64 PartsManager::get_streaming_offset() const { return streaming_offset_; } + string PartsManager::get_bitmask() { int32 prefix_count = -1; if (need_check_) { @@ -399,6 +405,7 @@ int64 PartsManager::get_size() const { CHECK(!unknown_size_flag_); return size_; } + int64 PartsManager::get_size_or_zero() const { return size_; } @@ -511,6 +518,7 @@ void PartsManager::set_checked_prefix_size(int64 size) { int64 PartsManager::get_checked_prefix_size() const { return checked_prefix_size_; } + int64 PartsManager::get_unchecked_ready_prefix_size() { update_first_not_ready_part(); auto count = first_not_ready_part_; diff --git a/td/telegram/files/ResourceManager.cpp b/td/telegram/files/ResourceManager.cpp index a66b0fc81..641403c3b 100644 --- a/td/telegram/files/ResourceManager.cpp +++ b/td/telegram/files/ResourceManager.cpp @@ -6,6 +6,8 @@ // #include "td/telegram/files/ResourceManager.h" +#include "td/telegram/files/FileLoaderUtils.h" + #include "td/utils/common.h" #include "td/utils/format.h" #include "td/utils/logging.h" @@ -159,6 +161,7 @@ void ResourceManager::loop() { } } } + void ResourceManager::add_node(NodeId node_id, int8 priority) { if (priority >= 0) { auto it = std::find_if(to_xload_.begin(), to_xload_.end(), [&](auto &x) { return x.first <= priority; }); @@ -168,6 +171,7 @@ void ResourceManager::add_node(NodeId node_id, int8 priority) { to_xload_.insert(it, std::make_pair(narrow_cast(-priority), node_id)); } } + bool ResourceManager::remove_node(NodeId node_id) { auto it = std::find_if(to_xload_.begin(), to_xload_.end(), [&](auto &x) { return x.second == node_id; }); if (it != to_xload_.end()) { diff --git a/td/telegram/files/ResourceManager.h b/td/telegram/files/ResourceManager.h index eaeba97c2..47884b172 100644 --- a/td/telegram/files/ResourceManager.h +++ b/td/telegram/files/ResourceManager.h @@ -17,6 +17,7 @@ #include namespace td { + class ResourceManager : public Actor { public: enum class Mode : int32 { Baseline, Greedy }; @@ -64,4 +65,5 @@ class ResourceManager : public Actor { void add_node(NodeId node_id, int8 priority); bool remove_node(NodeId node_id); }; + } // namespace td diff --git a/td/telegram/net/DcAuthManager.cpp b/td/telegram/net/DcAuthManager.cpp index c370fcf92..147d358d5 100644 --- a/td/telegram/net/DcAuthManager.cpp +++ b/td/telegram/net/DcAuthManager.cpp @@ -26,6 +26,8 @@ namespace td { +int VERBOSITY_NAME(dc) = VERBOSITY_NAME(DEBUG) + 2; + DcAuthManager::DcAuthManager(ActorShared<> parent) { parent_ = std::move(parent); auto s_main_dc_id = G()->td_db()->get_binlog_pmc()->get("main_dc_id"); diff --git a/td/telegram/net/DcAuthManager.h b/td/telegram/net/DcAuthManager.h index bec44bc28..71f0ab159 100644 --- a/td/telegram/net/DcAuthManager.h +++ b/td/telegram/net/DcAuthManager.h @@ -20,6 +20,8 @@ namespace td { +extern int VERBOSITY_NAME(dc); + class DcAuthManager : public NetQueryCallback { public: explicit DcAuthManager(ActorShared<> parent); diff --git a/td/telegram/net/NetQuery.cpp b/td/telegram/net/NetQuery.cpp index e02565093..df426042d 100644 --- a/td/telegram/net/NetQuery.cpp +++ b/td/telegram/net/NetQuery.cpp @@ -15,6 +15,8 @@ namespace td { +int VERBOSITY_NAME(net_query) = VERBOSITY_NAME(INFO); + int32 NetQuery::get_my_id() { return G()->get_my_id(); } diff --git a/td/telegram/net/NetQuery.h b/td/telegram/net/NetQuery.h index 246c1d497..db0c60238 100644 --- a/td/telegram/net/NetQuery.h +++ b/td/telegram/net/NetQuery.h @@ -31,6 +31,8 @@ namespace td { +extern int VERBOSITY_NAME(net_query); + class NetQuery; using NetQueryPtr = ObjectPool::OwnerPtr; using NetQueryRef = ObjectPool::WeakPtr; diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index cdf7075b1..8498839c0 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -10,6 +10,7 @@ #include "td/telegram/DhCache.h" #include "td/telegram/Global.h" +#include "td/telegram/net/DcAuthManager.h" #include "td/telegram/net/DcId.h" #include "td/telegram/net/MtprotoHeader.h" #include "td/telegram/net/NetQuery.h" diff --git a/tdactor/td/actor/impl/Scheduler-decl.h b/tdactor/td/actor/impl/Scheduler-decl.h index f9e80861a..73b94debd 100644 --- a/tdactor/td/actor/impl/Scheduler-decl.h +++ b/tdactor/td/actor/impl/Scheduler-decl.h @@ -32,6 +32,8 @@ namespace td { +extern int VERBOSITY_NAME(actor); + class ActorInfo; enum class ActorSendType { Immediate, Later, LaterWeak }; diff --git a/tdactor/td/actor/impl/Scheduler.cpp b/tdactor/td/actor/impl/Scheduler.cpp index 69c48a2f4..39cb4661e 100644 --- a/tdactor/td/actor/impl/Scheduler.cpp +++ b/tdactor/td/actor/impl/Scheduler.cpp @@ -27,6 +27,8 @@ namespace td { +int VERBOSITY_NAME(actor) = VERBOSITY_NAME(DEBUG) + 10; + TD_THREAD_LOCAL Scheduler *Scheduler::scheduler_; // static zero-initialized TD_THREAD_LOCAL ActorContext *Scheduler::context_; // static zero-initialized diff --git a/tddb/td/db/SqliteStatement.cpp b/tddb/td/db/SqliteStatement.cpp index 0547a6c55..f13218870 100644 --- a/tddb/td/db/SqliteStatement.cpp +++ b/tddb/td/db/SqliteStatement.cpp @@ -15,6 +15,8 @@ namespace td { +int VERBOSITY_NAME(sqlite) = VERBOSITY_NAME(DEBUG) + 10; + namespace { int printExplainQueryPlan(StringBuilder &sb, sqlite3_stmt *pStmt) { const char *zSql = sqlite3_sql(pStmt); diff --git a/tddb/td/db/SqliteStatement.h b/tddb/td/db/SqliteStatement.h index 7182b1409..6612fcfca 100644 --- a/tddb/td/db/SqliteStatement.h +++ b/tddb/td/db/SqliteStatement.h @@ -20,6 +20,8 @@ struct sqlite3_stmt; namespace td { +extern int VERBOSITY_NAME(sqlite); + class SqliteStatement { public: SqliteStatement() = default; diff --git a/tdutils/td/utils/logging.cpp b/tdutils/td/utils/logging.cpp index 46a5dbc60..7fac06f33 100644 --- a/tdutils/td/utils/logging.cpp +++ b/tdutils/td/utils/logging.cpp @@ -29,16 +29,6 @@ namespace td { -int VERBOSITY_NAME(net_query) = VERBOSITY_NAME(INFO); -int VERBOSITY_NAME(td_requests) = VERBOSITY_NAME(INFO); -int VERBOSITY_NAME(dc) = VERBOSITY_NAME(DEBUG) + 2; -int VERBOSITY_NAME(files) = VERBOSITY_NAME(DEBUG) + 2; -int VERBOSITY_NAME(mtproto) = VERBOSITY_NAME(DEBUG) + 7; -int VERBOSITY_NAME(raw_mtproto) = VERBOSITY_NAME(DEBUG) + 10; -int VERBOSITY_NAME(fd) = VERBOSITY_NAME(DEBUG) + 9; -int VERBOSITY_NAME(actor) = VERBOSITY_NAME(DEBUG) + 10; -int VERBOSITY_NAME(sqlite) = VERBOSITY_NAME(DEBUG) + 10; - LogOptions log_options; TD_THREAD_LOCAL const char *Logger::tag_ = nullptr; diff --git a/tdutils/td/utils/logging.h b/tdutils/td/utils/logging.h index 07d37c384..1202f0083 100644 --- a/tdutils/td/utils/logging.h +++ b/tdutils/td/utils/logging.h @@ -109,16 +109,6 @@ constexpr int VERBOSITY_NAME(DEBUG) = 4; constexpr int VERBOSITY_NAME(NEVER) = 1024; namespace td { -// TODO Not part of utils. Should be in some separate file -extern int VERBOSITY_NAME(mtproto); -extern int VERBOSITY_NAME(raw_mtproto); -extern int VERBOSITY_NAME(dc); -extern int VERBOSITY_NAME(fd); -extern int VERBOSITY_NAME(net_query); -extern int VERBOSITY_NAME(td_requests); -extern int VERBOSITY_NAME(actor); -extern int VERBOSITY_NAME(files); -extern int VERBOSITY_NAME(sqlite); struct LogOptions { std::atomic level{VERBOSITY_NAME(DEBUG) + 1}; diff --git a/tdutils/td/utils/port/detail/NativeFd.cpp b/tdutils/td/utils/port/detail/NativeFd.cpp index 3899b4a71..9c8b4f880 100644 --- a/tdutils/td/utils/port/detail/NativeFd.cpp +++ b/tdutils/td/utils/port/detail/NativeFd.cpp @@ -8,7 +8,6 @@ #include "td/utils/format.h" #include "td/utils/logging.h" -#include "td/utils/Status.h" #if TD_PORT_POSIX #include @@ -22,6 +21,8 @@ namespace td { +int VERBOSITY_NAME(fd) = VERBOSITY_NAME(DEBUG) + 9; + #if TD_FD_DEBUG class FdSet { public: diff --git a/tdutils/td/utils/port/detail/NativeFd.h b/tdutils/td/utils/port/detail/NativeFd.h index f6dcce9b6..4ecd99cbb 100644 --- a/tdutils/td/utils/port/detail/NativeFd.h +++ b/tdutils/td/utils/port/detail/NativeFd.h @@ -9,11 +9,14 @@ #include "td/utils/port/config.h" #include "td/utils/common.h" +#include "td/utils/logging.h" #include "td/utils/Status.h" #include "td/utils/StringBuilder.h" namespace td { +extern int VERBOSITY_NAME(fd); + class NativeFd { public: #if TD_PORT_POSIX