aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMéven Car <meven29@gmail.com>2019-08-14 16:27:31 +0200
committerMéven Car <meven29@gmail.com>2019-08-14 17:25:59 +0200
commit403c617eea56cc7581ee348e53d41eb4d291ba29 (patch)
tree303e9b5f24d59356d493045948bb1d5a0455e61a
parent2de9e4fc165bcadd54f81b7d17904c45632705f5 (diff)
downloadkconfig-403c617eea56cc7581ee348e53d41eb4d291ba29.tar.gz
kconfig-403c617eea56cc7581ee348e53d41eb4d291ba29.tar.bz2
Add a logging category for logs warnings
Summary: Disable logs unless the logging category kf5.kconfig.core is enabled Test Plan: ctest Reviewers: #frameworks, apol, cgiboudeaux Reviewed By: cgiboudeaux Subscribers: cgiboudeaux, mikeroyal, apol, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D22061
-rw-r--r--CMakeLists.txt2
-rw-r--r--kconfig.categories1
-rw-r--r--src/core/CMakeLists.txt5
-rw-r--r--src/core/kconfig.cpp5
-rw-r--r--src/core/kconfiggroup.cpp39
-rw-r--r--src/core/kconfigini.cpp17
-rw-r--r--src/core/kconfigwatcher.cpp3
-rw-r--r--src/core/kdesktopfile.cpp5
8 files changed, 45 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8a9e496a..36d6643c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,3 +101,5 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfig_version.h
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
+
+install(FILES kconfig.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
diff --git a/kconfig.categories b/kconfig.categories
new file mode 100644
index 00000000..2403da7b
--- /dev/null
+++ b/kconfig.categories
@@ -0,0 +1 @@
+kf5.kconfig.core KConfig Core DEFAULT_SEVERITY [WARNING] IDENTIFIER [KCONFIG_CORE_LOG]
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 28aad4f8..2fa80870 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -13,6 +13,11 @@ set(libkconfigcore_SRCS
kconfigwatcher.cpp
)
+ecm_qt_declare_logging_category(libkconfigcore_SRCS
+ HEADER kconfig_core_log_settings.h
+ IDENTIFIER KCONFIG_CORE_LOG
+ CATEGORY_NAME kf5.kconfig.core)
+
configure_file(config-kconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kconfig.h )
add_library(KF5ConfigCore ${libkconfigcore_SRCS})
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp
index f6824ce6..9f294209 100644
--- a/src/core/kconfig.cpp
+++ b/src/core/kconfig.cpp
@@ -24,6 +24,7 @@
#include "kconfig_p.h"
#include "config-kconfig.h"
+#include "kconfig_core_log_settings.h"
#include <cstdlib>
#include <fcntl.h>
@@ -408,7 +409,7 @@ bool KConfig::sync()
// lock the local file
if (d->configState == ReadWrite && !d->lockLocal()) {
- qWarning() << "couldn't lock local file";
+ qCWarning(KCONFIG_CORE_LOG) << "couldn't lock local file";
return false;
}
@@ -438,7 +439,7 @@ bool KConfig::sync()
if (d->wantGlobals() && writeGlobals) {
QExplicitlySharedDataPointer<KConfigBackend> tmp = KConfigBackend::create(*sGlobalFileName);
if (d->configState == ReadWrite && !tmp->lock()) {
- qWarning() << "couldn't lock global file";
+ qCWarning(KCONFIG_CORE_LOG) << "couldn't lock global file";
//unlock the local config if we're returning early
if (d->mBackend->isLocked()) {
diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp
index 92c58f6e..c7b8cb67 100644
--- a/src/core/kconfiggroup.cpp
+++ b/src/core/kconfiggroup.cpp
@@ -25,6 +25,7 @@
#include "kconfig.h"
#include "kconfig_p.h"
+#include "kconfig_core_log_settings.h"
#include "ksharedconfig.h"
#include "kconfigdata.h"
@@ -260,7 +261,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asIntList(value);
if (list.count() != 2) {
- qWarning() << errString(pKey, value, aDefault)
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
<< formatError(2, list.count());
return aDefault;
}
@@ -270,7 +271,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asRealList(value);
if (list.count() != 2) {
- qWarning() << errString(pKey, value, aDefault)
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
<< formatError(2, list.count());
return aDefault;
}
@@ -280,13 +281,13 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asIntList(value);
if (list.count() != 4) {
- qWarning() << errString(pKey, value, aDefault)
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
<< formatError(4, list.count());
return aDefault;
}
const QRect rect(list.at(0), list.at(1), list.at(2), list.at(3));
if (!rect.isValid()) {
- qWarning() << errString(pKey, value, aDefault);
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
return aDefault;
}
return rect;
@@ -295,13 +296,13 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asRealList(value);
if (list.count() != 4) {
- qWarning() << errString(pKey, value, aDefault)
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
<< formatError(4, list.count());
return aDefault;
}
const QRectF rect(list.at(0), list.at(1), list.at(2), list.at(3));
if (!rect.isValid()) {
- qWarning() << errString(pKey, value, aDefault);
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
return aDefault;
}
return rect;
@@ -310,13 +311,13 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asIntList(value);
if (list.count() != 2) {
- qWarning() << errString(pKey, value, aDefault)
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
<< formatError(2, list.count());
return aDefault;
}
const QSize size(list.at(0), list.at(1));
if (!size.isValid()) {
- qWarning() << errString(pKey, value, aDefault);
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
return aDefault;
}
return size;
@@ -325,13 +326,13 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asRealList(value);
if (list.count() != 2) {
- qWarning() << errString(pKey, value, aDefault)
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
<< formatError(2, list.count());
return aDefault;
}
const QSizeF size(list.at(0), list.at(1));
if (!size.isValid()) {
- qWarning() << errString(pKey, value, aDefault);
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
return aDefault;
}
return size;
@@ -339,7 +340,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
case QMetaType::QDateTime: {
const auto list = asIntList(value);
if (list.count() != 6) {
- qWarning() << errString(pKey, value, aDefault)
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
<< formatError(6, list.count());
return aDefault;
}
@@ -347,7 +348,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const QTime time(list.at(3), list.at(4), list.at(5));
const QDateTime dt(date, time);
if (!dt.isValid()) {
- qWarning() << errString(pKey, value, aDefault);
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
return aDefault;
}
return dt;
@@ -358,20 +359,20 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime
}
if (list.count() != 3) {
- qWarning() << errString(pKey, value, aDefault)
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
<< formatError(3, list.count());
return aDefault;
}
const QDate date(list.at(0), list.at(1), list.at(2));
if (!date.isValid()) {
- qWarning() << errString(pKey, value, aDefault);
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
return aDefault;
}
return date;
}
case QMetaType::QColor:
case QMetaType::QFont:
- qWarning() << "KConfigGroup::readEntry was passed GUI type '"
+ qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::readEntry was passed GUI type '"
<< aDefault.typeName()
<< "' but KConfigGui isn't linked! If it is linked to your program, "
"this is a platform bug. Please inform the KDE developers";
@@ -383,7 +384,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
break;
}
- qWarning() << "unhandled type " << aDefault.typeName();
+ qCWarning(KCONFIG_CORE_LOG) << "unhandled type " << aDefault.typeName();
return QVariant();
}
@@ -955,7 +956,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
break;
case QMetaType::QVariantList:
if (!value.canConvert(QMetaType::QStringList))
- qWarning() << "not all types in \"" << key << "\" can convert to QString,"
+ qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key << "\" can convert to QString,"
" information will be lost";
Q_FALLTHROUGH();
case QMetaType::QStringList:
@@ -1065,7 +1066,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QColor:
case QMetaType::QFont:
- qWarning() << "KConfigGroup::writeEntry was passed GUI type '"
+ qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry was passed GUI type '"
<< value.typeName()
<< "' but KConfigGui isn't linked! If it is linked to your program, this is a platform bug. "
"Please inform the KDE developers";
@@ -1074,7 +1075,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
data = QUrl(value.toUrl()).toString().toUtf8();
break;
default:
- qWarning() << "KConfigGroup::writeEntry - unhandled type" << value.typeName() << "in group" << name();
+ qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry - unhandled type" << value.typeName() << "in group" << name();
}
writeEntry(key, data, flags);
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp
index af306502..d07b59c6 100644
--- a/src/core/kconfigini.cpp
+++ b/src/core/kconfigini.cpp
@@ -26,6 +26,7 @@
#include "kconfigbackend_p.h"
#include "bufferfragment_p.h"
#include "kconfigdata.h"
+#include "kconfig_core_log_settings.h"
#include <qsavefile.h>
#include <qlockfile.h>
@@ -139,7 +140,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
end = start;
for (;;) {
if (end == line.length()) {
- qWarning() << warningProlog(file, lineNo) << "Invalid group header.";
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid group header.";
// XXX maybe reset the current group here?
goto next_line;
}
@@ -196,7 +197,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
line.trim();
}
if (aKey.isEmpty()) {
- qWarning() << warningProlog(file, lineNo) << "Invalid entry (empty key)";
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid entry (empty key)";
continue;
}
@@ -210,7 +211,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
while ((start = aKey.lastIndexOf('[')) >= 0) {
int end = aKey.indexOf(']', start);
if (end < 0) {
- qWarning() << warningProlog(file, lineNo)
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo)
<< "Invalid entry (missing ']')";
goto next_line;
} else if (end > start + 1 && aKey.at(start + 1) == '$') { // found option(s)
@@ -240,7 +241,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
}
} else { // found a locale
if (!locale.isNull()) {
- qWarning() << warningProlog(file, lineNo)
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo)
<< "Invalid entry (second locale!?)";
goto next_line;
}
@@ -250,7 +251,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
aKey.truncate(start);
}
if (eqpos < 0) { // Do this here after [$d] was checked
- qWarning() << warningProlog(file, lineNo) << "Invalid entry (missing '=')";
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid entry (missing '=')";
continue;
}
printableToString(&aKey, file, lineNo);
@@ -511,7 +512,7 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa
return true;
}
// Couldn't write. Disk full?
- qWarning() << "Couldn't write" << filePath() << ". Disk full?";
+ qCWarning(KCONFIG_CORE_LOG) << "Couldn't write" << filePath() << ". Disk full?";
return false;
}
} else {
@@ -855,7 +856,7 @@ char KConfigIniBackend::charFromHex(const char *str, const QFile &file, int line
} else {
QByteArray e(str, 2);
e.prepend("\\x");
- qWarning() << warningProlog(file, line) << "Invalid hex character " << c
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << "Invalid hex character " << c
<< " in \\x<nn>-type escape sequence \"" << e.constData() << "\".";
return 'x';
}
@@ -923,7 +924,7 @@ void KConfigIniBackend::printableToString(BufferFragment *aString, const QFile &
break;
default:
*r = '\\';
- qWarning() << warningProlog(file, line)
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line)
<< QStringLiteral("Invalid escape sequence \"\\%1\".").arg(str[i]);
}
}
diff --git a/src/core/kconfigwatcher.cpp b/src/core/kconfigwatcher.cpp
index 9a37b6f0..2e7defcb 100644
--- a/src/core/kconfigwatcher.cpp
+++ b/src/core/kconfigwatcher.cpp
@@ -20,6 +20,7 @@
#include "kconfigwatcher.h"
#include "config-kconfig.h"
+#include "kconfig_core_log_settings.h"
#if KCONFIG_USE_DBUS
#include <QDBusConnection>
@@ -85,7 +86,7 @@ KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config):
SLOT(onConfigChangeNotification(QHash<QString,QByteArrayList>)));
}
#else
- qWarning() << "Use of KConfigWatcher without DBus support. You will not receive updates";
+ qCWarning(KCONFIG_CORE_LOG) << "Use of KConfigWatcher without DBus support. You will not receive updates";
#endif
}
diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp
index d9283cef..367a7d8b 100644
--- a/src/core/kdesktopfile.cpp
+++ b/src/core/kdesktopfile.cpp
@@ -34,6 +34,7 @@
#include "kconfig_p.h"
#include "kconfiggroup.h"
#include "kconfigini_p.h"
+#include "kconfig_core_log_settings.h"
class KDesktopFilePrivate : public KConfigPrivate
{
@@ -158,7 +159,7 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString &path)
// Forbid desktop files outside of standard locations if kiosk is set so
if (!KAuthorized::authorize(QStringLiteral("run_desktop_files"))) {
- qWarning() << "Access to '" << path << "' denied because of 'run_desktop_files' restriction." << endl;
+ qCWarning(KCONFIG_CORE_LOG) << "Access to '" << path << "' denied because of 'run_desktop_files' restriction." << endl;
return false;
}
@@ -169,7 +170,7 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString &path)
return true;
}
- qWarning() << "Access to '" << path << "' denied, not owned by root, executable flag not set." << endl;
+ qCWarning(KCONFIG_CORE_LOG) << "Access to '" << path << "' denied, not owned by root, executable flag not set." << endl;
return false;
}