add:添加可查询自己ID和所处位置的命令Who和Where。

This commit is contained in:
taynpg 2025-02-25 16:09:22 +08:00
parent ea1c7bb631
commit e41876f063
3 changed files with 23 additions and 8 deletions

View File

@ -1,8 +1,8 @@
{
"files.autoSave": "onFocusChange",
"editor.fontSize": 14,
"editor.fontFamily": "'Source Code Pro', 'Source Code Pro', monospace",
"terminal.integrated.fontFamily": "Source Code Pro",
"editor.fontFamily": "'FiraCode Nerd Font Mono', 'FiraCode Nerd Font Mono', 'FiraCode Nerd Font Mono'",
"terminal.integrated.fontFamily": "FiraCode Nerd Font Mono",
"editor.fontLigatures": true,
//"C_Cpp.default.configurationProvider": "tboox.xmake-vscode",
"cmake.configureOnOpen": true,
@ -151,7 +151,8 @@
"hash_map": "cpp",
"stdfloat": "cpp",
"unordered_set": "cpp",
"cfenv": "cpp"
"cfenv": "cpp",
"cassert": "cpp"
},
"makefile.configureOnOpen": false,
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"

View File

@ -66,7 +66,8 @@ void CClient::run(const std::string& ip, const std::string& port)
delete bf;
TLOGI(log_, "version: {}", VERSION_NUM);
TLOGI(log_, "opensource: {}", VERSION_URL);
TLOGW(log_, "SupportCmd:Get|Up|Down|Cancel|Update");
TLOGW(log_, "SupportCmd ==>");
TLOGW(log_, "Get|Up|Down|Cancel|Update|Who|Where");
fc_append('|');
while (1) {
@ -87,6 +88,14 @@ void CClient::run(const std::string& ip, const std::string& port)
std::this_thread::sleep_for(std::chrono::milliseconds(10));
break;
}
if (cmd_input == "who" || cmd_input == "Who") {
TLOGD(log_, "ID => {}", own_id_);
continue;
}
if (cmd_input == "Where" || cmd_input == "where") {
TLOGD(log_, "At => {}", COfPath::to_full("."));
continue;
}
if (cmd_input == "Get" || cmd_input == "get") {
get_task_list();
continue;
@ -534,7 +543,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
}
switch (buf->type_) {
case TYPE_GET_ID: {
TLOGD(log_, "Your ID:{}", buf->tid_);
TLOGD(log_, "ID => {}", buf->tid_);
own_id_ = buf->tid_;
break;
}
@ -576,11 +585,16 @@ void CClient::handle_frame(CFrameBuffer* buf)
task_list_[index]->id = id;
}
if (num < 20) {
TLOGD(log_, "*****************************************");
TLOGD(log_, "============================================");
if (id == own_id_) {
TLOGI(log_, "@{}", real);
} else {
TLOGI(log_, "{}", real);
}
}
}
}
if (num >= 20) {
TLOGW(log_, "Too Many Files [{}], Only Display 20.", num);
}

View File

@ -132,7 +132,7 @@ CFrameBuffer::~CFrameBuffer()
Log_t get_logger(const std::string& mark)
{
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
console_sink->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e]: %v%$");
console_sink->set_pattern("%^[%m-%d %H:%M:%S.%e]: %v%$");
auto logger = std::make_shared<spdlog::logger>(mark, console_sink);
logger->set_level(spdlog::level::debug);
spdlog::register_logger(logger);