Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add app log category #196

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions application/DebugTimeManager.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "DebugTimeManager.h"
#include <QDateTime>
#include <QDebug>
#include <QLoggingCategory>

#include <sys/time.h>
#include <time.h>

#ifdef QT_DEBUG
Q_LOGGING_CATEGORY(logDebugTime, "log.viewer.debug.timemanager")
#else
Q_LOGGING_CATEGORY(logDebugTime, "log.viewer.debug.timemanager", QtInfoMsg)
#endif

DebugTimeManager::DebugTimeManager()
{

Expand Down Expand Up @@ -43,7 +50,7 @@ void DebugTimeManager::endPointLinux(const QString &point, const QString &status
return;
}
timespec diffTime = diff(m_MapLinuxPoint[point].time, endTime);
qInfo() << QString("[GRABPOINT] %1 %2 %3 time=%4s").arg(point).arg(m_MapLinuxPoint[point].desc).arg(status).arg(QString::number((diffTime.tv_sec * 1000 + (diffTime.tv_nsec) / 1000000) / 1000.0, 'g', 4));
qCInfo(logDebugTime) << QString("[GRABPOINT] %1 %2 %3 time=%4s").arg(point).arg(m_MapLinuxPoint[point].desc).arg(status).arg(QString::number((diffTime.tv_sec * 1000 + (diffTime.tv_nsec) / 1000000) / 1000.0, 'g', 4));
m_MapLinuxPoint.remove(point);
}
}
Expand Down
2 changes: 1 addition & 1 deletion application/cliapplicationhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using HelperCreator = CliApplicationHelper::HelperCreator;

#ifdef QT_DEBUG
Q_LOGGING_CATEGORY(dgAppHelper, "deepin-logger")
Q_LOGGING_CATEGORY(dgAppHelper, "deepin.logger")
#else
Q_LOGGING_CATEGORY(dgAppHelper, "deepin.logger", QtInfoMsg)
#endif
Expand Down
19 changes: 13 additions & 6 deletions application/dbusmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -10,6 +10,13 @@
#include <QDBusInterface>
#include <QDBusReply>
#include <QDebug>
#include <QLoggingCategory>

#ifdef QT_DEBUG
Q_LOGGING_CATEGORY(logDBusManager, "log.viewer.dbus.manager")
#else
Q_LOGGING_CATEGORY(logDBusManager, "log.viewer.dbus.manager", QtInfoMsg)
#endif

bool DBusManager::isGetedKlu = false;
QString DBusManager::isklusystemName = "";
Expand Down Expand Up @@ -41,7 +48,7 @@ QString DBusManager::getSystemInfo()
.property("ProductName")
.toString();
} else {
qWarning() << "Unknown OS version:" << osVersion;
qCWarning(logDBusManager) << "Unknown OS version:" << osVersion;
}
isGetedKlu = true;
}
Expand All @@ -55,14 +62,14 @@ bool DBusManager::isSEOepn()
if (interfaceSE.isValid()) {
QDBusReply<QString> reply = interfaceSE.call(QStringLiteral("Status"));
if (!reply.error().message().isEmpty())
qWarning() << qPrintable(QString("com.deepin.daemon.SecurityEnhance.Status DBus error: %1").arg(reply.error().message()));
qCWarning(logDBusManager) << qPrintable(QString("com.deepin.daemon.SecurityEnhance.Status DBus error: %1").arg(reply.error().message()));

if (reply.value() == "close")
bIsSEOpen = false;
else
bIsSEOpen = true;
} else {
qWarning() << qPrintable(QString("isSEOpen failed! interface error: %1").arg(interfaceSE.lastError().message()));
qCWarning(logDBusManager) << qPrintable(QString("isSEOpen failed! interface error: %1").arg(interfaceSE.lastError().message()));
}

return bIsSEOpen;
Expand All @@ -81,12 +88,12 @@ bool DBusManager::isAuditAdmin()
if (interfaceSE.isValid()) {
QDBusReply<QString> reply = interfaceSE.call(QStringLiteral("GetSEUserByName"), currentUserName);
if (!reply.error().message().isEmpty())
qWarning() << qPrintable(QString("com.deepin.daemon.SecurityEnhance.GetSEUserByName DBus error: %1").arg(reply.error().message()));
qCWarning(logDBusManager) << qPrintable(QString("com.deepin.daemon.SecurityEnhance.GetSEUserByName DBus error: %1").arg(reply.error().message()));

if (reply.value() == "audadm_u" || reply.value() == "auditadm_u")
bIsAuditAdmin = true;
} else {
qWarning() << qPrintable(QString("isAuditAdmin failed! interface error: %1").arg(interfaceSE.lastError().message()));
qCWarning(logDBusManager) << qPrintable(QString("isAuditAdmin failed! interface error: %1").arg(interfaceSE.lastError().message()));
}

return bIsAuditAdmin;
Expand Down
17 changes: 12 additions & 5 deletions application/dbusproxy/dldbushandler.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "dldbushandler.h"
#include <QDebug>
#include <QStandardPaths>
#include <QLoggingCategory>

#ifdef QT_DEBUG
Q_LOGGING_CATEGORY(logDBusHandler, "log.viewer.dbus.handler")
#else
Q_LOGGING_CATEGORY(logDBusHandler, "log.viewer.dbus.handler", QtInfoMsg)
#endif

DLDBusHandler *DLDBusHandler::m_statichandeler = nullptr;

Expand All @@ -30,9 +37,9 @@ DLDBusHandler::DLDBusHandler(QObject *parent)
this);
//Note: when dealing with remote objects, it is not always possible to determine if it exists when creating a QDBusInterface.
if (!m_dbus->isValid() && !m_dbus->lastError().message().isEmpty()) {
qCritical() << "dbus com.deepin.logviewer isValid false error:" << m_dbus->lastError() << m_dbus->lastError().message();
qCCritical(logDBusHandler) << "dbus com.deepin.logviewer isValid false error:" << m_dbus->lastError() << m_dbus->lastError().message();
}
qInfo() << "dbus com.deepin.logviewer isValid true";
qCInfo(logDBusHandler) << "dbus com.deepin.logviewer isValid true";
}

/*!
Expand Down Expand Up @@ -77,7 +84,7 @@ QStringList DLDBusHandler::getFileInfo(const QString &flag, bool unzip)
QDBusPendingReply<QStringList> reply = m_dbus->getFileInfo(flag, unzip);
reply.waitForFinished();
if (reply.isError()) {
qWarning() << "call dbus iterface 'getFileInfo()' failed. error info:" << reply.error().message();
qCWarning(logDBusHandler) << "call dbus iterface 'getFileInfo()' failed. error info:" << reply.error().message();
} else {
filePath = reply.value();
}
Expand All @@ -90,7 +97,7 @@ QStringList DLDBusHandler::getOtherFileInfo(const QString &flag, bool unzip)
reply.waitForFinished();
QStringList filePathList;
if (reply.isError()) {
qWarning() << "call dbus iterface 'getOtherFileInfo()' failed. error info:" << reply.error().message();
qCWarning(logDBusHandler) << "call dbus iterface 'getOtherFileInfo()' failed. error info:" << reply.error().message();
} else {
filePathList = reply.value();
}
Expand Down
61 changes: 34 additions & 27 deletions application/displaycontent.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -37,11 +37,18 @@
#include <QDateTime>
#include <QFileIconProvider>
#include <QMenu>
#include <QLoggingCategory>

#include <sys/utsname.h>
#include "malloc.h"
DWIDGET_USE_NAMESPACE

#ifdef QT_DEBUG
Q_LOGGING_CATEGORY(logDisplaycontent, "log.viewer.display.content")
#else
Q_LOGGING_CATEGORY(logDisplaycontent, "log.viewer.display.content", QtInfoMsg)
#endif

#define SINGLE_LOAD 300

#define NAME_WIDTH 470
Expand Down Expand Up @@ -305,7 +312,7 @@ void DisplayContent::generateJournalFile(int id, int lId, const QString &iSearch
Q_UNUSED(iSearchStr)
//系统日志上次获取的时间,和筛选条件一起判断,防止获取过于频繁
if (m_lastJournalGetTime.msecsTo(QDateTime::currentDateTime()) < 500 && m_journalFilter.timeFilter == id && m_journalFilter.eventTypeFilter == lId) {
qWarning() << "load journal log: repeat refrsh journal too fast!";
qCWarning(logDisplaycontent) << "load journal log: repeat refrsh journal too fast!";
QItemSelectionModel *p = m_treeView->selectionModel();
if (p)
p->select(m_pModel->index(0, 0), QItemSelectionModel::Rows | QItemSelectionModel::Select);
Expand Down Expand Up @@ -1664,7 +1671,7 @@ void DisplayContent::slot_exportClicked()
if (!fi.isWritable()) {
exportThread->sigResult(false);
delete exportThread;
qCritical() << QString("outdir:%1 is not writable.").arg(fi.absoluteFilePath());
qCCritical(logDisplaycontent) << QString("outdir:%1 is not writable.").arg(fi.absoluteFilePath());
return;
}

Expand Down Expand Up @@ -2716,11 +2723,11 @@ void DisplayContent::slot_getAuditType(int tcbx)
void DisplayContent::parseListToModel(const QList<LOG_MSG_DPKG> &iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
QList<LOG_MSG_DPKG> list = iList;
Expand Down Expand Up @@ -2753,12 +2760,12 @@ void DisplayContent::parseListToModel(const QList<LOG_MSG_DPKG> &iList, QStandar
void DisplayContent::parseListToModel(const QList<LOG_MSG_BOOT> &iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
QList<LOG_MSG_BOOT> list = iList;
Expand Down Expand Up @@ -2786,12 +2793,12 @@ void DisplayContent::parseListToModel(const QList<LOG_MSG_BOOT> &iList, QStandar
void DisplayContent::parseListToModel(QList<LOG_MSG_APPLICATOIN> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
QList<QStandardItem *> items;
Expand Down Expand Up @@ -2835,12 +2842,12 @@ void DisplayContent::parseListToModel(QList<LOG_MSG_APPLICATOIN> iList, QStandar
void DisplayContent::parseListToModel(QList<LOG_MSG_XORG> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
DStandardItem *item = nullptr;
Expand Down Expand Up @@ -2868,12 +2875,12 @@ void DisplayContent::parseListToModel(QList<LOG_MSG_XORG> iList, QStandardItemMo
void DisplayContent::parseListToModel(QList<LOG_MSG_NORMAL> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
DStandardItem *item = nullptr;
Expand Down Expand Up @@ -2909,12 +2916,12 @@ void DisplayContent::parseListToModel(QList<LOG_MSG_NORMAL> iList, QStandardItem
void DisplayContent::parseListToModel(QList<LOG_MSG_KWIN> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
DStandardItem *item = nullptr;
Expand All @@ -2933,12 +2940,12 @@ void DisplayContent::parseListToModel(QList<LOG_MSG_KWIN> iList, QStandardItemMo
void DisplayContent::parseListToModel(QList<LOG_MSG_DNF> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
QList<QStandardItem *> items;
Expand Down Expand Up @@ -2969,12 +2976,12 @@ void DisplayContent::parseListToModel(QList<LOG_MSG_DNF> iList, QStandardItemMod
void DisplayContent::parseListToModel(QList<LOG_MSG_DMESG> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
QList<QStandardItem *> items;
Expand Down Expand Up @@ -3004,12 +3011,12 @@ void DisplayContent::parseListToModel(QList<LOG_MSG_DMESG> iList, QStandardItemM
void DisplayContent::parseListToModel(QList<LOG_FILE_OTHERORCUSTOM> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
QList<QStandardItem *> items;
Expand All @@ -3031,12 +3038,12 @@ void DisplayContent::parseListToModel(QList<LOG_FILE_OTHERORCUSTOM> iList, QStan
void DisplayContent::parseListToModel(QList<LOG_MSG_AUDIT> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
QList<QStandardItem *> items;
Expand Down Expand Up @@ -3072,12 +3079,12 @@ void DisplayContent::parseListToModel(QList<LOG_MSG_AUDIT> iList, QStandardItemM
void DisplayContent::parseListToModel(QList<LOG_MSG_COREDUMP> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
QList<QStandardItem *> items;
Expand Down Expand Up @@ -3528,12 +3535,12 @@ void DisplayContent::onExportProgress(int nCur, int nTotal)
void DisplayContent::parseListToModel(QList<LOG_MSG_JOURNAL> iList, QStandardItemModel *oPModel)
{
if (!oPModel) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}

if (iList.isEmpty()) {
qWarning() << "parse model is Empty" << __LINE__;
qCWarning(logDisplaycontent) << "parse model is Empty" << __LINE__;
return;
}
DStandardItem *item = nullptr;
Expand Down
Loading