Skip to content

Commit

Permalink
feat: Adaptation log specification rectification
Browse files Browse the repository at this point in the history
 Adaptation log specification rectification

Log: Adaptation log specification rectification
Task: https://pms.uniontech.com/task-view-292081.html
  • Loading branch information
starhcq committed Oct 9, 2023
1 parent 68f2406 commit 12136a8
Show file tree
Hide file tree
Showing 27 changed files with 134 additions and 158 deletions.
40 changes: 20 additions & 20 deletions 3rdparty/DocxFactory/src/locale/LocaleFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,14 +1018,14 @@ double LocaleFunc::strToNum(const string &p_str)
if (!m_initialized)
initialize();

enum Part {
PREFIX = 0,
INTEGER,
FRACTION,
SUFFIX
enum _Part {
_PREFIX = 0,
_INTEGER,
_FRACTION,
_SUFFIX
};

Part l_part = PREFIX;
_Part l_part = _PREFIX;
double l_val = 0;
double l_dec = 1;
char l_neg = 0;
Expand All @@ -1041,54 +1041,54 @@ double LocaleFunc::strToNum(const string &p_str)
if (l_neg != 0)
break;

if (l_part == INTEGER || l_part == FRACTION)
l_part = SUFFIX;
if (l_part == _INTEGER || l_part == _FRACTION)
l_part = _SUFFIX;

l_neg = l_ch;
}

else if (l_ch == ' '

// if thousand separator is also space then treated as space only in prefix and suffix.
&& (m_numThSep != ' ' || l_part == PREFIX || l_part == SUFFIX)) {
if (l_part == INTEGER || l_part == FRACTION)
l_part = SUFFIX;
&& (m_numThSep != ' ' || l_part == _PREFIX || l_part == _SUFFIX)) {
if (l_part == _INTEGER || l_part == _FRACTION)
l_part = _SUFFIX;

if (l_part == SUFFIX && l_neg != 0)
if (l_part == _SUFFIX && l_neg != 0)
break;
}

else if (IS_DIGIT(l_ch)) {
if (l_part == PREFIX)
l_part = INTEGER;
if (l_part == _PREFIX)
l_part = _INTEGER;

switch (l_part) {
case INTEGER:
case _INTEGER:
l_val = l_val * 10 + (l_ch - 48);
break;

case FRACTION:
case _FRACTION:
l_dec = l_dec * 10;
l_val = l_val + (l_ch - 48) / l_dec;
break;
default:
break;
}

if (l_part == SUFFIX)
if (l_part == _SUFFIX)
break;
}

else if (l_ch == m_numFracSep) {
if (l_part == PREFIX || l_part == INTEGER)
l_part = FRACTION;
if (l_part == _PREFIX || l_part == _INTEGER)
l_part = _FRACTION;

else
break;
}

else if (l_ch == m_numThSep) {
if (l_part != INTEGER && l_part != FRACTION)
if (l_part != _INTEGER && l_part != _FRACTION)
break;
}

Expand Down
3 changes: 3 additions & 0 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ install(FILES assets/auditRule.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/de
# Install cli script deepin-logger
install(FILES assets/deepin-logger DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

# Install log json config file.
install(FILES assets/deepin-log-viewer.json DESTINATION ${CMAKE_INSTALL_PREFIX}/share/deepin-log-viewer/deepin-log.conf.d)

#FILES - deployed files.
#BASE - used to get subpath, if it's empty, only copy files, and ignore it's subpath structure.
#APPID - working for the app.
Expand Down
8 changes: 8 additions & 0 deletions application/assets/deepin-log-viewer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "deepin-log-viewer",
"exec": "/usr/bin/deepin-log-viewer",
"logType": "journal",
"logPath": "~/.cache/deepin/deepin-log-viewer/deepin-log-viewer.log",
"visible": "1",
"version": "V1.0"
}
8 changes: 4 additions & 4 deletions application/dbusproxy/dldbushandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,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()) {
qDebug() << "dbus com.deepin.logviewer isValid false error:" << m_dbus->lastError() << m_dbus->lastError().message();
qCritical() << "dbus com.deepin.logviewer isValid false error:" << m_dbus->lastError() << m_dbus->lastError().message();
}
qDebug() << "dbus com.deepin.logviewer isValid true";
qInfo() << "dbus com.deepin.logviewer isValid true";
}

/*!
Expand Down Expand Up @@ -77,7 +77,7 @@ QStringList DLDBusHandler::getFileInfo(const QString &flag, bool unzip)
QDBusPendingReply<QStringList> reply = m_dbus->getFileInfo(flag, unzip);
reply.waitForFinished();
if (reply.isError()) {
qDebug() << reply.error().message();
qWarning() << "call dbus iterface 'getFileInfo()' failed. error info:" << reply.error().message();
} else {
filePath = reply.value();
}
Expand All @@ -90,7 +90,7 @@ QStringList DLDBusHandler::getOtherFileInfo(const QString &flag, bool unzip)
reply.waitForFinished();
QStringList filePathList;
if (reply.isError()) {
qDebug() << reply.error().message();
qWarning() << "call dbus iterface 'getOtherFileInfo()' failed. error info:" << reply.error().message();
} else {
filePathList = reply.value();
}
Expand Down
19 changes: 3 additions & 16 deletions application/displaycontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,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) {
qDebug() << "repeat refrsh journal too fast!";
qWarning() << "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 @@ -1481,12 +1481,6 @@ void DisplayContent::slot_tableItemClicked(const QModelIndex &index)
*/
void DisplayContent::slot_BtnSelected(int btnId, int lId, QModelIndex idx)
{
qDebug() << QString("Button %1 clicked\n combobox: level is %2, cbxIdx is %3 tree %4 node!!")
.arg(btnId)
.arg(lId)
.arg(lId + 1)
.arg(idx.data(ITEM_DATE_ROLE).toString());

m_curLevel = lId; // m_curLevel equal combobox index-1;
m_curBtnId = btnId;

Expand Down Expand Up @@ -1551,7 +1545,6 @@ void DisplayContent::slot_logCatelogueClicked(const QModelIndex &index)
}

if (m_curListIdx == index && (m_flag != KERN && m_flag != BOOT)) {
qDebug() << "repeat click" << m_flag;
return;
}
m_currentKwinFilter = {""};
Expand Down Expand Up @@ -1665,7 +1658,7 @@ void DisplayContent::slot_exportClicked()
if (!fi.isWritable()) {
exportThread->sigResult(false);
delete exportThread;
qInfo() << QString("outdir:%1 is not writable.").arg(fi.absoluteFilePath());
qCritical() << QString("outdir:%1 is not writable.").arg(fi.absoluteFilePath());
return;
}

Expand Down Expand Up @@ -2338,7 +2331,6 @@ void DisplayContent::slot_vScrollValueChanged(int valuePixel)
int leftCnt = jList.count() - SINGLE_LOAD * rateValue;
//如果在页尾部则只加载最后一页的数量,否则加载单页全部数量
int end = leftCnt > SINGLE_LOAD ? SINGLE_LOAD : leftCnt;
qDebug() << "rate" << rateValue;
//把数据加入model中
insertJournalTable(jList, SINGLE_LOAD * rateValue, SINGLE_LOAD * rateValue + end);

Expand All @@ -2355,7 +2347,6 @@ void DisplayContent::slot_vScrollValueChanged(int valuePixel)
int leftCnt = jBootList.count() - SINGLE_LOAD * rateValue;
int end = leftCnt > SINGLE_LOAD ? SINGLE_LOAD : leftCnt;

qDebug() << "rate" << rateValue;
insertJournalBootTable(jBootList, SINGLE_LOAD * rateValue, SINGLE_LOAD * rateValue + end);
m_limitTag = rateValue;
m_treeView->verticalScrollBar()->setValue(valuePixel);
Expand Down Expand Up @@ -2539,11 +2530,8 @@ void DisplayContent::slot_vScrollValueChanged(int valuePixel)
* @brief DisplayContent::slot_searchResult 搜索框执行搜索槽函数
* @param str 要搜索的关键字
*/
void DisplayContent::slot_searchResult(QString str)
void DisplayContent::slot_searchResult(const QString &str)
{
qDebug() << QString("search: %1 treeIndex: %2")
.arg(str)
.arg(m_curListIdx.data(ITEM_DATE_ROLE).toString());
m_currentSearchStr = str;
if (m_flag == NONE)
return;
Expand Down Expand Up @@ -3300,7 +3288,6 @@ QList<LOG_MSG_BOOT> DisplayContent::filterBoot(BOOT_FILTERS ibootFilter, const Q
for (int i = 0; i < iList.size(); i++) {
LOG_MSG_BOOT msg = iList.at(i);
QString _statusStr = msg.status;
qDebug() << "xxx" << msg.msg.contains(ibootFilter.searchstr, Qt::CaseInsensitive) << "--" << msg.msg;
if ((_statusStr.compare(ibootFilter.statusFilter, Qt::CaseInsensitive) != 0) && !isStatusFilterEmpty)
continue;
if ((msg.status.contains(ibootFilter.searchstr, Qt::CaseInsensitive)) || (msg.msg.contains(ibootFilter.searchstr, Qt::CaseInsensitive))) {
Expand Down
2 changes: 1 addition & 1 deletion application/displaycontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public slots:
void slot_logLoadFailed(const QString &iError);
void slot_vScrollValueChanged(int valuePixel);

void slot_searchResult(QString str);
void slot_searchResult(const QString &str);
void slot_getLogtype(int tcbx); // add by Airy
void slot_getAuditType(int tcbx);
void slot_refreshClicked(const QModelIndex &index); //add by Airy for adding refresh
Expand Down
3 changes: 0 additions & 3 deletions application/filtercontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,6 @@ void FilterContent::slot_cbxAppIdxChanged(int idx)
setChangedcomboxstate(!getLeftButtonState());
QString path = cbx_app->itemData(idx, Qt::UserRole + 1).toString();
FILTER_CONFIG curConfig = m_config.value(m_currentType);
qDebug() << "apppath" << path;
curConfig.appListCbx = path;
//变化时改变记录选择选项的数据结构,以便下次还原
setCurrentConfig(curConfig);
Expand Down Expand Up @@ -832,7 +831,6 @@ void FilterContent::slot_cbxLogTypeChanged(int idx)
curConfig.typeCbx = idx;
setCurrentConfig(curConfig);
emit sigLogtypeChanged(idx);
qDebug() << "emit signal " + QString::number(idx);
}

void FilterContent::slot_cbxAuditTypeChanged(int idx)

Check warning on line 836 in application/filtercontent.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'slot_cbxAuditTypeChanged' is never used.
Expand All @@ -842,7 +840,6 @@ void FilterContent::slot_cbxAuditTypeChanged(int idx)
curConfig.auditCbx = idx;
setCurrentConfig(curConfig);
emit sigAuditTypeChanged(idx);
qDebug() << "auditType emit signal " + QString::number(idx);
}

/**
Expand Down
18 changes: 9 additions & 9 deletions application/journalbootwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ JournalBootWork::~JournalBootWork()
void JournalBootWork::stopWork()
{
m_canRun = false;
qDebug() << "stopWorkb";
qDebug() << "stopWork";
}

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ void JournalBootWork::setArg(QStringList arg)
*/
void JournalBootWork::run()
{
qDebug() << "JournalBootWork::run----threadrun";
qDebug() << "threadrun";
doWork();

}
Expand Down Expand Up @@ -148,7 +148,7 @@ void JournalBootWork::doWork()
//r为系统借口返回值,小于0则表示失败,直接返回
if (r < 0) {
QString errostr = QString("Failed to open journal: %1").arg(r);
qDebug() << errostr;
qWarning() << errostr;
emit journalBootError(errostr);
return;
}
Expand All @@ -157,7 +157,7 @@ void JournalBootWork::doWork()

if (r < 0) {
QString errostr = QString("Failed to seek tail journal: %1").arg(r);
qDebug() << errostr;
qWarning() << errostr;
emit journalBootError(errostr);
return;
}
Expand All @@ -174,7 +174,7 @@ void JournalBootWork::doWork()
r = sd_journal_add_match(j, m_arg.at(0).toStdString().c_str(), 0);
if (r < 0) {
QString errostr = QString("Failed to add match journal: %1").arg(r);
qDebug() << errostr;
qWarning() << errostr;
emit journalBootError(errostr);
return;
}
Expand All @@ -201,20 +201,20 @@ void JournalBootWork::doWork()
sd_journal_close(j);
return;
}
qDebug() << "match" << match;
qDebug() << "journal match condition:" << match;
//增加筛选条件
r = sd_journal_add_match(j, match, sizeof(match) - 1);
if (r < 0) {
QString errostr = QString("Failed to add match journal: %1").arg(r);
qDebug() << errostr;
qWarning() << errostr;
emit journalBootError(errostr);
return;
}
//合并以上两个筛选条件 (等级和bootid)
r = sd_journal_add_conjunction(j);
if (r < 0) {
QString errostr = QString("Failed to add conjunction journal: %1").arg(r);
qDebug() << errostr;
qWarning() << errostr;
emit journalBootError(errostr);
return;
}
Expand Down Expand Up @@ -276,7 +276,7 @@ void JournalBootWork::doWork()
r = sd_journal_get_data(j, "_COMM", reinterpret_cast<const void **>(&d), &l);
if (r < 0) {
logMsg.daemonName = "unknown";
qDebug() << logMsg.daemonId << "error code" << r;
qWarning() << logMsg.daemonId << "error code" << r;
} else {
QStringList strList = getReplaceColorStr(d).split("=");
strList.removeFirst();
Expand Down
5 changes: 2 additions & 3 deletions application/journalwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void journalWork::setArg(QStringList arg)
*/
void journalWork::run()
{
qDebug() << "journalWork::run--------threadrun";
qDebug() << "threadrun";
doWork();

}
Expand Down Expand Up @@ -174,7 +174,6 @@ void journalWork::doWork()
return;
}
int cnt = 0;

Check warning on line 176 in application/journalwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Condition 'cnt%500==0' is always false
qDebug() << "m_arg" << m_arg;
//调用宏开始迭代
SD_JOURNAL_FOREACH_BACKWARDS(j) {
if ((!m_canRun)) {

Check warning on line 179 in application/journalwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Condition '!m_canRun' is always false
Expand Down Expand Up @@ -226,7 +225,7 @@ void journalWork::doWork()
r = sd_journal_get_data(j, "_COMM", reinterpret_cast<const void **>(&d), &l);
if (r < 0) {
logMsg.daemonName = "unknown";
qDebug() << logMsg.daemonId << "error code" << r;
qWarning() << logMsg.daemonId << "error code" << r;
} else {
QStringList strList = getReplaceColorStr(d).split("=");
strList.removeFirst();
Expand Down
2 changes: 1 addition & 1 deletion application/logallexportthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void LogAllExportThread::run()
qInfo() << "outFile: " << m_outfile;
QFileInfo info(m_outfile);
if (!QFileInfo(info.path()).isWritable()) {
qInfo() << QString("outdir:%1 it not writable or is not exist.").arg(info.absolutePath());
qCritical() << QString("outdir:%1 it not writable or is not exist.").arg(info.absolutePath());
emit exportFinsh(false);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion application/logapplicationparsethread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,6 @@ void LogApplicationParseThread::initProccess()
*/
void LogApplicationParseThread::run()
{
qDebug() << "LogApplicationParseThread::run()---threadrun";
qDebug() << "threadrun";
doWork();
}
3 changes: 0 additions & 3 deletions application/logauththread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ QString LogAuthThread::startTime()
startFile.close();
}

qDebug() << "startStr" << startFile;
startStr = startStr.split(" ").value(0, "");
if (startStr.isEmpty()) {
return "";
Expand Down Expand Up @@ -226,7 +225,6 @@ void LogAuthThread::handleBoot()
QStringList strList = byte.split('\n', QString::SkipEmptyParts);

//按换行分割
// qInfo()<<strList.size()<<"_________________________";
for (int j = strList.size() - 1; j >= 0; --j) {
QString lineStr = strList.at(j);
if (lineStr.startsWith("/dev") || lineStr.isEmpty())
Expand Down Expand Up @@ -624,7 +622,6 @@ void LogAuthThread::handleDkpg()

void LogAuthThread::handleNormal()
{
qDebug() << "logAuthThread::handleNormal()";
if (!m_canRun) {
emit normalFinished(m_threadCount);
return;
Expand Down
Loading

0 comments on commit 12136a8

Please sign in to comment.