diff --git a/base/src/datetime_ex.cpp b/base/src/datetime_ex.cpp index fbf22c0d5dfff6389af63fd8fffe02170d56ffb4..12a814562a9c1fc4e4b4761a271198bae1fd3839 100644 --- a/base/src/datetime_ex.cpp +++ b/base/src/datetime_ex.cpp @@ -34,7 +34,6 @@ int64_t GetSecondsSince1970ToPointTime(struct tm inputTm) { time_t inputTime = mktime(&inputTm); if (inputTime == -1) { - UTILS_LOGE("mktime failed."); return -1; } system_clock::time_point pointTime = system_clock::from_time_t(inputTime); @@ -84,7 +83,7 @@ bool GetLocalTimeZone(int& timezone) t1 = mktime(&curTime1); t2 = mktime(&curTime2); if ((t1 == -1) || (t2 == -1)) { - UTILS_LOGE("mktime current time failed."); + UTILS_LOGD("mktime current time failed."); return false; } diff --git a/base/src/directory_ex.cpp b/base/src/directory_ex.cpp index 80e89292cf6d76c94f85c5f7dbfdad4cb1fc8965..fd8a366018cd079b483621e2bf5e73bdcf3480ea 100644 --- a/base/src/directory_ex.cpp +++ b/base/src/directory_ex.cpp @@ -28,7 +28,7 @@ string GetCurrentProcFullFileName() char procFile[PATH_MAX + 1] = {0}; int ret = readlink("/proc/self/exe", procFile, PATH_MAX); if (ret < 0 || ret > PATH_MAX) { - UTILS_LOGE("Get proc name failed, ret is: %{public}d!", ret); + UTILS_LOGD("Get proc name failed, ret is: %{public}d!", ret); return string(); } procFile[ret] = '\0'; @@ -245,7 +245,7 @@ bool ChangeModeDirectory(const string& path, const mode_t& mode) } else { if (access(subPath.c_str(), F_OK) == 0) { if (!ChangeMode(subPath, mode)) { - UTILS_LOGE("Failed to exec ChangeMode"); + UTILS_LOGD("Failed to exec ChangeMode"); closedir(dir); return false; } @@ -256,7 +256,7 @@ bool ChangeModeDirectory(const string& path, const mode_t& mode) string currentPath = ExcludeTrailingPathDelimiter(path); if (access(currentPath.c_str(), F_OK) == 0) { if (!ChangeMode(currentPath, mode)) { - UTILS_LOGE("Failed to exec ChangeMode"); + UTILS_LOGD("Failed to exec ChangeMode"); return false; } } @@ -266,24 +266,24 @@ bool ChangeModeDirectory(const string& path, const mode_t& mode) bool PathToRealPath(const string& path, string& realPath) { if (path.empty()) { - UTILS_LOGE("path is empty!"); + UTILS_LOGD("path is empty!"); return false; } if ((path.length() >= PATH_MAX)) { - UTILS_LOGE("path len is error, the len is: [%{public}zu]", path.length()); + UTILS_LOGD("path len is error, the len is: [%{public}zu]", path.length()); return false; } char tmpPath[PATH_MAX] = {0}; if (realpath(path.c_str(), tmpPath) == nullptr) { - UTILS_LOGE("path to realpath error"); + UTILS_LOGD("path to realpath error"); return false; } realPath = tmpPath; if (access(realPath.c_str(), F_OK) != 0) { - UTILS_LOGE("check realpath (%{private}s) error", realPath.c_str()); + UTILS_LOGD("check realpath (%{private}s) error", realPath.c_str()); return false; } return true; diff --git a/base/src/event_demultiplexer.cpp b/base/src/event_demultiplexer.cpp index cba4a3eb7507fe8b7ce045d7df881175d2bcf39c..fb8542a03962ee312ad34b03f6bbdd715994ffc3 100644 --- a/base/src/event_demultiplexer.cpp +++ b/base/src/event_demultiplexer.cpp @@ -47,7 +47,6 @@ uint32_t EventDemultiplexer::StartUp() if (epollFd_ < 0) { epollFd_ = epoll_create1(EPOLL_CLOEXEC); if (epollFd_ < 0) { - UTILS_LOGE("epoll_create1 failed."); return TIMER_ERR_BADF; } } @@ -65,7 +64,6 @@ void EventDemultiplexer::CleanUp() uint32_t EventDemultiplexer::UpdateEventHandler(EventHandler* handler) { if (handler == nullptr) { - UTILS_LOGE("event handler is null."); return TIMER_ERR_INVALID_VALUE; } @@ -82,7 +80,6 @@ uint32_t EventDemultiplexer::UpdateEventHandler(EventHandler* handler) } if (handler != itor->second) { - UTILS_LOGE("invalid event handler!"); return TIMER_ERR_DEAL_FAILED; } return Update(EPOLL_CTL_MOD, handler); @@ -91,7 +88,6 @@ uint32_t EventDemultiplexer::UpdateEventHandler(EventHandler* handler) uint32_t EventDemultiplexer::RemoveEventHandler(EventHandler* handler) { if (handler == nullptr) { - UTILS_LOGE("event handler is null."); return TIMER_ERR_INVALID_VALUE; } @@ -117,7 +113,7 @@ uint32_t EventDemultiplexer::Update(int operation, EventHandler* handler) event.data.ptr = reinterpret_cast(handler); if (epoll_ctl(epollFd_, operation, handler->GetHandle(), &event) != 0) { - UTILS_LOGE("epoll_ctl %{public}d operation %{public}d on handle %{public}d failed", + UTILS_LOGD("epoll_ctl %{public}d operation %{public}d on handle %{public}d failed", epollFd_, operation, handler->GetHandle()); return TIMER_ERR_DEAL_FAILED; } @@ -183,7 +179,7 @@ uint32_t EventDemultiplexer::Reactor2Epoll(uint32_t reactorEvent) case EventReactor::READ_EVENT | EventReactor::WRITE_EVENT: return EPOLLIN | EPOLLPRI | EPOLLOUT; default: - UTILS_LOGE("invalid event %{public}u.", reactorEvent); + UTILS_LOGD("invalid event %{public}u.", reactorEvent); return TIMER_ERR_DEAL_FAILED; } } diff --git a/base/src/event_reactor.cpp b/base/src/event_reactor.cpp index cfb6f533361a7537e42fef2c1bed8a074f7697d7..e54d183e2d7bbd737e8af63751d0610114010d8c 100644 --- a/base/src/event_reactor.cpp +++ b/base/src/event_reactor.cpp @@ -54,7 +54,6 @@ void EventReactor::UpdateEventHandler(EventHandler* handler) uint32_t EventReactor::StartUp() { if (demultiplexer_ == nullptr) { - UTILS_LOGE("Looper::startUp failed, demultiplexer is null."); return TIMER_ERR_INVALID_VALUE; } @@ -97,13 +96,12 @@ uint32_t EventReactor::ScheduleTimer(const TimerCallback& cb, uint32_t interval, std::lock_guard lock(mutex_); std::shared_ptr handler = std::make_shared(this, interval, once); if (handler == nullptr) { - UTILS_LOGE("ScheduleTimer create TimerEventHandler failed."); return TIMER_ERR_INVALID_VALUE; } handler->SetTimerCallback(cb); uint32_t ret = handler->Initialize(); if (ret != TIMER_ERR_OK) { - UTILS_LOGE("ScheduleTimer %{public}d initialize failed", interval); + UTILS_LOGD("ScheduleTimer %{public}d initialize failed", interval); return ret; } diff --git a/base/src/file_ex.cpp b/base/src/file_ex.cpp index d52f1b4de40f502bc2b1eae026725ad23761b819..7ac2ba96f55208e4fa5bd7c2e9ef842be99a95f0 100644 --- a/base/src/file_ex.cpp +++ b/base/src/file_ex.cpp @@ -37,14 +37,14 @@ bool LoadStringFromFile(const string& filePath, string& content) { ifstream file(filePath.c_str()); if (!file.is_open()) { - UTILS_LOGE("open file failed! filePath:%{public}s", filePath.c_str()); + UTILS_LOGD("open file failed! filePath:%{public}s", filePath.c_str()); return false; } file.seekg(0, ios::end); const long fileLength = file.tellg(); if (fileLength > MAX_FILE_LENGTH) { - UTILS_LOGE("invalid file length(%{public}ld)!", fileLength); + UTILS_LOGD("invalid file length(%{public}ld)!", fileLength); return false; } @@ -65,7 +65,7 @@ string GetFileNameByFd(const int fd) int ret = readlink(fdPath.c_str(), fileName, PATH_MAX); if (ret < 0 || ret > PATH_MAX) { - UTILS_LOGE("Get fileName failed, ret is: %{public}d!", ret); + UTILS_LOGD("Get fileName failed, ret is: %{public}d!", ret); return string(); } fileName[ret] = '\0'; @@ -76,7 +76,7 @@ bool LoadStringFromFdToFile(int fd, string& content) { string fileName = GetFileNameByFd(fd); if (fileName.empty()) { - UTILS_LOGE("LoadStringFromFd get file name by fd failed!"); + UTILS_LOGD("LoadStringFromFd get file name by fd failed!"); return false; } @@ -90,7 +90,7 @@ bool LoadStringFromFdToFile(int fd, string& content) bool LoadStringFromFd(int fd, string& content) { if (fd <= 0) { - UTILS_LOGE("invalid fd:%{public}d", fd); + UTILS_LOGD("invalid fd:%{public}d", fd); return false; } @@ -141,7 +141,7 @@ bool SaveStringToFile(const std::string& filePath, const std::string& content, b } if (!file.is_open()) { - UTILS_LOGE("open file failed! filePath:%{private}s", filePath.c_str()); + UTILS_LOGD("open file failed! filePath:%{private}s", filePath.c_str()); return false; } @@ -157,7 +157,7 @@ bool SaveStringToFile(const std::string& filePath, const std::string& content, b bool SaveStringToFd(int fd, const std::string& content) { if (fd <= 0) { - UTILS_LOGE("invalid fd:%{public}d", fd); + UTILS_LOGD("invalid fd:%{public}d", fd); return false; } @@ -185,13 +185,13 @@ bool LoadBufferFromNodeFile(const string& filePath, vector& content) { string realPath; if (!PathToRealPath(filePath, realPath)) { - UTILS_LOGE("filePath to realPath failed! filePath:%{private}s", filePath.c_str()); + UTILS_LOGD("filePath to realPath failed! filePath:%{private}s", filePath.c_str()); return false; } FILE *fp = fopen(realPath.c_str(), "r"); if (fp == nullptr) { - UTILS_LOGE("open file failed! filePath:%{private}s", realPath.c_str()); + UTILS_LOGD("open file failed! filePath:%{private}s", realPath.c_str()); return false; } @@ -222,14 +222,14 @@ bool LoadBufferFromFile(const string& filePath, vector& content) ifstream file; file.open(filePath.c_str(), ios::in | ios::binary); if (!file.is_open()) { - UTILS_LOGE("open file failed! filePath:%{private}s", filePath.c_str()); + UTILS_LOGD("open file failed! filePath:%{private}s", filePath.c_str()); return false; } file.seekg(0, std::ios::end); const long fileLength = file.tellg(); if (fileLength > MAX_FILE_LENGTH) { - UTILS_LOGE("invalid file length(%{public}ld)!", fileLength); + UTILS_LOGD("invalid file length(%{public}ld)!", fileLength); return false; } @@ -266,7 +266,7 @@ bool SaveBufferToFile(const string& filePath, const vector& content, bool ofstream file; file.open(filePath.c_str(), mode); if (!file.is_open()) { - UTILS_LOGE("open file failed! filePath:%{private}s, mode:%{private}d", filePath.c_str(), mode); + UTILS_LOGD("open file failed! filePath:%{private}s, mode:%{private}d", filePath.c_str(), mode); return false; } @@ -282,13 +282,13 @@ bool FileExists(const string& fileName) bool StringExistsInFile(const string& fileName, const string& subStr, bool caseSensitive /*= true*/) { if (subStr.empty()) { - UTILS_LOGE("String is empty"); + UTILS_LOGD("String is empty"); return false; } string str; if (!LoadStringFromFile(fileName, str)) { - UTILS_LOGE("File load fail, filePath:%{private}s", fileName.c_str()); + UTILS_LOGD("File load fail, filePath:%{private}s", fileName.c_str()); return false; } @@ -306,7 +306,7 @@ bool StringExistsInFile(const string& fileName, const string& subStr, bool caseS int CountStrInStr(const string& str, const string& subStr) { if (subStr.empty()) { - UTILS_LOGE("subStr is empty"); + UTILS_LOGD("subStr is empty"); return 0; } @@ -324,13 +324,13 @@ int CountStrInStr(const string& str, const string& subStr) int CountStrInFile(const string& fileName, const string& subStr, bool caseSensitive /*= true*/) { if (subStr.empty()) { - UTILS_LOGE("String is empty"); + UTILS_LOGD("String is empty"); return -1; } string str; if (!LoadStringFromFile(fileName, str)) { - UTILS_LOGE("File load fail, filePath:%{private}s", fileName.c_str()); + UTILS_LOGD("File load fail, filePath:%{private}s", fileName.c_str()); return -1; } diff --git a/base/src/string_ex.cpp b/base/src/string_ex.cpp index dc12736ba43962bd46e41664a84862666b6a9e4e..32340ae1a502828a1d955904ccba03674def6857 100644 --- a/base/src/string_ex.cpp +++ b/base/src/string_ex.cpp @@ -111,7 +111,6 @@ bool StrToInt(const string& str, int& value) auto result = strtol(addr, &end, 10); /* 10 means decimal */ if ((end == addr) || (end[0] != '\0') || (errno == ERANGE) || (result > INT_MAX) || (result < INT_MIN)) { - UTILS_LOGD("call StrToInt func false, input str is: %{public}s!", str.c_str()); return false; } @@ -122,13 +121,11 @@ bool StrToInt(const string& str, int& value) bool IsNumericStr(const string& str) { if (str.empty()) { - UTILS_LOGD("call IsNumericStr func, input str is empty!"); return false; } for (const auto& c : str) { if (!isdigit(c)) { - UTILS_LOGD("call IsNumericStr func false, input str is: %{public}s!", str.c_str()); return false; } } @@ -139,13 +136,11 @@ bool IsNumericStr(const string& str) bool IsAlphaStr(const string& str) { if (str.empty()) { - UTILS_LOGD("call IsAlphaStr func, input str is empty!"); return false; } for (const auto& c : str) { if (!isalpha(c)) { - UTILS_LOGD("call IsAlphaStr func false, input str is: %{public}s!", str.c_str()); return false; } } @@ -156,13 +151,11 @@ bool IsAlphaStr(const string& str) bool IsUpperStr(const string& str) { if (str.empty()) { - UTILS_LOGD("call IsUpperStr func, input str is empty!"); return false; } for (const auto& c : str) { if (!isupper(c)) { - UTILS_LOGD("call IsUpperStr func false, input str is: %{public}s!", str.c_str()); return false; } } @@ -173,13 +166,11 @@ bool IsUpperStr(const string& str) bool IsLowerStr(const string& str) { if (str.empty()) { - UTILS_LOGD("call IsLowerStr func, input str is empty!"); return false; } for (const auto& c : str) { if (!islower(c)) { - UTILS_LOGD("call IsLowerStr func false, input str is: %{public}s!", str.c_str()); return false; } } diff --git a/base/src/thread_ex.cpp b/base/src/thread_ex.cpp index e9181d466e29ce3f8546c0e1ef3611a700ada3e1..53e646124b9bb0749fbe6c8bf9017f1862ee1bde 100644 --- a/base/src/thread_ex.cpp +++ b/base/src/thread_ex.cpp @@ -33,7 +33,7 @@ struct ThreadParam { static int proxy(const ThreadParam* t) { if (t == nullptr) { - UTILS_LOGE("invalid param."); + UTILS_LOGD("invalid param."); return -1; } ThreadFunc f = t->startRoutine; diff --git a/base/src/unicode_ex.cpp b/base/src/unicode_ex.cpp index e92db9893a959423a0b38b1b02aebb8408e60e9a..b5ee372e442c72a91c327579d3b479cb035cd648 100644 --- a/base/src/unicode_ex.cpp +++ b/base/src/unicode_ex.cpp @@ -186,7 +186,7 @@ bool String16ToString8(const u16string& str16, string& str8) char* str8Temp = Char16ToChar8(str16.c_str(), str16Len); if (str8Temp == nullptr) { - UTILS_LOGE("Str16 to str8 failed, because str8Temp is nullptr!"); + UTILS_LOGD("Str16 to str8 failed, because str8Temp is nullptr!"); return false; } @@ -337,7 +337,7 @@ bool String8ToString16(const string& str8, u16string& str16) char16_t* str16Temp = Char8ToChar16(str8.c_str(), str8len); if (str16Temp == nullptr) { - UTILS_LOGE("str8 to str16 failed, str16Temp is nullptr!"); + UTILS_LOGD("str8 to str16 failed, str16Temp is nullptr!"); return false; }