From aa361b5d665ed7e0f0e239b95bd3eac02b06243d Mon Sep 17 00:00:00 2001 From: liduo Date: Mon, 19 May 2025 21:09:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3warning=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=BA=A7=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liduo --- src/cmd/package_parser.cpp | 2 +- src/compression_parser.cpp | 12 ++++++------ src/config_parser.cpp | 4 ++-- src/file_entry.cpp | 2 +- src/id_defined_parser.cpp | 4 ++-- src/resource_check.cpp | 2 +- src/resource_util.cpp | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cmd/package_parser.cpp b/src/cmd/package_parser.cpp index 67ad9cd..9c76dd5 100644 --- a/src/cmd/package_parser.cpp +++ b/src/cmd/package_parser.cpp @@ -553,7 +553,7 @@ uint32_t PackageParser::HandleProcess(int c, const string &argValue) { auto handler = handles_.find(c); if (handler == handles_.end()) { - cout << "Warning: unsupport " << c << endl; + PrintError(GetError(ERR_CODE_UNKNOWN_OPTION).FormatCause(std::to_string(c).c_str())); return RESTOOL_ERROR; } return handler->second(argValue); diff --git a/src/compression_parser.cpp b/src/compression_parser.cpp index 1379591..26504a4 100644 --- a/src/compression_parser.cpp +++ b/src/compression_parser.cpp @@ -125,8 +125,8 @@ uint32_t CompressionParser::Init() bool CompressionParser::ParseCompression(const cJSON *compressionNode) { if (!compressionNode) { - cout << "Warning: get 'compression' node is empty, the compiled images are not transcoded."; - cout << NEW_LINE_PATH << filePath_ << endl; + cerr << "Warning: get 'compression' node is empty, the compiled images are not transcoded."; + cerr << NEW_LINE_PATH << filePath_ << endl; return true; } if (!cJSON_IsObject(compressionNode)) { @@ -135,8 +135,8 @@ bool CompressionParser::ParseCompression(const cJSON *compressionNode) } cJSON *mediaNode = cJSON_GetObjectItem(compressionNode, "media"); if (!mediaNode) { - cout << "Warning: get 'media' node is empty, the compiled images are not transcoded."; - cout << NEW_LINE_PATH << filePath_ << endl; + cerr << "Warning: get 'media' node is empty, the compiled images are not transcoded."; + cerr << NEW_LINE_PATH << filePath_ << endl; return true; } if (!cJSON_IsObject(mediaNode)) { @@ -145,8 +145,8 @@ bool CompressionParser::ParseCompression(const cJSON *compressionNode) } cJSON *enableNode = cJSON_GetObjectItem(mediaNode, "enable"); if (!enableNode) { - cout << "Warning: get 'enable' node is empty, the compiled images are not transcoded."; - cout << NEW_LINE_PATH << filePath_ << endl; + cerr << "Warning: get 'enable' node is empty, the compiled images are not transcoded."; + cerr << NEW_LINE_PATH << filePath_ << endl; return true; } if (!cJSON_IsBool(enableNode)) { diff --git a/src/config_parser.cpp b/src/config_parser.cpp index 9d9f060..2447cfa 100644 --- a/src/config_parser.cpp +++ b/src/config_parser.cpp @@ -135,7 +135,7 @@ bool ConfigParser::SetAppIcon(string &icon, int64_t id) { cJSON *appNode = cJSON_GetObjectItem(root_, "app"); if (!appNode || !cJSON_IsObject(appNode)) { - cout << "Warning: 'app' not object" << endl; + cerr << "Warning: 'app' not object" << endl; return false; } cJSON_AddStringToObject(appNode, "icon", icon.c_str()); @@ -147,7 +147,7 @@ bool ConfigParser::SetAppLabel(string &label, int64_t id) { cJSON *appNode = cJSON_GetObjectItem(root_, "app"); if (!appNode || !cJSON_IsObject(appNode)) { - cout << "Warning: 'app' not object" << endl; + cerr << "Warning: 'app' not object" << endl; return false; } cJSON_AddStringToObject(appNode, "label", label.c_str()); diff --git a/src/file_entry.cpp b/src/file_entry.cpp index cc25f5e..8d87036 100644 --- a/src/file_entry.cpp +++ b/src/file_entry.cpp @@ -50,7 +50,7 @@ bool FileEntry::Init() { string filePath = filePath_.GetPath(); if (!Exist(filePath)) { - cout << "Warning: file not exist: " << filePath << endl; + cerr << "Warning: file not exist: " << filePath << endl; return false; } diff --git a/src/id_defined_parser.cpp b/src/id_defined_parser.cpp index 88129e0..bf8520a 100755 --- a/src/id_defined_parser.cpp +++ b/src/id_defined_parser.cpp @@ -104,8 +104,8 @@ uint32_t IdDefinedParser::Init(const string &filePath, bool isSystem) return RESTOOL_ERROR; } if (cJSON_GetArraySize(recordNode) == 0) { - cout << "Warning: 'record' node is empty, please check the JSON file."; - cout << NEW_LINE_PATH << filePath << endl; + cerr << "Warning: 'record' node is empty, please check the JSON file."; + cerr << NEW_LINE_PATH << filePath << endl; return RESTOOL_SUCCESS; } int64_t startSysId = 0; diff --git a/src/resource_check.cpp b/src/resource_check.cpp index 9312ab4..9704789 100755 --- a/src/resource_check.cpp +++ b/src/resource_check.cpp @@ -72,7 +72,7 @@ void ResourceCheck::CheckNodeInResourceItem(const string &key, const ResourceIte return; } if (width != height) { - cout << "Warning: the png width and height not equal" << NEW_LINE_PATH << filePath << endl; + cerr << "Warning: the png width and height not equal" << NEW_LINE_PATH << filePath << endl; return; } auto result = g_keyNodeIndexs.find(key); diff --git a/src/resource_util.cpp b/src/resource_util.cpp index 70c4250..0a821a8 100644 --- a/src/resource_util.cpp +++ b/src/resource_util.cpp @@ -490,8 +490,8 @@ bool ResourceUtil::IsValidName(const string &name) void ResourceUtil::PrintWarningMsg(vector> &noBaseResource) { for (const auto &item : noBaseResource) { - cout << "Warning: the " << ResourceUtil::ResTypeToString(item.first); - cout << " of '" << item.second << "' does not have a base resource." << endl; + cerr << "Warning: the " << ResourceUtil::ResTypeToString(item.first); + cerr << " of '" << item.second << "' does not have a base resource." << endl; } }