diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) +include(ECMQtDeclareLoggingCategory) set(REQUIRED_QT_VERSION 5.8.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml DBus Widgets) diff --git a/src/solid/devices/backends/udisks2/CMakeLists.txt b/src/solid/devices/backends/udisks2/CMakeLists.txt --- a/src/solid/devices/backends/udisks2/CMakeLists.txt +++ b/src/solid/devices/backends/udisks2/CMakeLists.txt @@ -11,4 +11,10 @@ devices/backends/udisks2/udisksstorageaccess.cpp devices/backends/udisks2/udisksgenericinterface.cpp devices/backends/udisks2/dbus/manager.cpp -) \ No newline at end of file +) + +ecm_qt_declare_logging_category(solid_LIB_SRCS + HEADER udisks_debug.h + IDENTIFIER Solid::Backends::UDisks2::UDISKS2 + DEFAULT_SEVERITY Warning + CATEGORY_NAME org.kde.solid.udisks2) diff --git a/src/solid/devices/backends/udisks2/udisksblock.cpp b/src/solid/devices/backends/udisks2/udisksblock.cpp --- a/src/solid/devices/backends/udisks2/udisksblock.cpp +++ b/src/solid/devices/backends/udisks2/udisksblock.cpp @@ -33,6 +33,7 @@ #include #include +#include "udisks_debug.h" #include "udisksblock.h" using namespace Solid::Backends::UDisks2; @@ -69,7 +70,7 @@ } } } else { - qWarning() << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message(); + qCWarning(UDISKS2) << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message(); } } diff --git a/src/solid/devices/backends/udisks2/udisksdevice.cpp b/src/solid/devices/backends/udisks2/udisksdevice.cpp --- a/src/solid/devices/backends/udisks2/udisksdevice.cpp +++ b/src/solid/devices/backends/udisks2/udisksdevice.cpp @@ -19,6 +19,7 @@ License along with this library. If not, see . */ +#include "udisks_debug.h" #include "udisksdevice.h" #include "udisksdevicebackend.h" #include "udisksblock.h" @@ -95,7 +96,7 @@ connect(m_backend, SIGNAL(changed()), this, SIGNAL(changed())); connect(m_backend, SIGNAL(propertyChanged(QMap)), this, SIGNAL(propertyChanged(QMap))); } else { - qDebug() << "Created invalid Device for udi" << udi; + qCDebug(UDISKS2) << "Created invalid Device for udi" << udi; } } diff --git a/src/solid/devices/backends/udisks2/udisksdevicebackend.cpp b/src/solid/devices/backends/udisks2/udisksdevicebackend.cpp --- a/src/solid/devices/backends/udisks2/udisksdevicebackend.cpp +++ b/src/solid/devices/backends/udisks2/udisksdevicebackend.cpp @@ -20,6 +20,7 @@ License along with this library. If not, see . */ +#include "udisks_debug.h" #include "udisksdevicebackend.h" #include @@ -86,7 +87,7 @@ const QString xmlData = introspect(); if (xmlData.isEmpty()) { - qDebug() << m_udi << "has no interfaces!"; + qCDebug(UDISKS2) << m_udi << "has no interfaces!"; return; } @@ -145,7 +146,7 @@ m_propertyCache.insert(it.key(), it.value()); } } else { - qWarning() << "Error getting props:" << reply.error().name() << reply.error().message(); + qCWarning(UDISKS2) << "Error getting props:" << reply.error().name() << reply.error().message(); } //qDebug() << "After iface" << iface << ", cache now contains" << m_propertyCache.size() << "items"; } diff --git a/src/solid/devices/backends/udisks2/udisksmanager.cpp b/src/solid/devices/backends/udisks2/udisksmanager.cpp --- a/src/solid/devices/backends/udisks2/udisksmanager.cpp +++ b/src/solid/devices/backends/udisks2/udisksmanager.cpp @@ -20,6 +20,7 @@ #include "udisksmanager.h" #include "udisksdevicebackend.h" +#include "udisks_debug.h" #include #include @@ -163,7 +164,7 @@ } } } else { - qWarning() << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message(); + qCWarning(UDISKS2) << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message(); } } @@ -186,7 +187,7 @@ return; } - qDebug() << udi << "has new interfaces:" << interfaces_and_properties.keys(); + qCDebug(UDISKS2) << udi << "has new interfaces:" << interfaces_and_properties.keys(); updateBackend(udi); @@ -213,7 +214,7 @@ return; } - qDebug() << udi << "lost interfaces:" << interfaces; + qCDebug(UDISKS2) << udi << "lost interfaces:" << interfaces; /* * Determine left interfaces. The device backend may have processed the @@ -251,7 +252,7 @@ const QString udi = msg.path(); updateBackend(udi); qulonglong size = properties.value("Size").toULongLong(); - qDebug() << "MEDIA CHANGED in" << udi << "; size is:" << size; + qCDebug(UDISKS2) << "MEDIA CHANGED in" << udi << "; size is:" << size; if (!m_deviceCache.contains(udi) && size > 0) { // we don't know the optdisc, got inserted m_deviceCache.append(udi); diff --git a/src/solid/devices/backends/udisks2/udisksopticaldisc.cpp b/src/solid/devices/backends/udisks2/udisksopticaldisc.cpp --- a/src/solid/devices/backends/udisks2/udisksopticaldisc.cpp +++ b/src/solid/devices/backends/udisks2/udisksopticaldisc.cpp @@ -33,6 +33,7 @@ #include "../shared/udevqt.h" #include "udisks2.h" +#include "udisks_debug.h" #include "udisksopticaldisc.h" #include "soliddefs_p.h" @@ -55,29 +56,31 @@ int pos = 0; /* the path table record we're on */ int curr_record = 1; + /* import debug category */ + using Solid::Backends::UDisks2::UDISKS2; Solid::OpticalDisc::ContentType result = Solid::OpticalDisc::NoContent; int fd = open(device_file.constData(), O_RDONLY); /* read the block size */ lseek(fd, 0x8080, SEEK_CUR); if (read(fd, &bs, 2) != 2) { - qDebug("Advanced probing on %s failed while reading block size", qPrintable(device_file)); + qCDebug(UDISKS2, "Advanced probing on %s failed while reading block size", qPrintable(device_file)); goto out; } /* read in size of path table */ lseek(fd, 2, SEEK_CUR); if (read(fd, &ts, 2) != 2) { - qDebug("Advanced probing on %s failed while reading path table size", qPrintable(device_file)); + qCDebug(UDISKS2, "Advanced probing on %s failed while reading path table size", qPrintable(device_file)); goto out; } /* read in which block path table is in */ lseek(fd, 6, SEEK_CUR); if (read(fd, &tl, 4) != 4) { - qDebug("Advanced probing on %s failed while reading path table block", qPrintable(device_file)); + qCDebug(UDISKS2, "Advanced probing on %s failed while reading path table block", qPrintable(device_file)); goto out; } @@ -88,42 +91,42 @@ while (pos < ts) { /* get the length of the filename of the current entry */ if (read(fd, &len_di, 1) != 1) { - qDebug("Advanced probing on %s failed, cannot read more entries", qPrintable(device_file)); + qCDebug(UDISKS2, "Advanced probing on %s failed, cannot read more entries", qPrintable(device_file)); break; } /* get the record number of this entry's parent i'm pretty sure that the 1st entry is always the top directory */ lseek(fd, 5, SEEK_CUR); if (read(fd, &parent, 2) != 2) { - qDebug("Advanced probing on %s failed, couldn't read parent entry", qPrintable(device_file)); + qCDebug(UDISKS2, "Advanced probing on %s failed, couldn't read parent entry", qPrintable(device_file)); break; } /* read the name */ if (read(fd, dirname, len_di) != len_di) { - qDebug("Advanced probing on %s failed, couldn't read the entry name", qPrintable(device_file)); + qCDebug(UDISKS2, "Advanced probing on %s failed, couldn't read the entry name", qPrintable(device_file)); break; } dirname[len_di] = 0; /* if we found a folder that has the root as a parent, and the directory name matches one of the special directories then set the properties accordingly */ if (parent == 1) { if (!strcasecmp(dirname, "VIDEO_TS")) { - qDebug("Disc in %s is a Video DVD", qPrintable(device_file)); + qCDebug(UDISKS2, "Disc in %s is a Video DVD", qPrintable(device_file)); result = Solid::OpticalDisc::VideoDvd; break; } else if (!strcasecmp(dirname, "BDMV")) { - qDebug("Disc in %s is a Blu-ray video disc", qPrintable(device_file)); + qCDebug(UDISKS2, "Disc in %s is a Blu-ray video disc", qPrintable(device_file)); result = Solid::OpticalDisc::VideoBluRay; break; } else if (!strcasecmp(dirname, "VCD")) { - qDebug("Disc in %s is a Video CD", qPrintable(device_file)); + qCDebug(UDISKS2, "Disc in %s is a Video CD", qPrintable(device_file)); result = Solid::OpticalDisc::VideoCd; break; } else if (!strcasecmp(dirname, "SVCD")) { - qDebug("Disc in %s is a Super Video CD", qPrintable(device_file)); + qCDebug(UDISKS2, "Disc in %s is a Super Video CD", qPrintable(device_file)); result = Solid::OpticalDisc::SuperVideoCd; break; } diff --git a/src/solid/devices/backends/udisks2/udisksopticaldrive.cpp b/src/solid/devices/backends/udisks2/udisksopticaldrive.cpp --- a/src/solid/devices/backends/udisks2/udisksopticaldrive.cpp +++ b/src/solid/devices/backends/udisks2/udisksopticaldrive.cpp @@ -30,6 +30,7 @@ #include #include +#include "udisks_debug.h" #include "udisksopticaldrive.h" #include "udisks2.h" #include "udisksdevice.h" @@ -89,7 +90,7 @@ } } } else { // show error - qWarning() << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message(); + qCWarning(UDISKS2) << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message(); } if (!blockPath.isEmpty()) { diff --git a/src/solid/devices/backends/udisks2/udisksstorageaccess.cpp b/src/solid/devices/backends/udisks2/udisksstorageaccess.cpp --- a/src/solid/devices/backends/udisks2/udisksstorageaccess.cpp +++ b/src/solid/devices/backends/udisks2/udisksstorageaccess.cpp @@ -19,6 +19,7 @@ License along with this library. If not, see . */ +#include "udisks_debug.h" #include "udisksstorageaccess.h" #include "udisks2.h" @@ -347,7 +348,7 @@ m_lastReturnObject, wId, appId); m_passphraseRequested = reply.isValid(); if (!m_passphraseRequested) { - qWarning() << "Failed to call the SolidUiServer, D-Bus said:" << reply.error(); + qCWarning(UDISKS2) << "Failed to call the SolidUiServer, D-Bus said:" << reply.error(); } return m_passphraseRequested;