Add td_api::testSetLogTagVerbosityLevel method.
GitOrigin-RevId: 763fcf9156671857c71967741b9ce8c67f4a7ea0
This commit is contained in:
parent
a3b6aca07d
commit
b7c2248c72
@ -3402,3 +3402,7 @@ testGetDifference = Ok;
|
||||
testUseUpdate = Update;
|
||||
//@description Does nothing and ensures that the Error object is used; for testing only
|
||||
testUseError = Error;
|
||||
//@description Changes verbosity level for a specified log tag; for testing only. This is an offline method. Can be called before authorization. Can be called synchronously
|
||||
//@tag Logging tag to change verbosity level (one of "td_init", "update_file", "connections", "binlog", "proxy", "net_query", "td_requests", "dc", "files", "mtproto", "raw_mtproto", "fd", "actor", "buffer", "sqlite")
|
||||
//@new_verbosity_level New verbosity level; 0-1023
|
||||
testSetLogTagVerbosityLevel tag:string new_verbosity_level:int32 = Ok;
|
||||
|
Binary file not shown.
@ -73,6 +73,8 @@
|
||||
|
||||
#include "td/mtproto/utils.h" // for create_storer, fetch_result, etc, TODO
|
||||
|
||||
#include "tdnet/td/net/TransparentProxy.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/filesystem.h"
|
||||
#include "td/utils/format.h"
|
||||
@ -3251,6 +3253,7 @@ bool Td::is_synchronous_request(int32 id) {
|
||||
case td_api::getFileExtension::ID:
|
||||
case td_api::cleanFileName::ID:
|
||||
case td_api::getLanguagePackString::ID:
|
||||
case td_api::testSetLogTagVerbosityLevel::ID:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -6907,6 +6910,73 @@ void Td::on_request(uint64 id, td_api::testGetDifference &request) {
|
||||
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
||||
}
|
||||
|
||||
static int *get_log_verbosity_level(Slice name) {
|
||||
if (name == "td_init") {
|
||||
return &VERBOSITY_NAME(td_init);
|
||||
}
|
||||
if (name == "update_file") {
|
||||
return &VERBOSITY_NAME(update_file);
|
||||
}
|
||||
if (name == "connections") {
|
||||
return &VERBOSITY_NAME(connections);
|
||||
}
|
||||
if (name == "binlog") {
|
||||
return &VERBOSITY_NAME(binlog);
|
||||
}
|
||||
if (name == "proxy") {
|
||||
return &VERBOSITY_NAME(proxy);
|
||||
}
|
||||
if (name == "net_query") {
|
||||
return &VERBOSITY_NAME(net_query);
|
||||
}
|
||||
if (name == "td_requests") {
|
||||
return &VERBOSITY_NAME(td_requests);
|
||||
}
|
||||
if (name == "dc") {
|
||||
return &VERBOSITY_NAME(dc);
|
||||
}
|
||||
if (name == "files") {
|
||||
return &VERBOSITY_NAME(files);
|
||||
}
|
||||
if (name == "mtproto") {
|
||||
return &VERBOSITY_NAME(mtproto);
|
||||
}
|
||||
if (name == "raw_mtproto") {
|
||||
return &VERBOSITY_NAME(raw_mtproto);
|
||||
}
|
||||
if (name == "fd") {
|
||||
return &VERBOSITY_NAME(fd);
|
||||
}
|
||||
if (name == "actor") {
|
||||
return &VERBOSITY_NAME(actor);
|
||||
}
|
||||
if (name == "buffer") {
|
||||
return &VERBOSITY_NAME(buffer);
|
||||
}
|
||||
if (name == "sqlite") {
|
||||
return &VERBOSITY_NAME(sqlite);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::testSetLogTagVerbosityLevel &request) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::testSetLogTagVerbosityLevel &request) {
|
||||
if (request.new_verbosity_level_ < 0 || request.new_verbosity_level_ > 1023) {
|
||||
return td_api::make_object<td_api::error>(400, "Wrong new verbosity level");
|
||||
}
|
||||
|
||||
int *level = get_log_verbosity_level(request.tag_);
|
||||
if (level == nullptr) {
|
||||
return td_api::make_object<td_api::error>(400, "Log tag is not found");
|
||||
}
|
||||
*level = static_cast<int>(request.new_verbosity_level_);
|
||||
|
||||
return td_api::make_object<td_api::ok>();
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::testUseUpdate &request) {
|
||||
send_closure(actor_id(this), &Td::send_result, id, nullptr);
|
||||
}
|
||||
|
@ -906,6 +906,7 @@ class Td final : public NetQueryCallback {
|
||||
// test
|
||||
void on_request(uint64 id, td_api::testNetwork &request);
|
||||
void on_request(uint64 id, td_api::testGetDifference &request);
|
||||
void on_request(uint64 id, td_api::testSetLogTagVerbosityLevel &request);
|
||||
void on_request(uint64 id, td_api::testUseUpdate &request);
|
||||
void on_request(uint64 id, td_api::testUseError &request);
|
||||
void on_request(uint64 id, td_api::testCallEmpty &request);
|
||||
@ -925,6 +926,7 @@ class Td final : public NetQueryCallback {
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::getFileExtension &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::cleanFileName &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::getLanguagePackString &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::testSetLogTagVerbosityLevel &request);
|
||||
|
||||
Status init(DbKey key) TD_WARN_UNUSED_RESULT;
|
||||
void clear();
|
||||
|
@ -3381,6 +3381,16 @@ class CliClient final : public Actor {
|
||||
td::Log::set_verbosity_level(static_cast<int>(op.size()));
|
||||
} else if (op[0] == 'v' && ('0' <= op[1] && op[1] <= '9')) {
|
||||
td::Log::set_verbosity_level(to_integer<int>(op.substr(1)));
|
||||
} else if (op == "sltvl" || op == "sltvle") {
|
||||
string tag;
|
||||
string level;
|
||||
std::tie(tag, level) = split(args);
|
||||
auto request = make_tl_object<td_api::testSetLogTagVerbosityLevel>(tag, to_integer<int32>(level));
|
||||
if (op == "sltvl") {
|
||||
send_request(std::move(request));
|
||||
} else {
|
||||
execute(std::move(request));
|
||||
}
|
||||
} else if (op == "q" || op == "Quit") {
|
||||
quit();
|
||||
} else if (op == "dnq" || op == "DumpNetQueries") {
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
static int VERBOSITY_NAME(update_file) = VERBOSITY_NAME(DEBUG);
|
||||
int VERBOSITY_NAME(update_file) = VERBOSITY_NAME(DEBUG);
|
||||
|
||||
FileNode *FileNodePtr::operator->() const {
|
||||
return get();
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
extern int VERBOSITY_NAME(update_file);
|
||||
|
||||
enum class FileLocationSource : int8 { None, FromUser, FromDb, FromServer };
|
||||
|
||||
class FileNode {
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
static int VERBOSITY_NAME(connections) = VERBOSITY_NAME(DEBUG) + 8;
|
||||
int VERBOSITY_NAME(connections) = VERBOSITY_NAME(DEBUG) + 8;
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@ -48,6 +48,8 @@ class GetHostByNameActor;
|
||||
|
||||
namespace td {
|
||||
|
||||
extern int VERBOSITY_NAME(connections);
|
||||
|
||||
class Proxy {
|
||||
public:
|
||||
static Proxy socks5(string server, int32 port, string user, string password) {
|
||||
|
@ -57,7 +57,6 @@ class OptionsParser {
|
||||
#if TD_WINDOWS
|
||||
return -1;
|
||||
#else
|
||||
// use getopt. long keys are not supported for now
|
||||
char buff[1024];
|
||||
StringBuilder sb({buff, sizeof(buff)});
|
||||
for (auto &opt : options_) {
|
||||
|
Loading…
Reference in New Issue
Block a user