summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Montel <[email protected]>2018-02-21 08:01:14 +0100
committerLaurent Montel <[email protected]>2018-02-21 08:01:14 +0100
commita588eeb60d2deb52ea649f4cb28cceaeba6e20b0 (patch)
treee157299b8c41086356ba13392f1a0441ce5e4faf
parentdcc7a52ed8e665c871f5863e1f9bbbf9de76a367 (diff)
Use regularexpression
-rw-r--r--autotests/kdebugsettingutiltest.cpp2
-rw-r--r--src/kdebugsettingsutil.cpp8
2 files changed, 7 insertions, 3 deletions
diff --git a/autotests/kdebugsettingutiltest.cpp b/autotests/kdebugsettingutiltest.cpp
index e29e111..6063084 100644
--- a/autotests/kdebugsettingutiltest.cpp
+++ b/autotests/kdebugsettingutiltest.cpp
@@ -50,6 +50,8 @@ 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("linewithcomment") << QStringLiteral("log linux#comment about linux") << QStringLiteral("linux") << QStringLiteral("log") << true;
}
diff --git a/src/kdebugsettingsutil.cpp b/src/kdebugsettingsutil.cpp
index e80a996..8b949e2 100644
--- a/src/kdebugsettingsutil.cpp
+++ b/src/kdebugsettingsutil.cpp
@@ -91,19 +91,21 @@ KdeLoggingCategory KDebugSettingsUtil::parseLineKdeLoggingCategory(QString line)
qCWarning(KDEBUGSETTINGS_LOG) << "No space:" << line << endl;
return category;
}
-#if 1
+#if 0
+ //log linux (foo)
+
const QString logName = line.left(space);
const QString description = line.mid(space).simplified();
#else
QString logName;
QString description;
- static const QRegularExpression regularExpressionUser(QStringLiteral("^(.*)\\s+(.*)$"));
+ static const QRegularExpression regularExpressionUser(QStringLiteral("^([\\w._-]+)\\s*(.*)$"));
QRegularExpressionMatch match = regularExpressionUser.match(line);
if (match.hasMatch()) {
logName = match.captured(1);
description = match.captured(2);
- qDebug() << " logName"<<logName<<" description " << description << " line " << line;
+ //qDebug() << " logName"<<logName<<" description " << description << " line " << line;
}
#endif