Commit 1d361642 authored by Antonio Larrosa Jimenez's avatar Antonio Larrosa Jimenez
Browse files

Use ecm_qt_declare_logging_category to declare the logging categories

This automatizes the generation of logging categories so a
kdeconnect-kde.categories is generated and installed to
/usr/share/qlogging-categories5/ so kdebugsettings can use it.

Also, sets the default logging level to Warning. So now the logs
of users won't be filled with debug messages but they can
modify the configuration easily with kdebugsettings.
parent 8bf49850
Pipeline #21386 passed with stage
in 5 minutes and 29 seconds
......@@ -20,6 +20,7 @@ include(KDECMakeSettings)
include(ECMAddTests)
include(ECMSetupVersion)
include(ECMInstallIcons)
include(ECMQtDeclareLoggingCategory)
include(FeatureSummary)
include(GenerateExportHeader)
if (NOT SAILFISHOS)
......@@ -124,4 +125,6 @@ if(BUILD_TESTING)
add_subdirectory(tests)
endif()
ecm_qt_install_logging_categories(EXPORT kdeconnect-kde FILE kdeconnect-kde.categories SORT DESTINATION "${KDE_INSTALL_LOGGINGCATEGORIESDIR}")
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
add_definitions(-DTRANSLATION_DOMAIN=\"kdeconnect-core\")
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER kdeconnect_debug.h
IDENTIFIER KDECONNECT_CORE CATEGORY_NAME kdeconnect.core
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (core)")
set(KDECONNECT_PRIVATE_DBUS_ADDR unix:tmpdir=/tmp)
if(WIN32)
set(KDECONNECT_PRIVATE_DBUS_ADDR tcp:host=localhost,port=0)
......@@ -39,6 +47,7 @@ set(kdeconnectcore_SRCS
device.cpp
core_debug.cpp
notificationserverinfo.cpp
${debug_file_SRCS}
)
add_library(kdeconnectcore ${kdeconnectcore_SRCS})
......
......@@ -20,8 +20,6 @@
#include "core_debug.h"
Q_LOGGING_CATEGORY(KDECONNECT_CORE, "kdeconnect.core")
#if defined(__GNU_LIBRARY__)
#include <execinfo.h>
#include <stdlib.h>
......
......@@ -21,11 +21,8 @@
#ifndef CORE_DEBUG_H
#define CORE_DEBUG_H
#include <QLoggingCategory>
#include "kdeconnectcore_export.h"
KDECONNECTCORE_EXPORT Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_CORE)
#include "kdeconnect_debug.h"
void logBacktrace();
......
add_definitions(-DTRANSLATION_DOMAIN="kdeconnect-kded")
add_executable(kdeconnectd kdeconnectd.cpp)
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER kdeconnectd_debug.h
IDENTIFIER KDECONNECT_DAEMON CATEGORY_NAME kdeconnect.daemon
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (daemon)")
add_executable(kdeconnectd kdeconnectd.cpp ${debug_file_SRCS})
target_include_directories(kdeconnectd PUBLIC ${CMAKE_BINARY_DIR})
target_link_libraries(kdeconnectd kdeconnectcore KF5::KIOWidgets KF5::DBusAddons KF5::Notifications KF5::I18n Qt5::Widgets)
......
......@@ -21,7 +21,6 @@
#include <QApplication>
#include <QNetworkAccessManager>
#include <QTimer>
#include <QLoggingCategory>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QDBusMessage>
......@@ -42,9 +41,7 @@
#include "core/device.h"
#include "core/backends/pairinghandler.h"
#include "kdeconnect-version.h"
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_DAEMON)
Q_LOGGING_CATEGORY(KDECONNECT_DAEMON, "kdeconnect.daemon")
#include "kdeconnectd_debug.h"
class DesktopDaemon : public Daemon
{
......
add_definitions(-DTRANSLATION_DOMAIN="kdeconnect-fileitemaction")
add_library(kdeconnectfileitemaction MODULE sendfileitemaction.cpp)
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER kdeconnect_fileitemaction_debug.h
IDENTIFIER KDECONNECT_FILEITEMACTION CATEGORY_NAME kdeconnect.fileitemaction
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (fileitemaction)")
add_library(kdeconnectfileitemaction MODULE sendfileitemaction.cpp ${debug_file_SRCS})
target_link_libraries(
kdeconnectfileitemaction
KF5::KIOWidgets
......
......@@ -37,9 +37,9 @@
#include <dbushelper.h>
K_PLUGIN_CLASS_WITH_JSON(SendFileItemAction, "kdeconnectsendfile.json")
#include "kdeconnect_fileitemaction_debug.h"
Q_LOGGING_CATEGORY(KDECONNECT_FILEITEMACTION, "kdeconnect.fileitemaction")
K_PLUGIN_CLASS_WITH_JSON(SendFileItemAction, "kdeconnectsendfile.json")
SendFileItemAction::SendFileItemAction(QObject* parent, const QVariantList& ): KAbstractFileItemActionPlugin(parent)
{
......
......@@ -23,13 +23,11 @@
#include <KFileItemListProperties>
#include <KAbstractFileItemActionPlugin>
#include <QLoggingCategory>
class QAction;
class KFileItemListProperties;
class QWidget;
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_FILEITEMACTION)
class SendFileItemAction : public KAbstractFileItemActionPlugin
{
Q_OBJECT
......
......@@ -10,6 +10,19 @@ function(geninterface source_h output_h)
set(libkdeconnect_SRC ${libkdeconnect_SRC} PARENT_SCOPE)
endfunction()
set(debug_files_SRCS)
ecm_qt_declare_logging_category(
debug_files_SRCS HEADER interfaces_conversation_message_debug.h
IDENTIFIER CONVERSATION_MESSAGE_LOGGING_CATEGORY CATEGORY_NAME kdeconnect.interfaces.conversationmessage
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (conversation message)")
ecm_qt_declare_logging_category(
debug_files_SRCS HEADER interfaces_debug.h
IDENTIFIER KDECONNECT_INTERFACES CATEGORY_NAME kdeconnect.interfaces
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (interfaces)")
set(libkdeconnect_SRC
dbusinterfaces.cpp
devicesmodel.cpp
......@@ -20,6 +33,7 @@ set(libkdeconnect_SRC
remotesinksmodel.cpp
devicespluginfilterproxymodel.cpp
# modeltest.cpp
${debug_files_SRCS}
)
geninterface(${PROJECT_SOURCE_DIR}/core/daemon.h daemoninterface)
......
......@@ -20,10 +20,9 @@
#include "conversationmessage.h"
#include <QLoggingCategory>
#include <QVariantMap>
Q_LOGGING_CATEGORY(CONVERSATION_MESSAGE_LOGGING_CATEGORY, "kdeconnect.interfaces.conversationmessage")
#include "interfaces_conversation_message_debug.h"
ConversationMessage::ConversationMessage(const QVariantMap& args)
: m_eventField(args[QStringLiteral("event")].toInt()),
......
......@@ -22,12 +22,9 @@
#define PLUGINS_TELEPHONY_CONVERSATIONMESSAGE_H_
#include <QDBusMetaType>
#include <QLoggingCategory>
#include "kdeconnectinterfaces_export.h"
Q_DECLARE_LOGGING_CATEGORY(CONVERSATION_MESSAGE_LOGGING_CATEGORY)
class ConversationAddress;
class KDECONNECTINTERFACES_EXPORT ConversationMessage
......
......@@ -32,7 +32,7 @@
#include <dbushelper.h>
// #include "modeltest.h"
Q_LOGGING_CATEGORY(KDECONNECT_INTERFACES, "kdeconnect.interfaces");
#include "interfaces_debug.h"
static QString createId() { return QCoreApplication::instance()->applicationName()+QString::number(QCoreApplication::applicationPid()); }
......
/**
* Copyright 2014 Alejandro Fiestas Olivares <afiestas@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef KDECONNECT_INTERFACES_DEBUG_H
#define KDECONNECT_INTERFACES_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_INTERFACES)
#endif //KDECONNECT_INTERFACES_DEBUG_H
......@@ -19,7 +19,6 @@
*/
#include "notificationsmodel.h"
#include "interfaces_debug.h"
#include <QDebug>
#include <QIcon>
......@@ -30,6 +29,7 @@
//In older Qt released, qAsConst isnt available
#include "core/qtcompat_p.h"
#include "interfaces_debug.h"
NotificationsModel::NotificationsModel(QObject* parent)
: QAbstractListModel(parent)
......
include_directories(${CMAKE_SOURCE_DIR})
add_definitions(-DTRANSLATION_DOMAIN="kdeconnect-kio")
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER kdeconnectkio_debug.h
IDENTIFIER KDECONNECT_KIO CATEGORY_NAME kdeconnect.kio
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (kio)")
set(kio_kdeconnect_PART_SRCS
kiokdeconnect.cpp
${debug_file_SRCS}
)
add_library(kio_kdeconnect MODULE ${kio_kdeconnect_PART_SRCS})
......
......@@ -29,7 +29,7 @@
#include <QDebug>
#include <QtPlugin>
Q_LOGGING_CATEGORY(KDECONNECT_KIO, "kdeconnect.kio")
#include "kdeconnectkio_debug.h"
class KIOPluginForMetaData : public QObject
{
......
......@@ -22,14 +22,11 @@
#define KIOKDECONNECT_H
#include <QObject>
#include <QLoggingCategory>
#include <kio/slavebase.h>
#include "interfaces/dbusinterfaces.h"
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_KIO)
class KioKdeconnect : public QObject, public KIO::SlaveBase
{
Q_OBJECT
......
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER plugin_battery_debug.h
IDENTIFIER KDECONNECT_PLUGIN_BATTERY CATEGORY_NAME kdeconnect.plugin.battery
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (plugin battery)")
set(kdeconnect_battery_SRCS
batteryplugin.cpp
batterydbusinterface.cpp
${debug_file_SRCS}
)
kdeconnect_add_plugin(kdeconnect_battery JSON kdeconnect_battery.json SOURCES ${kdeconnect_battery_SRCS})
......
......@@ -23,6 +23,7 @@
#include <QDebug>
#include <core/device.h>
#include "plugin_battery_debug.h"
QMap<QString, BatteryDbusInterface *> BatteryDbusInterface::s_dbusInterfaces;
......
......@@ -30,11 +30,10 @@
#include <core/daemon.h>
#include "batterydbusinterface.h"
#include "plugin_battery_debug.h"
K_PLUGIN_CLASS_WITH_JSON(BatteryPlugin, "kdeconnect_battery.json")
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_BATTERY, "kdeconnect.plugin.battery")
BatteryPlugin::BatteryPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
, batteryDbusInterface(new BatteryDbusInterface(device()))
......
......@@ -21,13 +21,11 @@
#ifndef BATTERYPLUGIN_H
#define BATTERYPLUGIN_H
#include <QLoggingCategory>
#include <core/kdeconnectplugin.h>
#define PACKET_TYPE_BATTERY QStringLiteral("kdeconnect.battery")
#define PACKET_TYPE_BATTERY_REQUEST QStringLiteral("kdeconnect.battery.request")
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_BATTERY)
class BatteryDbusInterface;
class BatteryPlugin
......
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER plugin_clipboard_debug.h
IDENTIFIER KDECONNECT_PLUGIN_CLIPBOARD CATEGORY_NAME kdeconnect.plugin.clipboard
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (plugin clipboard)")
set(kdeconnect_clipboard_SRCS
clipboardplugin.cpp
clipboardlistener.cpp
${debug_file_SRCS}
)
kdeconnect_add_plugin(kdeconnect_clipboard JSON kdeconnect_clipboard.json SOURCES ${kdeconnect_clipboard_SRCS})
......
......@@ -21,13 +21,12 @@
#include "clipboardplugin.h"
#include "clipboardlistener.h"
#include "plugin_clipboard_debug.h"
#include <KPluginFactory>
K_PLUGIN_CLASS_WITH_JSON(ClipboardPlugin, "kdeconnect_clipboard.json")
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CLIPBOARD, "kdeconnect.plugin.clipboard")
ClipboardPlugin::ClipboardPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
{
......
......@@ -23,11 +23,8 @@
#include <QObject>
#include <QClipboard>
#include <QLoggingCategory>
#include <core/kdeconnectplugin.h>
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CLIPBOARD)
/**
* Packet containing just clipboard contents, sent when a device updates its clipboard.
* <p>
......
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER plugin_contacts_debug.h
IDENTIFIER KDECONNECT_PLUGIN_CONTACTS CATEGORY_NAME kdeconnect.plugin.contacts
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (plugin contacts)")
set(kdeconnect_contacts_SRCS
contactsplugin.cpp
${debug_file_SRCS}
)
kdeconnect_add_plugin(kdeconnect_contacts JSON kdeconnect_contacts.json SOURCES ${kdeconnect_contacts_SRCS})
......
......@@ -24,16 +24,15 @@
#include <QDBusConnection>
#include <QDBusMetaType>
#include <QLoggingCategory>
#include <QFile>
#include <QDir>
#include <QIODevice>
#include <core/device.h>
K_PLUGIN_CLASS_WITH_JSON(ContactsPlugin, "kdeconnect_contacts.json")
#include "plugin_contacts_debug.h"
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CONTACTS, "kdeconnect.plugin.contacts")
K_PLUGIN_CLASS_WITH_JSON(ContactsPlugin, "kdeconnect_contacts.json")
ContactsPlugin::ContactsPlugin(QObject* parent, const QVariantList& args) :
KdeConnectPlugin(parent, args)
......
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER plugin_findthisdevice_debug.h
IDENTIFIER KDECONNECT_PLUGIN_FINDTHISDEVICE CATEGORY_NAME kdeconnect.plugin.findthisdevice
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (plugin findthisdevice)")
set(kdeconnect_findthisdevice_SRCS
findthisdeviceplugin.cpp
${debug_file_SRCS}
)
kdeconnect_add_plugin(kdeconnect_findthisdevice
......@@ -22,7 +30,7 @@ endif()
set(kdeconnect_findthisdevice_config_SRCS findthisdevice_config.cpp)
ki18n_wrap_ui(kdeconnect_findthisdevice_config_SRCS findthisdevice_config.ui)
add_library(kdeconnect_findthisdevice_config MODULE ${kdeconnect_findthisdevice_config_SRCS})
add_library(kdeconnect_findthisdevice_config MODULE ${kdeconnect_findthisdevice_config_SRCS} ${debug_file_SRCS})
target_link_libraries(kdeconnect_findthisdevice_config
kdeconnectpluginkcm
Qt5::Multimedia
......
......@@ -32,6 +32,7 @@
// Qt
#include <QDBusConnection>
#include <QMediaPlayer>
#include "plugin_findthisdevice_debug.h"
K_PLUGIN_CLASS_WITH_JSON(FindThisDevicePlugin, "kdeconnect_findthisdevice.json")
......
......@@ -33,16 +33,10 @@
#include <QUrl>
#endif
// Qt
#include <QLoggingCategory>
#include "plugin_findthisdevice_debug.h"
#define PACKET_TYPE_FINDMYPHONE_REQUEST QStringLiteral("kdeconnect.findmyphone.request")
static const QLoggingCategory &KDECONNECT_PLUGIN_FINDTHISDEVICE()
{
static const QLoggingCategory category("kdeconnect.plugin.findthisdevice");
return category;
}
class FindThisDevicePlugin
: public KdeConnectPlugin
{
......
qt5_add_dbus_interface(lockdevice_SRCS org.freedesktop.ScreenSaver.xml screensaverdbusinterface)
kdeconnect_add_plugin(kdeconnect_lockdevice JSON kdeconnect_lockdevice.json SOURCES lockdeviceplugin.cpp ${lockdevice_SRCS})
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER plugin_lock_debug.h
IDENTIFIER KDECONNECT_PLUGIN_LOCKREMOTE CATEGORY_NAME kdeconnect.plugin.lock
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (plugin lockremote)")
kdeconnect_add_plugin(kdeconnect_lockdevice JSON kdeconnect_lockdevice.json SOURCES lockdeviceplugin.cpp ${lockdevice_SRCS} ${debug_file_SRCS})
target_link_libraries(kdeconnect_lockdevice
kdeconnectcore
......
......@@ -24,16 +24,14 @@
#include <KPluginFactory>
#include <QDebug>
#include <QLoggingCategory>
#include "screensaverdbusinterface.h"
#include "plugin_lock_debug.h"
#include <core/device.h>
#include <dbushelper.h>
K_PLUGIN_CLASS_WITH_JSON(LockDevicePlugin, "kdeconnect_lockdevice.json")
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_LOCKREMOTE, "kdeconnect.plugin.lock")
LockDevicePlugin::LockDevicePlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
, m_remoteLocked(false)
......
......@@ -20,7 +20,14 @@ qt5_add_dbus_interface(kdeconnect_mpriscontrol_SRCS org.mpris.MediaPlayer2.xml m
endif()
kdeconnect_add_plugin(kdeconnect_mpriscontrol JSON kdeconnect_mpriscontrol.json SOURCES ${kdeconnect_mpriscontrol_SRCS})
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
debug_file_SRCS HEADER plugin_mpris_debug.h
IDENTIFIER KDECONNECT_PLUGIN_MPRIS CATEGORY_NAME kdeconnect.plugin.mpris
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (plugin mpris)")
kdeconnect_add_plugin(kdeconnect_mpriscontrol JSON kdeconnect_mpriscontrol.json SOURCES ${kdeconnect_mpriscontrol_SRCS} ${debug_file_SRCS})
if(WIN32)
target_link_libraries(kdeconnect_mpriscontrol kdeconnectcore)
......
......@@ -20,6 +20,7 @@
#include "mpriscontrolplugin-win.h"
#include <core/device.h>
#include "plugin_mpris_debug.h"
#include <KPluginFactory>
......@@ -27,8 +28,6 @@
K_PLUGIN_CLASS_WITH_JSON(MprisControlPlugin, "kdeconnect_mpriscontrol.json")
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS, "kdeconnect.plugin.mpris")
MprisControlPlugin::MprisControlPlugin(QObject *parent, const QVariantList &args) : KdeConnectPlugin(parent, args) { }
bool MprisControlPlugin::receivePacket(const NetworkPacket &np)
......
......@@ -24,14 +24,11 @@
#include <core/kdeconnectplugin.h>
#include <QString>
#include <QLoggingCategory>
#define PLAYERNAME QStringLiteral("Media Player")
#define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris")
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS)
class MprisControlPlugin
: public KdeConnectPlugin
{
......
......@@ -34,12 +34,10 @@
#include "dbusproperties.h"
#include "mprisplayer.h"
#include "mprisroot.h"
#include "plugin_mpris_debug.h"
K_PLUGIN_CLASS_WITH_JSON(MprisControlPlugin, "kdeconnect_mpriscontrol.json")
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS, "kdeconnect.plugin.mpris")
MprisPlayer::MprisPlayer(const QString& serviceName, const QString& dbusObjectPath, const QDBusConnection& busConnection)
: m_serviceName(serviceName)
, m_propertiesInterface(new OrgFreedesktopDBusPropertiesInterface(serviceName, dbusObjectPath, busConnection))
......
......@@ -23,13 +23,11 @@
#include <QString>
#include <QHash>
#include <QLoggingCategory>
#include <QDBusServiceWatcher>
#include <QSharedPointer>
#include <core/kdeconnectplugin.h>
class OrgFreedesktopDBusPropertiesInterface;
class OrgMprisMediaPlayer2PlayerInterface;
......@@ -53,8 +51,6 @@ private:
#define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris")
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS)
class MprisControlPlugin
: public KdeConnectPlugin
{
......
kdeconnect_add_plugin(kdeconnect_mprisremote JSON kdeconnect_mprisremote.json SOURCES mprisremoteplugin.cpp mprisremoteplayer.cpp mprisremoteplayermediaplayer2.cpp mprisremoteplayermediaplayer2player.cpp)