From c29340be8a1f640d3e002aec77e532a2dfbfdea8 Mon Sep 17 00:00:00 2001 From: shuaijie Date: Tue, 30 Jul 2024 17:25:19 +0800 Subject: [PATCH] fix: unvail "error,fail" log output due to app_error list Log: modify "error,fail" to unsucess in logdata --- deepin-system-monitor-main/3rdparty/include/closestream.h | 4 ++-- deepin-system-monitor-main/common/common.h | 6 +++--- deepin-system-monitor-main/dbus/dbusalarmnotify.cpp | 4 ++-- .../gui/dialog/systemprotectionsetting.cpp | 4 ++-- deepin-system-monitor-main/process/process.cpp | 3 ++- deepin-system-monitor-main/process/process_set.cpp | 2 +- deepin-system-monitor-main/service/service_manager.cpp | 2 +- deepin-system-monitor-main/system/cpu_set.cpp | 2 +- deepin-system-monitor-main/system/diskio_info.cpp | 2 +- deepin-system-monitor-main/system/mem.cpp | 2 +- deepin-system-monitor-main/system/net_info.cpp | 2 +- deepin-system-monitor-main/system/netif_packet_capture.cpp | 2 +- deepin-system-monitor-main/system/sys_info.cpp | 2 +- deepin-system-monitor-plugin-popup/process/process.cpp | 2 +- deepin-system-monitor-plugin-popup/system/cpu_set.cpp | 2 +- helper.hpp | 5 ++++- 16 files changed, 25 insertions(+), 21 deletions(-) diff --git a/deepin-system-monitor-main/3rdparty/include/closestream.h b/deepin-system-monitor-main/3rdparty/include/closestream.h index a674da1c..0973d740 100644 --- a/deepin-system-monitor-main/3rdparty/include/closestream.h +++ b/deepin-system-monitor-main/3rdparty/include/closestream.h @@ -67,9 +67,9 @@ close_stdout(void) { if (flush_standard_stream(stdout) != 0 && !(errno == EPIPE)) { if (errno) - warn(_("write error")); + warn(_("write unsuccess")); else - warnx(_("write error")); + warnx(_("write unsuccess")); _exit(CLOSE_EXIT_CODE); } diff --git a/deepin-system-monitor-main/common/common.h b/deepin-system-monitor-main/common/common.h index 5701effb..f4afe7c2 100644 --- a/deepin-system-monitor-main/common/common.h +++ b/deepin-system-monitor-main/common/common.h @@ -144,14 +144,14 @@ QString formatHz(quint32 freq, HzUnit base = KHz, int prec = 2); } // namespace format -namespace error { +namespace print { inline void print_errno(decltype(errno) e, const QString msg) { - qCWarning(app) << QString("Error: [%1] %2, ").arg(e).arg(strerror(e)) << msg; + qCWarning(app) << QString("unsuccess: [%1] %2, ").arg(e).arg(strerror(e)) << msg; } -} // namespace error +} // namespace print namespace time { diff --git a/deepin-system-monitor-main/dbus/dbusalarmnotify.cpp b/deepin-system-monitor-main/dbus/dbusalarmnotify.cpp index 38eba532..e468a892 100644 --- a/deepin-system-monitor-main/dbus/dbusalarmnotify.cpp +++ b/deepin-system-monitor-main/dbus/dbusalarmnotify.cpp @@ -82,8 +82,8 @@ void DBusAlarmNotify::showAlarmNotify(QString topic, QString msg, int timeout) QDBusMessage replyMsg = QDBusConnection::sessionBus().call(ddeNotify); if (replyMsg.type() == QDBusMessage::ErrorMessage) { - qCWarning(app) << __FUNCTION__ << __LINE__ << ", dde notify dbus method call fail , error name :" - << replyMsg.errorName() << " , error msg :" << replyMsg.errorMessage(); + qCWarning(app) << __FUNCTION__ << __LINE__ << ", dde notify dbus method call unsuccess , unsuccess name :" + << replyMsg.errorName() << " , unsuccess msg :" << replyMsg.errorMessage(); QString cmd = QString("gdbus call -e -d org.deepin.SystemMonitorDaemon -o /org/deepin/SystemMonitorDaemon -m org.deepin.SystemMonitorDaemon.setAlaramLastTimeInterval 0"); QProcess::startDetached(cmd); } else { diff --git a/deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp b/deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp index a6d20bd1..deadc0a1 100644 --- a/deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp +++ b/deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp @@ -486,7 +486,7 @@ void SystemProtectionSetting::onMessgaeSetting(QVariant value) QDBusMessage replyMsg = QDBusConnection::sessionBus().call(showDDEControlCenterPage); if (replyMsg.type() == QDBusMessage::ErrorMessage) { - qCWarning(app) << __FUNCTION__ << __LINE__ << ", dde control center dbus method call fail , error name :" + qCWarning(app) << __FUNCTION__ << __LINE__ << ", dde control center dbus method call unsuccess , unsuccess name :" << replyMsg.errorName() << " , error msg :" << replyMsg.errorMessage(); } @@ -514,7 +514,7 @@ void SystemProtectionSetting::onMessgaeSetting(QVariant value) QDBusMessage replyMsg = QDBusConnection::sessionBus().call(showDDEControlCenter); if (replyMsg.type() == QDBusMessage::ErrorMessage) { - qCWarning(app) << __FUNCTION__ << __LINE__ << ", dde control center dbus method call fail , error name :" + qCWarning(app) << __FUNCTION__ << __LINE__ << ", dde control center dbus method call unsuccess , unsuccess name :" << replyMsg.errorName() << " , error msg :" << replyMsg.errorMessage(); } } diff --git a/deepin-system-monitor-main/process/process.cpp b/deepin-system-monitor-main/process/process.cpp index b47b204e..cb8c7337 100644 --- a/deepin-system-monitor-main/process/process.cpp +++ b/deepin-system-monitor-main/process/process.cpp @@ -40,7 +40,7 @@ using namespace common::alloc; using namespace common::init; using namespace common::core; -using namespace common::error; +using namespace common::print; using namespace core::system; namespace core { @@ -597,6 +597,7 @@ void Process::readIO() // scan each line while (fgets(buf, bsiz, fp.get())) { + if (errno != 0) return; if (!strncmp(buf, "read_bytes", 10)) { sscanf(buf + 12, "%llu", &d->read_bytes); } else if (!strncmp(buf, "write_bytes", 11)) { diff --git a/deepin-system-monitor-main/process/process_set.cpp b/deepin-system-monitor-main/process/process_set.cpp index fefd01df..6b0f3c1d 100644 --- a/deepin-system-monitor-main/process/process_set.cpp +++ b/deepin-system-monitor-main/process/process_set.cpp @@ -15,7 +15,7 @@ #define PROC_PATH "/proc" -using namespace common::error; +using namespace common::print; namespace core { namespace process { diff --git a/deepin-system-monitor-main/service/service_manager.cpp b/deepin-system-monitor-main/service/service_manager.cpp index 4f05be1e..25caffaa 100644 --- a/deepin-system-monitor-main/service/service_manager.cpp +++ b/deepin-system-monitor-main/service/service_manager.cpp @@ -61,7 +61,7 @@ static bool setServiceEnable(const QString &servieName, bool enable, QString &er } if (!errorString.isEmpty()) { - qCWarning(app) << QString("Set service %1 failed, error %1").arg(enable ? "enable" : "disable").arg(errorString); + qCWarning(app) << QString("Set service %1 failed, unsuccess %1").arg(enable ? "enable" : "disable").arg(errorString); return false; } else { qCDebug(app) << QString("Set service %1 ret: %2").arg(enable ? "enable" : "disable").arg(retMsg.value()); diff --git a/deepin-system-monitor-main/system/cpu_set.cpp b/deepin-system-monitor-main/system/cpu_set.cpp index ca550f95..6c3c707f 100644 --- a/deepin-system-monitor-main/system/cpu_set.cpp +++ b/deepin-system-monitor-main/system/cpu_set.cpp @@ -30,7 +30,7 @@ extern "C" { #define PROC_PATH_STAT "/proc/stat" #define PROC_PATH_CPUINFO "/proc/cpuinfo" -using namespace common::error; +using namespace common::print; using namespace common::alloc; using namespace common::init; using namespace DDLog; diff --git a/deepin-system-monitor-main/system/diskio_info.cpp b/deepin-system-monitor-main/system/diskio_info.cpp index 843bb273..a386ff07 100644 --- a/deepin-system-monitor-main/system/diskio_info.cpp +++ b/deepin-system-monitor-main/system/diskio_info.cpp @@ -13,7 +13,7 @@ #include -using namespace common::error; +using namespace common::print; using namespace common::alloc; namespace core { diff --git a/deepin-system-monitor-main/system/mem.cpp b/deepin-system-monitor-main/system/mem.cpp index 3c945cf5..26cd72ae 100644 --- a/deepin-system-monitor-main/system/mem.cpp +++ b/deepin-system-monitor-main/system/mem.cpp @@ -11,7 +11,7 @@ #define PROC_PATH_MEM "/proc/meminfo" -using namespace common::error; +using namespace common::print; using namespace common::alloc; namespace core { diff --git a/deepin-system-monitor-main/system/net_info.cpp b/deepin-system-monitor-main/system/net_info.cpp index 4e3eee7b..796bdfaa 100644 --- a/deepin-system-monitor-main/system/net_info.cpp +++ b/deepin-system-monitor-main/system/net_info.cpp @@ -9,7 +9,7 @@ #include -using namespace common::error; +using namespace common::print; namespace core { namespace system { diff --git a/deepin-system-monitor-main/system/netif_packet_capture.cpp b/deepin-system-monitor-main/system/netif_packet_capture.cpp index ef59de45..b0080a39 100644 --- a/deepin-system-monitor-main/system/netif_packet_capture.cpp +++ b/deepin-system-monitor-main/system/netif_packet_capture.cpp @@ -93,7 +93,7 @@ bool NetifPacketCapture::hasDevIP() //获取网络IP(IPv4) if (ioctl(sockfd, SIOCGIFADDR, &ifr) == -1) { close(sockfd); - //qCDebug(app)<<"ioctl error!"; + //qCDebug(app)<<"ioctl unsuccess!"; return false; } diff --git a/deepin-system-monitor-main/system/sys_info.cpp b/deepin-system-monitor-main/system/sys_info.cpp index b8ce4117..eb3a91b0 100644 --- a/deepin-system-monitor-main/system/sys_info.cpp +++ b/deepin-system-monitor-main/system/sys_info.cpp @@ -36,7 +36,7 @@ using namespace common::alloc; using namespace common::core; -using namespace common::error; +using namespace common::print; using namespace core::system; DCORE_USE_NAMESPACE diff --git a/deepin-system-monitor-plugin-popup/process/process.cpp b/deepin-system-monitor-plugin-popup/process/process.cpp index 773a8f40..629588ac 100644 --- a/deepin-system-monitor-plugin-popup/process/process.cpp +++ b/deepin-system-monitor-plugin-popup/process/process.cpp @@ -40,7 +40,7 @@ using namespace common::alloc; using namespace common::init; using namespace common::core; -using namespace common::error; +using namespace common::print; using namespace core::system; namespace core { diff --git a/deepin-system-monitor-plugin-popup/system/cpu_set.cpp b/deepin-system-monitor-plugin-popup/system/cpu_set.cpp index cc6faf1f..95bfd83a 100644 --- a/deepin-system-monitor-plugin-popup/system/cpu_set.cpp +++ b/deepin-system-monitor-plugin-popup/system/cpu_set.cpp @@ -26,7 +26,7 @@ #define PROC_PATH_STAT "/proc/stat" #define PROC_PATH_CPUINFO "/proc/cpuinfo" -using namespace common::error; +using namespace common::print; using namespace common::alloc; namespace core { diff --git a/helper.hpp b/helper.hpp index 7e853800..2d015223 100644 --- a/helper.hpp +++ b/helper.hpp @@ -4,10 +4,13 @@ // SPDX-License-Identifier: GPL-3.0-or-later #pragma once +#include "ddlog.h" #include #include +using namespace DDLog; + namespace common{ class SystemState { @@ -148,7 +151,7 @@ static inline const SystemState &systemInfo() static SystemState *state = nullptr; if (!state) { const auto version = DTK_CORE_NAMESPACE::DSysInfo::majorVersion(); - qInfo() << "Running desktop environment version is:" << version << ", versionNumber:" << version.toLong(); + qCInfo(app) << "Running desktop environment version is:" << version << ", versionNumber:" << version.toLong(); if (!version.isEmpty() && version.toLong() <= 20) { state = new V20SystemState(); state->updateVersion(true);