Skip to content

Commit

Permalink
feat: 终端日志规范改造 (#301)
Browse files Browse the repository at this point in the history
Description: 终端日志规范改造

Log: 终端日志规范改造
  • Loading branch information
hundundadi authored Oct 7, 2023
1 parent a4870a9 commit 4f4a1f0
Show file tree
Hide file tree
Showing 36 changed files with 211 additions and 246 deletions.
1 change: 0 additions & 1 deletion 3rdparty/terminalwidget/lib/BlockArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ const Block * BlockArray::at(size_t i)
}

if (i > index) {
qDebug() << "BlockArray::at() i > index\n";
return nullptr;
}

Expand Down
23 changes: 11 additions & 12 deletions 3rdparty/terminalwidget/lib/ColorScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,16 +516,16 @@ ColorScheme* KDE3ColorSchemeReader::read()
if ( line.startsWith(QLatin1String("color")) )
{
if (!readColorLine(line,scheme))
qDebug() << "Failed to read KDE 3 color scheme line" << line;
qWarning() << "Failed to read KDE 3 color scheme line" << line;
}
else if ( line.startsWith(QLatin1String("title")) )
{
if (!readTitleLine(line,scheme))
qDebug() << "Failed to read KDE 3 color scheme title line" << line;
qWarning() << "Failed to read KDE 3 color scheme title line" << line;
}
else
{
qDebug() << "KDE 3 color scheme contains an unsupported feature, '" <<
qWarning() << "KDE 3 color scheme contains an unsupported feature, '" <<
line << "'";
}
}
Expand Down Expand Up @@ -614,10 +614,10 @@ void ColorSchemeManager::loadAllColorSchemes()
}

if ( failed > 0 ){
qDebug() << "failed to load " << failed << " color schemes.";
qWarning() << "failed to load " << failed << " color schemes.";
}

qDebug() << "load all color schemes";
qInfo() << "load all color schemes";
//qDebug() << "nativeColorSchemes" << nativeColorSchemes ;
//qDebug() << "kde3ColorSchemes" << kde3ColorSchemes;
_haveLoadedAll = true;
Expand All @@ -644,7 +644,7 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)

if (scheme->name().isEmpty())
{
qDebug() << "color scheme name is not valid.";
qWarning() << "color scheme name is not valid.";
delete scheme;
return false;
}
Expand All @@ -655,7 +655,7 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
_colorSchemes.insert(scheme->name(),scheme);
else
{
qDebug() << "color scheme with name" << scheme->name() << "has already been" <<
qWarning() << "color scheme with name" << scheme->name() << "has already been" <<
"found, ignoring.";
delete scheme;
}
Expand Down Expand Up @@ -705,7 +705,7 @@ bool ColorSchemeManager::loadColorScheme(const QString& filePath)

if (scheme->name().isEmpty())
{
qDebug() << "Color scheme in" << filePath << "does not have a valid name and was not loaded.";
qWarning() << "Color scheme in" << filePath << "does not have a valid name and was not loaded.";
delete scheme;
return false;
}
Expand All @@ -716,7 +716,7 @@ bool ColorSchemeManager::loadColorScheme(const QString& filePath)
}
else
{
qDebug() << "color scheme with name" << schemeName << "has already been" <<
qWarning() << "color scheme with name" << schemeName << "has already been" <<
"found, ignoring.";

delete scheme;
Expand Down Expand Up @@ -781,7 +781,7 @@ bool ColorSchemeManager::deleteColorScheme(const QString& name)
}
else
{
qDebug() << "Failed to remove color scheme -" << path;
qWarning() << "Failed to remove color scheme -" << path;
return false;
}
}
Expand All @@ -794,7 +794,6 @@ bool ColorSchemeManager::deleteColorScheme(const QString& name)
*******************************************************************************/
void ColorSchemeManager::realodColorScheme(const QString &origName)
{
qDebug() << "realodColorScheme:" << origName;
if (!origName.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(origName)) {
return;
}
Expand All @@ -806,7 +805,7 @@ void ColorSchemeManager::realodColorScheme(const QString &origName)
scheme->read(origName);

if (scheme->name().isEmpty()) {
qDebug() << "Color scheme in" << origName << "does not have a valid name and was not loaded.";
qWarning() << "Color scheme in" << origName << "does not have a valid name and was not loaded.";
delete scheme;
return;
}
Expand Down
27 changes: 10 additions & 17 deletions 3rdparty/terminalwidget/lib/HistorySearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
int linesRead = 0;
int linesToRead = endLine - startLine + 1;

qDebug() << "linesToRead:" << linesToRead;

QString stringBackwardsAfterForwards;
QTextStream backwardsAfterForwardsStream(&stringBackwardsAfterForwards);

Expand Down Expand Up @@ -179,7 +177,6 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
m_lastBackwardsPosition = endPosition;
qDebug() << "backwards save m_lastBackwardsPosition2:" << m_lastBackwardsPosition;
}
qDebug() << "endPosition 5!!!!!!!!!!!! == endColumn:" << endPosition;
}
}

Expand All @@ -192,11 +189,8 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
qDebug() << "forwards matchStart:" << matchStart << ", startColumn:" << startColumn;
if (matchStart >= endPosition) {
matchStart = -1;
qDebug() << "forwards matchStart == -1:" << matchStart;
}
} else {
qDebug() << "string:" << string;
qDebug() << "m_lastBackwardsPosition:" << m_lastBackwardsPosition;
qDebug() << "string length:" << string.length() << ", endPosition:" << endPosition;
//考虑了查找结果在第一行的情况
if (0 == startLine && startLine == endLine && endPosition > endColumn) {
Expand Down Expand Up @@ -233,10 +227,10 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
//考虑了查找结果在第一行的情况
if (0 == m_foundStartLine && m_foundStartLine == m_foundEndLine) {
m_lastBackwardsPosition = m_foundStartColumn;
qDebug() << "!!! ready to change m_foundStartColumn: " << m_foundStartColumn;
qDebug() << "!!! ready to change m_foundEndColumn: " << m_foundEndColumn;
qDebug() << "!!! ready to change m_foundStartLine: " << m_foundStartLine;
qDebug() << "!!! ready to change m_foundEndLine: " << m_foundEndLine;
qDebug() << "ready to change m_foundStartColumn: " << m_foundStartColumn;
qDebug() << "ready to change m_foundEndColumn: " << m_foundEndColumn;
qDebug() << "ready to change m_foundStartLine: " << m_foundStartLine;
qDebug() << "ready to change m_foundEndLine: " << m_foundEndLine;
}
else if (-1 == endPosition || -1 == endColumn) {
QString stringAfterSearch;
Expand All @@ -254,18 +248,18 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
decoder.end();

m_lastBackwardsPosition = stringAfterSearch.length() + m_foundStartColumn;
qDebug() << "!!! ready to change m_lastBackwardsPosition: " << m_lastBackwardsPosition;
qDebug() << "ready to change m_lastBackwardsPosition: " << m_lastBackwardsPosition;
}
}

//看看能不能从m_foundEndColumn m_foundEndLine和m_foundStartColumn m_foundStartLine推算出目前查找的字符串index
//在正向查找的时候,保存当前indexOf(search, totalString) 到 m_lastBackwardsPosition
// 总共读了多少行,记录下字符串总长度,加上当前偏移量

qDebug() << "m_foundStartColumn" << m_foundStartColumn
<< "m_foundStartLine" << m_foundStartLine
<< "m_foundEndColumn" << m_foundEndColumn
<< "m_foundEndLine" << m_foundEndLine;
qDebug() << "changed m_foundStartColumn" << m_foundStartColumn
<< "changed m_foundStartLine" << m_foundStartLine
<< "changed m_foundEndColumn" << m_foundEndColumn
<< "changed m_foundEndLine" << m_foundEndLine;

/***add begin by ut001121 zhangmeng 20200515 修复BUG22626***/
/**
Expand All @@ -286,7 +280,6 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
//qDebug() << "loseStart" << loseStart << "loseEnd" << loseEnd ;

// if (loseStart < 0 || loseStart > loseEnd) {
// qDebug() << "========loseStart and loseEnd is not expected" << loseStart << loseEnd;
// exit(-1);
// }

Expand Down Expand Up @@ -333,7 +326,7 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en
linesRead += blockSize;
}

qDebug() << "Not found";
qInfo() << "History Search Not found";
return false;
}

Expand Down
1 change: 0 additions & 1 deletion 3rdparty/terminalwidget/lib/KeyboardTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ KeyboardTranslator* KeyboardTranslatorManager::loadTranslator(const QString& nam
const QString& path = findTranslatorPath(name);

QFile source(path);
qDebug() << __FUNCTION__ << path << endl;
if (name.isEmpty() || !source.open(QIODevice::ReadOnly | QIODevice::Text))
return nullptr;

Expand Down
5 changes: 2 additions & 3 deletions 3rdparty/terminalwidget/lib/encodes/detectcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void DetectCode::icuDetectTextEncoding(const QString &filePath, QByteArrayList &
FILE *file;
file = fopen(filePath.toLocal8Bit().data(), "rb");
if (file == nullptr) {
qInfo() << "fopen file failed.";
qWarning() << "fopen file failed.";
return;
}

Expand Down Expand Up @@ -425,7 +425,7 @@ int DetectCode::ChartDet_DetectingTextCoding(const char *str, QString &encoding,
DetectObj *obj = detect_obj_init();

if (obj == nullptr) {
// qInfo() << "Memory Allocation failed\n";
qWarning() << "Code identification libarary memory allocation failed\n";
return CHARDET_MEM_ALLOCATED_FAIL;
}

Expand All @@ -441,7 +441,6 @@ int DetectCode::ChartDet_DetectingTextCoding(const char *str, QString &encoding,
size_t len = fread(buff, 1, buffer_size, fp);
detect(buff, &obj);
QString encoding = obj->encoding;
qInfo() << "==== encoding: " << encoding;
if (encoding == "") {
continue;
} else if (!encoding.isEmpty()) {
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ install(FILES src/deepin-terminal.desktop
install(FILES src/assets/logo/deepin-terminal.svg
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/)

install(FILES src/assets/logconfig/deepin-terminal.json
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/deepin-log-viewer/deepin-log.conf.d/)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/deepin-terminal
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
PERMISSIONS OWNER_READ OWNER_EXECUTE
Expand Down
8 changes: 8 additions & 0 deletions src/assets/logconfig/deepin-terminal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "deepin-terminal",
"exec": "/usr/bin/deepin-termnial",
"logType": "journal",
"logPath": "~/.cache/deepin/deepin-termnial/deepin-termnial.log",
"visible": true,
"version": "V1.0"
}
27 changes: 13 additions & 14 deletions src/common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ void Utils::parseCommandLine(QStringList arguments, TermProperties &Properties,
// 处理相应参数,当遇到-v -h参数的时候,这里进程会退出。
parser.process(arguments);
} else {
qInfo() << "input args:" << qPrintable(arguments.join(" "));
qInfo() << "arg: optionWorkDirectory" << parser.value(optWorkDirectory);
qInfo() << "arg: optionExecute" << Properties[Execute].toStringList().join(" ");
qInfo() << "arg: optionQuakeMode" << parser.isSet(optQuakeMode);
qInfo() << "arg: optionWindowState" << parser.isSet(optWindowState);
qInfo() << "Command line input args:" << qPrintable(arguments.join(" "));
qInfo() << "The work directory :" << parser.value(optWorkDirectory);
qInfo() << QString("Execute %1 command in the terminal").arg(Properties[Execute].toStringList().join(" "));
qInfo() << "Run in quake mode :" << parser.isSet(optQuakeMode);
qInfo() << "Set the window mode on starting :" << parser.isSet(optWindowState);
// 这个位置参数解析出来是无法匹配的,可是不带前面标识符,无法准确使用。
}
return;
Expand Down Expand Up @@ -428,11 +428,10 @@ QStringList Utils::parseExecutePara(QStringList &arguments)
if (paraList.size() != 0) {
for (int i = 0; i < index - startIndex; i++) {
arguments.removeAt(startIndex);
qInfo() << arguments.size();
}
arguments.removeOne("-e");
arguments.removeOne("--execute");
qInfo() << opt << paraList << "arguments" << arguments;
qInfo() << "Remove the arguments after '-e',the arguments :" << arguments;
}

return paraList;
Expand All @@ -456,7 +455,7 @@ QStringList Utils::parseNestedQString(QString str)
//对路径带空格的脚本,右键执行时不进行拆分处理, //./deepin-terminal "-e" "/home/lx777/Desktop/a b/PerfTools_1.9.sh"
QFileInfo fi(str);
if (fi.isFile()) {
qInfo() << "this is file,not split.";
qWarning() << "this is file,not split.";
paraList.append(str);
return paraList;
}
Expand Down Expand Up @@ -523,7 +522,7 @@ QList<QByteArray> Utils::encodeList()
}
}
if (!bFind)
qInfo() << "encode name :" << name << "not find!";
qWarning() << "encode (name :" << name << ") not find!";
else
encodeList << encodename;

Expand Down Expand Up @@ -598,8 +597,8 @@ bool Utils::isLoongarch()
return false;
}
m_Arch = QString::fromLocal8Bit(utsbuf.machine);
qInfo() << "m_Arch:" << m_Arch;
}
qInfo() << "Current system architecture:" << m_Arch;
return "mips64" == m_Arch || "loongarch64" == m_Arch;
}

Expand Down Expand Up @@ -673,7 +672,7 @@ MainWindow *Utils::getMainWindow(QWidget *currWidget)
MainWindow *main = nullptr;
QWidget *pWidget = currWidget->parentWidget();
while (pWidget != nullptr) {
qInfo() << pWidget->metaObject()->className();
qInfo() << "Current Window Class Name :" << pWidget->metaObject()->className();
if (("NormalWindow" == pWidget->objectName()) || ("QuakeWindow" == pWidget->objectName())) {
qInfo() << "has find MainWindow";
main = static_cast<MainWindow *>(pWidget);
Expand Down Expand Up @@ -718,7 +717,7 @@ void FontFilter::handleWidthFont()
m_thread->start();
return;
}
qInfo() << "m_thread is Running";
//qInfo() << "m_thread is Running";
}

void FontFilter::setStop(bool stop)
Expand Down Expand Up @@ -805,7 +804,7 @@ void FontFilter::compareWhiteList()
else
Blacklist.append(sfont);
}
qInfo() << "DBUS get font:" << DBUSWhitelist;
qInfo() << "Compare font get font:" << Whitelist;
qInfo() << "Font whitelist obtained through the dbus interface :" << DBUSWhitelist;
qInfo() << "Whitelist of real available fonts :" << Whitelist;
}
/******** Add by ut001000 renfeixiang 2020-06-15:增加 处理等宽字体的类 End***************/
Loading

0 comments on commit 4f4a1f0

Please sign in to comment.