Skip to content

Commit

Permalink
Move log tags definitions out of logging.cpp.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 0e74b94ec194f8ee678bb77a04d35df46702b330
  • Loading branch information
levlam committed Oct 5, 2020
1 parent c9c19f3 commit d2d0cb5
Show file tree
Hide file tree
Showing 28 changed files with 70 additions and 27 deletions.
3 changes: 3 additions & 0 deletions td/mtproto/SessionConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include <type_traits>

namespace td {

int VERBOSITY_NAME(mtproto) = VERBOSITY_NAME(DEBUG) + 7;

namespace mtproto_api {

const int32 msg_container::ID;
Expand Down
3 changes: 3 additions & 0 deletions td/mtproto/SessionConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <utility>

namespace td {

extern int VERBOSITY_NAME(mtproto);

namespace mtproto_api {

class rpc_error;
Expand Down
3 changes: 3 additions & 0 deletions td/mtproto/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <tuple>

namespace td {

int VERBOSITY_NAME(raw_mtproto) = VERBOSITY_NAME(DEBUG) + 10;

namespace mtproto {

#pragma pack(push, 4)
Expand Down
3 changes: 3 additions & 0 deletions td/mtproto/Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include <utility>

namespace td {

extern int VERBOSITY_NAME(raw_mtproto);

namespace mtproto {

class AuthKey;
Expand Down
10 changes: 10 additions & 0 deletions td/telegram/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <atomic>
#include <map>
Expand Down
5 changes: 3 additions & 2 deletions td/telegram/Td.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -4132,8 +4135,6 @@ class Td::UploadFileCallback : public FileManager::UploadCallback {
}
};

int VERBOSITY_NAME(td_init) = VERBOSITY_NAME(DEBUG) + 3;

template <class T>
void Td::complete_pending_preauthentication_requests(const T &func) {
for (auto &request : pending_preauthentication_requests_) {
Expand Down
1 change: 1 addition & 0 deletions td/telegram/Td.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion td/telegram/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_;
}
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/files/FileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -18,7 +19,6 @@
#include "td/utils/ScopeGuard.h"

#include <tuple>
#include <utility>

namespace td {

Expand Down
3 changes: 1 addition & 2 deletions td/telegram/files/FileLoaderActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

namespace td {

class LocalFileLocation;
class ResourceManager;

class FileLoaderActor : public NetQueryCallback {
public:
virtual void set_resource_manager(ActorShared<ResourceManager>) = 0;
virtual void set_resource_manager(ActorShared<ResourceManager> resource_manager) = 0;
virtual void update_priority(int8 priority) = 0;
virtual void update_resources(const ResourceState &other) = 0;

Expand Down
2 changes: 2 additions & 0 deletions td/telegram/files/FileLoaderUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

namespace td {

int VERBOSITY_NAME(files) = VERBOSITY_NAME(DEBUG) + 2;

namespace {
Result<std::pair<FileFd, string>> try_create_new_file(Result<CSlice> result_name) {
TRY_RESULT(name, std::move(result_name));
Expand Down
2 changes: 2 additions & 0 deletions td/telegram/files/FileLoaderUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace td {

extern int VERBOSITY_NAME(files);

Result<std::pair<FileFd, string>> open_temp_file(FileType file_type) TD_WARN_UNUSED_RESULT;

Result<string> create_from_temp(CSlice temp_path, CSlice dir, CSlice name) TD_WARN_UNUSED_RESULT;
Expand Down
8 changes: 8 additions & 0 deletions td/telegram/files/PartsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_);
}
Expand Down Expand Up @@ -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_) {
Expand Down Expand Up @@ -399,6 +405,7 @@ int64 PartsManager::get_size() const {
CHECK(!unknown_size_flag_);
return size_;
}

int64 PartsManager::get_size_or_zero() const {
return size_;
}
Expand Down Expand Up @@ -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_;
Expand Down
4 changes: 4 additions & 0 deletions td/telegram/files/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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; });
Expand All @@ -168,6 +171,7 @@ void ResourceManager::add_node(NodeId node_id, int8 priority) {
to_xload_.insert(it, std::make_pair(narrow_cast<int8>(-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()) {
Expand Down
2 changes: 2 additions & 0 deletions td/telegram/files/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <utility>

namespace td {

class ResourceManager : public Actor {
public:
enum class Mode : int32 { Baseline, Greedy };
Expand Down Expand Up @@ -64,4 +65,5 @@ class ResourceManager : public Actor {
void add_node(NodeId node_id, int8 priority);
bool remove_node(NodeId node_id);
};

} // namespace td
2 changes: 2 additions & 0 deletions td/telegram/net/DcAuthManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions td/telegram/net/DcAuthManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

namespace td {

extern int VERBOSITY_NAME(dc);

class DcAuthManager : public NetQueryCallback {
public:
explicit DcAuthManager(ActorShared<> parent);
Expand Down
2 changes: 2 additions & 0 deletions td/telegram/net/NetQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace td {

int VERBOSITY_NAME(net_query) = VERBOSITY_NAME(INFO);

int32 NetQuery::get_my_id() {
return G()->get_my_id();
}
Expand Down
2 changes: 2 additions & 0 deletions td/telegram/net/NetQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

namespace td {

extern int VERBOSITY_NAME(net_query);

class NetQuery;
using NetQueryPtr = ObjectPool<NetQuery>::OwnerPtr;
using NetQueryRef = ObjectPool<NetQuery>::WeakPtr;
Expand Down
1 change: 1 addition & 0 deletions td/telegram/net/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions tdactor/td/actor/impl/Scheduler-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

namespace td {

extern int VERBOSITY_NAME(actor);

class ActorInfo;

enum class ActorSendType { Immediate, Later, LaterWeak };
Expand Down
2 changes: 2 additions & 0 deletions tdactor/td/actor/impl/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tddb/td/db/SqliteStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tddb/td/db/SqliteStatement.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct sqlite3_stmt;

namespace td {

extern int VERBOSITY_NAME(sqlite);

class SqliteStatement {
public:
SqliteStatement() = default;
Expand Down
10 changes: 0 additions & 10 deletions tdutils/td/utils/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions tdutils/td/utils/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> level{VERBOSITY_NAME(DEBUG) + 1};
Expand Down
3 changes: 2 additions & 1 deletion tdutils/td/utils/port/detail/NativeFd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/Status.h"

#if TD_PORT_POSIX
#include <fcntl.h>
Expand All @@ -22,6 +21,8 @@

namespace td {

int VERBOSITY_NAME(fd) = VERBOSITY_NAME(DEBUG) + 9;

#if TD_FD_DEBUG
class FdSet {
public:
Expand Down
Loading

0 comments on commit d2d0cb5

Please sign in to comment.