Commit 971216c8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Split debug categories in several categories + autogenerate it + install categories file

parent 494be972
......@@ -44,6 +44,7 @@ include(ECMPackageConfigHelpers)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(ECMSetupVersion)
include(ECMQtDeclareLoggingCategory)
check_library_exists(c clock_gettime "time.h" HAVE_CLOCK_GETTIME_C)
......@@ -111,4 +112,6 @@ install(EXPORT libksysguardLibraryTargets
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
FILE KF5SysGuardLibraryTargets.cmake )
install(FILES libksysguard.categories DESTINATION ${KDE_INSTALL_CONFDIR})
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
......@@ -4,13 +4,13 @@
########### next target ###############
set(ksgrd_LIB_SRCS
${libksysguard_SOURCE_DIR}/processcore/processcore_debug.cpp
SensorAgent.cpp
SensorManager.cpp
SensorShellAgent.cpp
SensorSocketAgent.cpp
)
ecm_qt_declare_logging_category(ksgrd_LIB_SRCS HEADER ksgrd_debug.h IDENTIFIER LIBKSYSGUARD_KSGRD CATEGORY_NAME org.kde.libksysguard.ksgrd)
add_definitions(-DTRANSLATION_DOMAIN=\"ksgrd\")
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
......
......@@ -23,8 +23,7 @@
//#include <stdlib.h>
#include "processcore/processcore_debug.h"
#include <QDebug>
#include "ksgrd_debug.h"
#include <KLocalizedString>
#include "SensorClient.h"
......@@ -75,7 +74,7 @@ void SensorAgent::sendRequest( const QString &req, SensorClient *client, int id
mInputFIFO.enqueue( new SensorRequest( req, client, id ) );
#if SA_TRACE
qCDebug(LIBKSYSGUARD) << "-> " << req << "(" << mInputFIFO.count() << "/"
qCDebug(LIBKSYSGUARD_KSGRD) << "-> " << req << "(" << mInputFIFO.count() << "/"
<< mProcessingFIFO.count() << ")" << endl;
#endif
executeCommand();
......@@ -93,7 +92,7 @@ void SensorAgent::processAnswer( const char *buf, int buflen )
}
#if SA_TRACE
qCDebug(LIBKSYSGUARD) << "<- " << QString::fromUtf8(buffer, buffer.size());
qCDebug(LIBKSYSGUARD_KSGRD) << "<- " << QString::fromUtf8(buffer, buffer.size());
#endif
int startOfAnswer = 0; //This can become >= buffer.size(), so check before using!
for ( int i = 0; i < buffer.size(); ++i ) {
......@@ -136,7 +135,7 @@ void SensorAgent::processAnswer( const char *buf, int buflen )
if(!answer.isEmpty())
mAnswerBuffer << answer;
#if SA_TRACE
qCDebug(LIBKSYSGUARD) << "<= " << mAnswerBuffer
qCDebug(LIBKSYSGUARD_KSGRD) << "<= " << mAnswerBuffer
<< "(" << mInputFIFO.count() << "/"
<< mProcessingFIFO.count() << ")" << endl;
#endif
......@@ -152,7 +151,7 @@ void SensorAgent::processAnswer( const char *buf, int buflen )
* ready to serve requests now. */
mDaemonOnLine = true;
#if SA_TRACE
qCDebug(LIBKSYSGUARD) << "Daemon now online!";
qCDebug(LIBKSYSGUARD_KSGRD) << "Daemon now online!";
#endif
mAnswerBuffer.clear();
continue;
......@@ -162,7 +161,7 @@ void SensorAgent::processAnswer( const char *buf, int buflen )
// remove pending request from FIFO
if ( mProcessingFIFO.isEmpty() ) {
qCDebug(LIBKSYSGUARD) << "ERROR: Received answer but have no pending "
qCDebug(LIBKSYSGUARD_KSGRD) << "ERROR: Received answer but have no pending "
<< "request!" << endl;
mAnswerBuffer.clear();
continue;
......@@ -180,7 +179,7 @@ void SensorAgent::processAnswer( const char *buf, int buflen )
if(!mAnswerBuffer.isEmpty() && mAnswerBuffer[0] == "UNKNOWN COMMAND") {
/* Notify client that the sensor seems to be no longer available. */
qCDebug(LIBKSYSGUARD) << "Received UNKNOWN COMMAND for: " << req->request();
qCDebug(LIBKSYSGUARD_KSGRD) << "Received UNKNOWN COMMAND for: " << req->request();
req->client()->sensorLost( req->id() );
} else {
// Notify client of newly arrived answer.
......@@ -208,13 +207,13 @@ void SensorAgent::executeCommand()
SensorRequest *req = mInputFIFO.dequeue();
#if SA_TRACE
qCDebug(LIBKSYSGUARD) << ">> " << req->request().toAscii() << "(" << mInputFIFO.count()
qCDebug(LIBKSYSGUARD_KSGRD) << ">> " << req->request().toAscii() << "(" << mInputFIFO.count()
<< "/" << mProcessingFIFO.count() << ")" << endl;
#endif
// send request to daemon
QString cmdWithNL = req->request() + '\n';
if ( !writeMsg( cmdWithNL.toLatin1().constData(), cmdWithNL.length() ) )
qCDebug(LIBKSYSGUARD) << "SensorAgent::writeMsg() failed";
qCDebug(LIBKSYSGUARD_KSGRD) << "SensorAgent::writeMsg() failed";
// add request to processing FIFO.
// Note that this means that mProcessingFIFO is now responsible for managing the memory for it.
......
......@@ -27,8 +27,7 @@
#include <QWidget>
#include <QEvent>
#include <kconfiggroup.h>
#include "processcore/processcore_debug.h"
#include "ksgrd_debug.h"
#include "SensorShellAgent.h"
#include "SensorSocketAgent.h"
......@@ -326,7 +325,7 @@ bool SensorManager::resynchronize( const QString &hostName )
mAgents.remove( hostName );
qCDebug(LIBKSYSGUARD) << "Re-synchronizing connection to " << hostName;
qCDebug(LIBKSYSGUARD_KSGRD) << "Re-synchronizing connection to " << hostName;
return engage( hostName, shell, command );
}
......
......@@ -26,7 +26,7 @@
#include <kshell.h>
#include <klocalizedstring.h>
#include "processcore/processcore_debug.h"
#include "ksgrd_debug.h"
#include "SensorManager.h"
#include "SensorShellAgent.h"
......@@ -102,14 +102,14 @@ void SensorShellAgent::errMsgRcvd( )
// But if this is extended, we will need to handle this better
const QString buf = QString::fromUtf8( buffer );
qCDebug(LIBKSYSGUARD) << "SensorShellAgent: Warning, received text over stderr!"
qCDebug(LIBKSYSGUARD_KSGRD) << "SensorShellAgent: Warning, received text over stderr!"
<< endl << buf << endl;
}
void SensorShellAgent::daemonExited( int exitCode, QProcess::ExitStatus exitStatus )
{
Q_UNUSED(exitCode);
qCDebug(LIBKSYSGUARD) << "daemon exited, exit status " << exitStatus;
qCDebug(LIBKSYSGUARD_KSGRD) << "daemon exited, exit status " << exitStatus;
if ( mRetryCount-- <= 0 || (mDaemon->start(), !mDaemon->waitForStarted()) )
{
setDaemonOnLine( false );
......@@ -124,7 +124,7 @@ void SensorShellAgent::daemonError( QProcess::ProcessError errorStatus )
QString error;
switch(errorStatus) {
case QProcess::FailedToStart:
qCDebug(LIBKSYSGUARD) << "failed to run" << mDaemon->program().join(QStringLiteral(" "));
qCDebug(LIBKSYSGUARD_KSGRD) << "failed to run" << mDaemon->program().join(QStringLiteral(" "));
error = i18n("Could not run daemon program '%1'.", mDaemon->program().join(" "));
break;
case QProcess::Crashed:
......@@ -135,7 +135,7 @@ void SensorShellAgent::daemonError( QProcess::ProcessError errorStatus )
error = i18n("The daemon program '%1' failed.", mDaemon->program().join(" "));
}
setReasonForOffline(error);
qCDebug(LIBKSYSGUARD) << "Error received " << error << "(" << errorStatus << ")";
qCDebug(LIBKSYSGUARD_KSGRD) << "Error received " << error << "(" << errorStatus << ")";
setDaemonOnLine( false );
if(sensorManager())
sensorManager()->disengage( this ); //delete ourselves
......
......@@ -23,8 +23,7 @@
//#include <stdlib.h>
#include "processcore/processcore_debug.h"
#include <QDebug>
#include "ksgrd_debug.h"
#include <klocalizedstring.h>
#include "SensorClient.h"
......@@ -54,7 +53,7 @@ bool SensorSocketAgent::start( const QString &host, const QString&,
const QString&, int port )
{
if ( port <= 0 )
qCDebug(LIBKSYSGUARD) << "SensorSocketAgent::start: Invalid port " << port;
qCDebug(LIBKSYSGUARD_KSGRD) << "SensorSocketAgent::start: Invalid port " << port;
setHostName( host );
mPort = port;
......
org.kde.libksysguard.ksgrd libksysguard (ksgrd)
org.kde.libksysguard.processcore libksysguard (processcore)
org.kde.libksysguard.processui libksysguard (processui)
org.kde.libksysguard.ksignalplotter libksysguard (ksignalplotter)
......@@ -3,7 +3,6 @@ add_definitions(-DTRANSLATION_DOMAIN=\"processcore\")
########### next target ###############
set(ksysguard_LIB_SRCS
processcore_debug.cpp
processes.cpp
process.cpp
processes_local_p.cpp
......@@ -11,7 +10,7 @@ set(ksysguard_LIB_SRCS
processes_base_p.cpp
processes_atop_p.cpp
)
ecm_qt_declare_logging_category(ksysguard_LIB_SRCS HEADER processcore_debug.h IDENTIFIER LIBKSYSGUARD_PROCESSCORE CATEGORY_NAME org.kde.libksysguard.processcore)
add_library(processcore ${ksysguard_LIB_SRCS})
......
/* This file is part of the KDE project
Copyright (C) 2014 Hrvoje Senjan <hrvoje.senjan@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "processcore_debug.h"
Q_LOGGING_CATEGORY(LIBKSYSGUARD, "libksysguard")
/* This file is part of the KDE project
Copyright (C) 2014 Hrvoje Senjan <hrvoje.senjan@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef PROCESSCORE_DEBUG_H
#define PROCESSCORE_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(LIBKSYSGUARD)
#endif
......@@ -310,7 +310,7 @@ bool ProcessesATop::setViewingTime(const QDateTime &when)
d->currentlySelectedIndex = i - d->historyTimes.begin();
bool success = d->loadDataForHistory(d->currentlySelectedIndex);
if(!success)
qCWarning(LIBKSYSGUARD) << d->lastError;
qCWarning(LIBKSYSGUARD_PROCESSCORE) << d->lastError;
return success;
}
return false;
......
......@@ -93,11 +93,11 @@ void ProcessesRemote::setup() {
long ProcessesRemote::getParentPid(long pid) {
if(!d->processByPid.contains(pid)) {
qCDebug(LIBKSYSGUARD) << "Parent pid requested for pid that we do not have info on " << pid;
qCDebug(LIBKSYSGUARD_PROCESSCORE) << "Parent pid requested for pid that we do not have info on " << pid;
return 0;
}
if(d->ppidColumn == -1) {
qCDebug(LIBKSYSGUARD) << "ppid column not known ";
qCDebug(LIBKSYSGUARD_PROCESSCORE) << "ppid column not known ";
return 0;
}
return d->processByPid[pid].at(d->ppidColumn).toLong();
......@@ -106,7 +106,7 @@ bool ProcessesRemote::updateProcessInfo( long pid, Process *process)
{
Q_CHECK_PTR(process);
if(!d->processByPid.contains(pid)) {
qCDebug(LIBKSYSGUARD) << "update request for pid that we do not have info on " << pid;
qCDebug(LIBKSYSGUARD_PROCESSCORE) << "update request for pid that we do not have info on " << pid;
return false;
}
QList<QByteArray> p = d->processByPid[pid];
......
......@@ -6,7 +6,6 @@ check_include_files(byteswap.h HAVE_BYTESWAP_H)
set(ksysguard_WIDGETS "ksysguard.widgets")
set(processui_LIB_SRCS
${libksysguard_SOURCE_DIR}/processcore/processcore_debug.cpp
ksysguardprocesslist.cpp
ProcessFilter.cpp
ProcessModel.cpp
......@@ -15,6 +14,9 @@ set(processui_LIB_SRCS
scripting.cpp
)
ecm_qt_declare_logging_category(processui_LIB_SRCS HEADER processui_debug.h IDENTIFIER LIBKSYSGUARD_PROCESSUI CATEGORY_NAME org.kde.libksysguard.processui)
ki18n_wrap_ui( processui_LIB_SRCS
ReniceDlgUi.ui
ProcessWidgetUI.ui
......
......@@ -19,7 +19,7 @@
Boston, MA 02110-1301, USA.
*/
#include "processcore/processcore_debug.h"
#include "processui_debug.h"
/* For getuid() */
#include <unistd.h>
......@@ -42,7 +42,7 @@ bool ProcessFilter::filterAcceptsRow( int source_row, const QModelIndex & source
const KSysGuard::Process *process;
if(model->isSimpleMode()) {
if(source_parent.isValid()) {
qCDebug(LIBKSYSGUARD) << "Serious error with data. In simple mode, there should be no children";
qCDebug(LIBKSYSGUARD_PROCESSUI) << "Serious error with data. In simple mode, there should be no children";
return true;
}
process = model->getProcessAtIndex(source_row);
......@@ -58,7 +58,7 @@ bool ProcessFilter::filterAcceptsRow( int source_row, const QModelIndex & source
//}
}
if(!model->isSimpleMode() && source_row >= parent_process->children().size()) {
qCDebug(LIBKSYSGUARD) << "Serious error with data. Source row requested for a non existent row. Requested " << source_row << " of " << parent_process->children().size() << " for " << parent_process->pid();
qCDebug(LIBKSYSGUARD_PROCESSUI) << "Serious error with data. Source row requested for a non existent row. Requested " << source_row << " of " << parent_process->children().size() << " for " << parent_process->pid();
return true;
}
......
......@@ -28,7 +28,7 @@
#include "processcore/processes.h"
#include "processcore/process.h"
#include "processcore/processcore_debug.h"
#include "processui_debug.h"
#include <kcolorscheme.h>
#include <kiconloader.h>
......@@ -867,7 +867,7 @@ void ProcessModelPrivate::beginRemoveRow( KSysGuard::Process *process )
} else {
int row = process->parent()->children().indexOf(process);
if(row == -1) {
qCDebug(LIBKSYSGUARD) << "A serious problem occurred in remove row.";
qCDebug(LIBKSYSGUARD_PROCESSUI) << "A serious problem occurred in remove row.";
mRemovingRow = false;
return;
}
......
......@@ -2,11 +2,10 @@
set(ksignalplotter_WIDGETS "ksignalplotter.widgets")
set(ksignalplotter_LIB_SRCS
${libksysguard_SOURCE_DIR}/processcore/processcore_debug.cpp
ksignalplotter.cpp
kgraphicssignalplotter.cpp
)
# kde4_moc_headers(ksignalplotter ksignalplotter.h kgraphicssignalplotter.h)
ecm_qt_declare_logging_category(ksignalplotter_LIB_SRCS HEADER ksignalplotter_debug.h IDENTIFIER LIBKSYSGUARD_KSIGNALPLOTTER CATEGORY_NAME org.kde.libksysguard.ksignalplotter)
add_library(ksignalplotter ${ksignalplotter_LIB_SRCS})
add_library(KF5::SignalPlotter ALIAS ksignalplotter)
......
......@@ -30,7 +30,7 @@
#endif
#include "ksignalplotter_p.h"
#include "processcore/processcore_debug.h"
#include "ksignalplotter_debug.h"
#include <QPainter>
#include <QPixmap>
......@@ -108,11 +108,11 @@ QColor KSignalPlotter::beamColor( int index ) const {
void KSignalPlotter::setBeamColor( int index, const QColor &color ) {
if(!color.isValid()) {
qCDebug(LIBKSYSGUARD) << "Invalid color";
qCDebug(LIBKSYSGUARD_KSIGNALPLOTTER) << "Invalid color";
return;
}
if( index >= d->mBeamColors.count() ) {
qCDebug(LIBKSYSGUARD) << "Invalid index" << index;
qCDebug(LIBKSYSGUARD_KSIGNALPLOTTER) << "Invalid index" << index;
return;
}
Q_ASSERT(d->mBeamColors.count() == d->mBeamColorsLight.count());
......@@ -514,7 +514,7 @@ void KSignalPlotterPrivate::rescale() {
void KSignalPlotterPrivate::addSample( const QList<qreal>& sampleBuf )
{
if(sampleBuf.count() != mBeamColors.count()) {
qCDebug(LIBKSYSGUARD) << "Sample data discarded - contains wrong number of beams";
qCDebug(LIBKSYSGUARD_KSIGNALPLOTTER) << "Sample data discarded - contains wrong number of beams";
return;
}
mBeamData.prepend(sampleBuf);
......@@ -550,7 +550,7 @@ void KSignalPlotterPrivate::reorderBeams( const QList<int>& newOrder )
QList< QList<qreal> >::Iterator it;
for(it = mBeamData.begin(); it != mBeamData.end(); ++it) {
if(newOrder.count() != (*it).count()) {
qCWarning(LIBKSYSGUARD) << "Serious problem in move sample. beamdata[i] has " << (*it).count() << " and neworder has " << newOrder.count();
qCWarning(LIBKSYSGUARD_KSIGNALPLOTTER) << "Serious problem in move sample. beamdata[i] has " << (*it).count() << " and neworder has " << newOrder.count();
} else {
QList<qreal> newBeam;
for(int i = 0; i < newOrder.count(); i++) {
......
......@@ -3,22 +3,25 @@ find_package(Qt5 REQUIRED CONFIG COMPONENTS Test)
include_directories(${libksysguard_SOURCE_DIR})
if(Qt5WebKitWidgets_FOUND)
# Process unit test
ecm_add_test(processtest.cpp ${libksysguard_SOURCE_DIR}/processcore/processcore_debug.cpp TEST_NAME processtest
ecm_qt_declare_logging_category(processtest_debug_SRCS HEADER processcore_debug.h IDENTIFIER LIBKSYSGUARD_PROCESSCORE CATEGORY_NAME org.kde.libksysguard.processcore)
ecm_add_test(processtest.cpp ${processtest_debug_SRCS} TEST_NAME processtest
LINK_LIBRARIES KF5::ProcessUi Qt5::Test)
endif()
if (KF5Plasma_FOUND)
ecm_add_test(signalplotterbenchmark.cpp ${libksysguard_SOURCE_DIR}/processcore/processcore_debug.cpp ../signalplotter/ksignalplotter.cpp
set(SIGNALPLOTTER_DEBUG_SRCS)
ecm_qt_declare_logging_category(SIGNALPLOTTER_DEBUG_SRCS HEADER ksignalplotter_debug.h IDENTIFIER LIBKSYSGUARD_KSIGNALPLOTTER CATEGORY_NAME org.kde.libksysguard.ksignalplotter)
ecm_add_test(signalplotterbenchmark.cpp ../signalplotter/ksignalplotter.cpp ${SIGNALPLOTTER_DEBUG_SRCS}
TEST_NAME signalplotterbenchmark
LINK_LIBRARIES KF5::SignalPlotter Qt5::Test Qt5::Widgets KF5::IconThemes
)
ecm_add_test(graphicssignalplotterbenchmark.cpp ${libksysguard_SOURCE_DIR}/processcore/processcore_debug.cpp ../signalplotter/kgraphicssignalplotter.cpp
ecm_add_test(graphicssignalplotterbenchmark.cpp ../signalplotter/kgraphicssignalplotter.cpp ${SIGNALPLOTTER_DEBUG_SRCS}
TEST_NAME graphicssignalplotterbenchmark
LINK_LIBRARIES KF5::SignalPlotter Qt5::Test Qt5::Widgets KF5::IconThemes KF5::Plasma
)
ecm_add_test(signalplottertest.cpp ${libksysguard_SOURCE_DIR}/processcore/processcore_debug.cpp ../signalplotter/ksignalplotter.cpp
ecm_add_test(signalplottertest.cpp ../signalplotter/ksignalplotter.cpp ${SIGNALPLOTTER_DEBUG_SRCS}
TEST_NAME signalplottertest
LINK_LIBRARIES KF5::SignalPlotter Qt5::Test Qt5::Widgets KF5::IconThemes
)
......
......@@ -26,7 +26,7 @@
#include "processcore/processes.h"
#include "processcore/process.h"
#include "processcore/processes_base_p.h"
#include "processcore/processcore_debug.h"
#include "processcore_debug.h"
#include "processui/ksysguardprocesslist.h"
......
Supports Markdown
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