Commit e46a0666 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Use categorized logging for libraries.

parent 82e62293
......@@ -29,6 +29,7 @@ set(learnerprofile_LIB_SRCS
profilemanager.cpp
storage.cpp
models/learninggoalmodel.cpp
liblearner_debug.cpp
)
add_library(artikulatelearnerprofile SHARED ${learnerprofile_LIB_SRCS})
......
......@@ -24,7 +24,7 @@
#include <QHash>
#include <QFileInfo>
#include <QPixmap>
#include <QDebug>
#include "liblearner_debug.h"
using namespace LearnerProfile;
......@@ -81,14 +81,14 @@ QString Learner::imageUrl() const
void Learner::importImage(const QString &path)
{
if (!QFileInfo(path).exists()) {
qWarning() << "image path points to a non-existing file, aborting: " << path;
qCWarning(LIBLEARNER_LOG) << "image path points to a non-existing file, aborting: " << path;
return;
}
QPixmap image = QPixmap(path);
image = image.scaled(120, 120);
image.save(d->imageUrl());
emit imageUrlChanged();
qDebug() << "saved scaled image from " << path << " at " << d->imageUrl();
qCDebug(LIBLEARNER_LOG) << "saved scaled image from " << path << " at " << d->imageUrl();
}
QList< LearningGoal* > Learner::goals() const
......@@ -165,7 +165,7 @@ LearningGoal * Learner::activeGoal(Learner::Category categoryLearner) const
// workaround for Q_INVOKABLE access of enum
LearningGoal::Category category = static_cast<LearningGoal::Category>(categoryLearner);
if (!d->m_activeGoal.contains(category)) {
qWarning() << "(Learner " << identifier() << ") No current learning goal set for category "
qCWarning(LIBLEARNER_LOG) << "(Learner " << identifier() << ") No current learning goal set for category "
<< category
<< " : fall back to first in list";
foreach (LearningGoal *goal, d->m_goals) {
......@@ -173,7 +173,7 @@ LearningGoal * Learner::activeGoal(Learner::Category categoryLearner) const
return goal;
}
}
qWarning() << "No learning goals of catagory " << category << " registered";
qCWarning(LIBLEARNER_LOG) << "No learning goals of catagory " << category << " registered";
return 0;
}
return d->m_activeGoal[category];
......
/*
* Copyright 2015 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "liblearner_debug.h"
Q_LOGGING_CATEGORY(LIBLEARNER_LOG, "log_liblearner")
/*
* Copyright 2015 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBLEARNER_DEBUG_H
#define LIBLEARNER_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(LIBLEARNER_LOG)
#endif
......@@ -27,7 +27,7 @@
#include <QSignalMapper>
#include <KLocalizedString>
#include <QDebug>
#include "liblearner_debug.h"
using namespace LearnerProfile;
......@@ -214,7 +214,7 @@ void LearningGoalModel::onLearningGoalAboutToBeRemoved(int index)
}
if (index < 0 || d->m_goals.count() <= index) {
qWarning() << "Cannot remove learning goal from model, not registered";
qCWarning(LIBLEARNER_LOG) << "Cannot remove learning goal from model, not registered";
return;
}
beginRemoveRows(QModelIndex(), index, index);
......
......@@ -24,7 +24,7 @@
#include <QObject>
#include <QList>
#include <QDebug>
#include "liblearner_debug.h"
#include <KConfigCore/KConfig>
#include <KConfigCore/KConfigGroup>
#include <QFileDialog>
......@@ -82,7 +82,7 @@ LearnerProfile::ProfileManagerPrivate::ProfileManagerPrivate()
}
}
if (m_activeProfile == 0) {
qDebug() << "No last active profile found, falling back to first found profile";
qCDebug(LIBLEARNER_LOG) << "No last active profile found, falling back to first found profile";
if (m_profiles.size() > 0) {
m_activeProfile = m_profiles.at(0);
}
......@@ -196,7 +196,7 @@ void ProfileManager::removeProfile(Learner *learner)
{
int index = d->m_profiles.indexOf(learner);
if (index < 0) {
qWarning() << "Profile was not found, aborting";
qCWarning(LIBLEARNER_LOG) << "Profile was not found, aborting";
return;
}
emit profileAboutToBeRemoved(index);
......
......@@ -21,7 +21,7 @@
#include "storage.h"
#include "learner.h"
#include <QDebug>
#include "liblearner_debug.h"
#include <QDir>
#include <KLocalizedString>
......@@ -165,7 +165,7 @@ bool Storage::removeProfile(Learner *learner)
bool Storage::removeRelation(Learner *learner, LearningGoal *goal)
{
qDebug() << "remove relation";
qCDebug(LIBLEARNER_LOG) << "remove relation";
QSqlDatabase db = database();
QSqlQuery removeGoalRelationQuery(db);
removeGoalRelationQuery.prepare(
......@@ -333,7 +333,7 @@ QSqlDatabase Storage::database()
if (!dir.exists()) {
dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
}
qDebug() << "Database path: " << path;
qCDebug(LIBLEARNER_LOG) << "Database path: " << path;
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(path);
......@@ -384,7 +384,7 @@ bool Storage::updateSchema()
}
else {
if (!db.transaction()) {
qWarning() << db.lastError().text();
qCWarning(LIBLEARNER_LOG) << db.lastError().text();
raiseError(db.lastError());
return false;
}
......
......@@ -37,6 +37,7 @@ set(sound_LIB_SRCS
outputdevicecontroller.cpp
qtgstreamercapturebackend.cpp
qtgstreameroutputbackend.cpp
libsound_debug.cpp
)
add_library(artikulatesound SHARED ${sound_LIB_SRCS})
......
......@@ -22,7 +22,7 @@
#include "qtgstreamercapturebackend.h"
#include <QUrl>
#include <QStringList>
#include <QDebug>
#include "libsound_debug.h"
/**
* \class CaptureDeviceControllerPrivate
......
/*
* Copyright 2015 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libsound_debug.h"
Q_LOGGING_CATEGORY(LIBSOUND_LOG, "log_libsound")
/*
* Copyright 2015 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBSOUND_DEBUG_H
#define LIBSOUND_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(LIBSOUND_LOG)
#endif
......@@ -21,7 +21,7 @@
#include "outputdevicecontroller.h"
#include "qtgstreameroutputbackend.h"
#include <QUrl>
#include <QDebug>
#include "libsound_debug.h"
/**
* \class OutputDeviceControllerPrivate
......
......@@ -30,7 +30,7 @@
#include <QGst/Event>
#include <QGst/Message>
#include <QGst/Bus>
#include <QDebug>
#include "libsound_debug.h"
#include <KLocalizedString>
QtGStreamerCaptureBackend::QtGStreamerCaptureBackend()
......@@ -98,7 +98,7 @@ void QtGStreamerCaptureBackend::onBusMessage(const QGst::MessagePtr & message)
switch (message->type()) {
case QGst::MessageEos:
//got end-of-stream - stop the pipeline
qDebug() << "EOS signal received, stopping pipeline";
qCDebug(LIBSOUND_LOG) << "EOS signal received, stopping pipeline";
stopPipeline();
break;
case QGst::MessageError:
......@@ -119,7 +119,7 @@ void QtGStreamerCaptureBackend::startCapture(const QString &filePath)
{
// clear pipeline if still existing
if (m_pipeline) {
qWarning() << "removing forgotten pipeline";
qCWarning(LIBSOUND_LOG) << "removing forgotten pipeline";
//send an end-of-stream event to flush metadata and cause an EosMessage to be delivered
m_pipeline->sendEvent(QGst::EosEvent::create());
}
......@@ -163,7 +163,7 @@ void QtGStreamerCaptureBackend::stopCapture()
void QtGStreamerCaptureBackend::stopPipeline()
{
if (!m_pipeline) {
qWarning() << "Stopping non-existing pipeline, aborting";
qCWarning(LIBSOUND_LOG) << "Stopping non-existing pipeline, aborting";
return;
}
m_pipeline->setState(QGst::StateNull);
......
Markdown is supported
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