Commit ecaa04c0 authored by Laurent Montel's avatar Laurent Montel 😁

Start to implement default categories support

parent a588eeb6
......@@ -50,8 +50,11 @@ void KDebugSettingUtilTest::shouldParseKdeLoggingLine_data()
QTest::newRow("comment-2") << QStringLiteral("#log linux") << QString() << QString() << false;
QTest::newRow("validLineWithParentheses") << QStringLiteral("log linux (foo)") << QStringLiteral("linux (foo)") << QStringLiteral("log") << true;
QTest::newRow("validLineWithParenthesesAndCategories") << QStringLiteral("log linux (foo) [WARNING]") << QStringLiteral("linux (foo) [WARNING]") << QStringLiteral("log") << true;
QTest::newRow("validLineWithParenthesesAndCategories") << QStringLiteral("log linux (foo) [WARNING]") << QStringLiteral("linux (foo)") << QStringLiteral("log") << true;
QTest::newRow("validLineCategories") << QStringLiteral("log linux [WARNING]") << QStringLiteral("linux") << QStringLiteral("log") << true;
QTest::newRow("validLineCategories2") << QStringLiteral("log linux [WARNING] ") << QStringLiteral("linux") << QStringLiteral("log") << true;
QTest::newRow("validLineCategories3") << QStringLiteral("log linux [WARNING] ") << QStringLiteral("linux") << QStringLiteral("log") << true;
QTest::newRow("linewithcomment") << QStringLiteral("log linux#comment about linux") << QStringLiteral("linux") << QStringLiteral("log") << true;
}
......
......@@ -107,6 +107,17 @@ KdeLoggingCategory KDebugSettingsUtil::parseLineKdeLoggingCategory(QString line)
description = match.captured(2);
//qDebug() << " logName"<<logName<<" description " << description << " line " << line;
}
static const QRegularExpression regularExpressionDefaultCategory(QStringLiteral("^(.*)\\s+\\[(.*)\\]$"));
QRegularExpressionMatch match2 = regularExpressionDefaultCategory.match(description);
if (match.hasMatch()) {
const QString descriptionCaptured = match2.captured(1);
const QString defaultCategory = match2.captured(2);
if (!descriptionCaptured.isEmpty() && !defaultCategory.isEmpty()) {
description = descriptionCaptured;
qDebug() << " match.captured(1);" << match2.captured(1);
qDebug() << " match.captured(2);" << match2.captured(2);
}
}
#endif
category.logName = logName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment