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

Use categorized logging for application.

parent e46a0666
......@@ -56,6 +56,7 @@ set(artikulateCore_SRCS
core/player.cpp
core/recorder.cpp
ui/newcoursedialog.cpp
artikulate_debug.cpp
)
# compile UI files
......@@ -92,6 +93,7 @@ set(artikulate_SRCS
main.cpp
mainwindow.cpp
application.cpp
artikulate_debug.cpp
models/coursemodel.cpp
models/coursefiltermodel.cpp
......@@ -124,6 +126,7 @@ set(artikulate_editor_SRCS
main_editor.cpp
mainwindow_editor.cpp
application.cpp
artikulate_debug.cpp
models/coursemodel.cpp
models/coursefiltermodel.cpp
......
/*
* 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 "artikulate_debug.h"
Q_LOGGING_CATEGORY(ARTIKULATE_LOG, "log_artikulate")
/*
* 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 ARTIKULATE_DEBUG_H
#define ARTIKULATE_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(ARTIKULATE_LOG)
#endif
......@@ -26,7 +26,7 @@
#include "resourcemanager.h"
#include "phonemegroup.h"
#include <QDebug>
#include "artikulate_debug.h"
#include <KLocalizedString>
#include <QStringList>
#include <QPair>
......@@ -153,7 +153,7 @@ void Course::addUnit(Unit *unit)
QList<Unit*>::ConstIterator iter = m_unitList.constBegin();
while (iter != m_unitList.constEnd()) {
if (unit->id() == (*iter)->id()) {
qWarning() << "Unit already contained in this course, aborting";
qCWarning(ARTIKULATE_LOG) << "Unit already contained in this course, aborting";
return;
}
++iter;
......@@ -184,7 +184,7 @@ Unit * Course::createUnit()
QString id = QUuid::createUuid().toString();
while (unitIds.contains(id)) {
id = QUuid::createUuid().toString();
qWarning() << "Unit id generator has found a collision, recreating id.";
qCWarning(ARTIKULATE_LOG) << "Unit id generator has found a collision, recreating id.";
}
// create unit
......@@ -209,7 +209,7 @@ Phrase * Course::createPhrase(Unit *unit)
QString id = QUuid::createUuid().toString();
while (phraseIds.contains(id)) {
id = QUuid::createUuid().toString();
qWarning() << "Phrase id generator has found a collision, recreating id.";
qCWarning(ARTIKULATE_LOG) << "Phrase id generator has found a collision, recreating id.";
}
// create unit
......@@ -267,7 +267,7 @@ PhonemeGroup * Course::phonemeGroup(Unit *unit) const
void Course::addPhonemeGroup(PhonemeGroup *phonemeGroup)
{
if (m_phonemeUnitList.contains(phonemeGroup)) {
qWarning() << "Phoneme group already contained in this course, aborting";
qCWarning(ARTIKULATE_LOG) << "Phoneme group already contained in this course, aborting";
return;
}
emit phonemeGroupAboutToBeAdded(phonemeGroup, m_phonemeGroupList.count());
......
......@@ -27,7 +27,7 @@
#include "core/unit.h"
#include "core/phrase.h"
#include "core/resourcemanager.h"
#include <QDebug>
#include "artikulate_debug.h"
EditorSession::EditorSession(QObject *parent)
: QObject(parent)
......
......@@ -22,7 +22,7 @@
#include "models/languagemodel.h"
#include "phoneme.h"
#include "phonemegroup.h"
#include <QDebug>
#include "artikulate_debug.h"
#include <KLocalizedString>
Language::Language(QObject *parent)
......@@ -104,7 +104,7 @@ PhonemeGroup * Language::addPhonemeGroup(const QString &identifier, const QStrin
QList<PhonemeGroup *>::ConstIterator iter = m_phonemeGroups.constBegin();
while (iter != m_phonemeGroups.constEnd()) {
if (QString::compare((*iter)->id(), identifier) == 0) {
qWarning() << "Prononciation Group identifier already registered, aborting";
qCWarning(ARTIKULATE_LOG) << "Prononciation Group identifier already registered, aborting";
return 0;
}
++iter;
......
......@@ -19,7 +19,7 @@
*/
#include "phoneme.h"
#include <QDebug>
#include "artikulate_debug.h"
Phoneme::Phoneme(QObject *parent)
: QObject(parent)
......
......@@ -21,7 +21,7 @@
#include "phonemegroup.h"
#include "phoneme.h"
#include <QDebug>
#include "artikulate_debug.h"
PhonemeGroup::PhonemeGroup(QObject *parent)
: QObject(parent)
......@@ -87,7 +87,7 @@ void PhonemeGroup::addPhoneme(Phoneme *phoneme)
QList<Phoneme *>::ConstIterator iter = m_phonemes.constBegin();
while (iter != m_phonemes.constEnd()) {
if (QString::compare((*iter)->id(), phoneme->id()) == 0) {
qWarning() << "Phoneme identifier already registered in group "<< m_title <<", aborting";
qCWarning(ARTIKULATE_LOG) << "Phoneme identifier already registered in group "<< m_title <<", aborting";
return;
}
++iter;
......@@ -103,7 +103,7 @@ Phoneme * PhonemeGroup::addPhoneme(const QString &identifier, const QString &tit
QList<Phoneme *>::ConstIterator iter = m_phonemes.constBegin();
while (iter != m_phonemes.constEnd()) {
if (QString::compare((*iter)->id(), identifier) == 0) {
qWarning() << "Phoneme identifier " << identifier <<" already registered in group "
qCWarning(ARTIKULATE_LOG) << "Phoneme identifier " << identifier <<" already registered in group "
<< m_title <<", aborting";
return 0;
}
......
......@@ -25,7 +25,7 @@
#include "course.h"
#include "settings.h"
#include <QDebug>
#include "artikulate_debug.h"
#include <QTemporaryFile>
#include <sys/stat.h>
......@@ -150,7 +150,7 @@ void Phrase::setType(const QString &typeString)
setType(Paragraph);
return;
}
qWarning() << "Cannot set type from unknown identifier, aborting";
qCWarning(ARTIKULATE_LOG) << "Cannot set type from unknown identifier, aborting";
return;
}
......@@ -199,7 +199,7 @@ void Phrase::setEditState(const QString &stateString)
setEditState(Completed);
return;
}
qWarning() << "Cannot set edit state from unknown identifier " << stateString << ", aborting";
qCWarning(ARTIKULATE_LOG) << "Cannot set edit state from unknown identifier " << stateString << ", aborting";
return;
}
......@@ -236,7 +236,7 @@ QUrl Phrase::sound() const
void Phrase::setSound(const QUrl &soundFile)
{
if (!soundFile.isValid() || soundFile.isEmpty()) {
qWarning() << "Not setting empty sound file path.";
qCWarning(ARTIKULATE_LOG) << "Not setting empty sound file path.";
return;
}
m_nativeSoundFile = soundFile;
......
......@@ -22,7 +22,7 @@
#include "libsound/src/outputdevicecontroller.h"
#include <QList>
#include <QDebug>
#include "artikulate_debug.h"
#include <QUrl>
#include <QString>
......@@ -42,7 +42,7 @@ Player::~Player()
void Player::setSoundFile(const QUrl &fileUrl)
{
if (!fileUrl.isValid() || fileUrl.isEmpty()) {
qWarning() << "Not setting empty sound file path.";
qCWarning(ARTIKULATE_LOG) << "Not setting empty sound file path.";
return;
}
m_soundFile = fileUrl;
......@@ -72,7 +72,7 @@ void Player::playback()
qCritical() << "Abort playing sound, no file available";
return;
}
qDebug() << this << "Playback sound in file "<< m_soundFile.toLocalFile();
qCDebug(ARTIKULATE_LOG) << this << "Playback sound in file "<< m_soundFile.toLocalFile();
OutputDeviceController::self().play(QUrl::fromLocalFile(m_soundFile.toLocalFile()));
m_playbackState = PlayingState;
connect(&OutputDeviceController::self(), SIGNAL(started()), this, SLOT(updateState()));
......
......@@ -22,7 +22,7 @@
#include "libsound/src/capturedevicecontroller.h"
#include <QList>
#include <QDebug>
#include "artikulate_debug.h"
#include <QDir>
#include <QUrl>
#include <QString>
......@@ -49,11 +49,11 @@ Recorder::CaptureState Recorder::state() const
void Recorder::startCapture()
{
if (CaptureDeviceController::self().state() == CaptureDeviceController::RecordingState) {
qWarning() << "Stopped capture before starting new capture, since was still active.";
qCWarning(ARTIKULATE_LOG) << "Stopped capture before starting new capture, since was still active.";
CaptureDeviceController::self().stopCapture();
}
m_recordingBufferFile.open();
qDebug() << "Start recording to temporary file " << m_recordingBufferFile.fileName();
qCDebug(ARTIKULATE_LOG) << "Start recording to temporary file " << m_recordingBufferFile.fileName();
CaptureDeviceController::self().startCapture(m_recordingBufferFile.fileName());
m_state = RecordingState;
emit stateChanged();
......
......@@ -43,7 +43,7 @@
#include <QUuid>
#include <QDir>
#include <QDirIterator>
#include <QDebug>
#include "artikulate_debug.h"
#include <QUrl>
#include <QStandardPaths>
......@@ -367,7 +367,7 @@ void ResourceManager::updateCourseFromSkeleton(Course *course)
}
// FIXME deassociate removed phrases
qDebug() << "Update performed!";
qCDebug(ARTIKULATE_LOG) << "Update performed!";
}
CourseResource * ResourceManager::addCourse(const QUrl &courseFile)
......
......@@ -36,7 +36,7 @@
#include <QFileInfo>
#include <QDir>
#include <QDebug>
#include "artikulate_debug.h"
class CourseResourcePrivate
{
......@@ -158,14 +158,14 @@ void CourseResource::sync()
// if resource was never loaded, it cannot be changed
if (d->m_courseResource == 0) {
qDebug() << "Aborting sync, course was not parsed.";
qCDebug(ARTIKULATE_LOG) << "Aborting sync, course was not parsed.";
return;
}
//TODO
// // not writing back if not modified
// if (!d->m_courseResource->modified()) {
// qDebug() << "Aborting sync, course was not modified.";
// qCDebug(ARTIKULATE_LOG) << "Aborting sync, course was not modified.";
// return;
// }
......@@ -231,7 +231,7 @@ void CourseResource::sync()
// write back to file
QFileInfo info(path().adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path()); // create directories if necessary
if (!info.exists()) {
qDebug() << "create xml output file directory, not existing";
qCDebug(ARTIKULATE_LOG) << "create xml output file directory, not existing";
QDir dir;
dir.mkpath(path().adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path());
}
......@@ -239,7 +239,7 @@ void CourseResource::sync()
//TODO port to KSaveFile
QFile file(path().toLocalFile());
if (!file.open(QIODevice::WriteOnly)) {
qWarning() << "Unable to open file " << file.fileName() << " in write mode, aborting.";
qCWarning(ARTIKULATE_LOG) << "Unable to open file " << file.fileName() << " in write mode, aborting.";
return;
}
......@@ -335,7 +335,7 @@ QObject * CourseResource::resource()
}
QDomDocument document = loadDomDocument(path(), schema);
if (document.isNull()) {
qWarning() << "Could not parse document " << path().toLocalFile() << ", aborting.";
qCWarning(ARTIKULATE_LOG) << "Could not parse document " << path().toLocalFile() << ", aborting.";
return 0;
}
......@@ -361,7 +361,7 @@ QObject * CourseResource::resource()
}
}
if (d->m_courseResource->language() == 0) {
qWarning() << "Language ID" << language << "unknown, could not register any language, aborting";
qCWarning(ARTIKULATE_LOG) << "Language ID" << language << "unknown, could not register any language, aborting";
return 0;
}
......
......@@ -30,7 +30,7 @@
#include <QIODevice>
#include <QFile>
#include <QDebug>
#include "artikulate_debug.h"
class LanguageResourcePrivate
{
......@@ -142,7 +142,7 @@ QObject * LanguageResource::resource()
}
if (!d->m_path.isLocalFile()) {
qWarning() << "Cannot open language file at " << d->m_path.toLocalFile() << ", aborting.";
qCWarning(ARTIKULATE_LOG) << "Cannot open language file at " << d->m_path.toLocalFile() << ", aborting.";
return 0;
}
......@@ -153,7 +153,7 @@ QObject * LanguageResource::resource()
QDomDocument document = loadDomDocument(d->m_path, schema);
if (document.isNull()) {
qWarning() << "Could not parse document " << d->m_path.toLocalFile() << ", aborting.";
qCWarning(ARTIKULATE_LOG) << "Could not parse document " << d->m_path.toLocalFile() << ", aborting.";
return 0;
}
......
......@@ -20,7 +20,7 @@
#include "resourceinterface.h"
#include <QDebug>
#include "artikulate_debug.h"
#include <QUrl>
#include <QIODevice>
#include <QXmlSchema>
......@@ -53,12 +53,12 @@ bool ResourceInterface::isContributorResource() const
void ResourceInterface::sync()
{
qWarning() << "Resource does not implement syncing.";
qCWarning(ARTIKULATE_LOG) << "Resource does not implement syncing.";
}
void ResourceInterface::reload()
{
qWarning() << "Resource does not implement reloading.";
qCWarning(ARTIKULATE_LOG) << "Resource does not implement reloading.";
}
QXmlSchema ResourceInterface::loadXmlSchema(const QString &schemeName) const
......@@ -68,7 +68,7 @@ QXmlSchema ResourceInterface::loadXmlSchema(const QString &schemeName) const
QXmlSchema schema;
if (file.isEmpty() || schema.load(file) == false) {
qWarning() << "Schema at file " << file.toLocalFile() << " is invalid.";
qCWarning(ARTIKULATE_LOG) << "Schema at file " << file.toLocalFile() << " is invalid.";
}
return schema;
}
......@@ -78,7 +78,7 @@ QDomDocument ResourceInterface::loadDomDocument(const QUrl &path, const QXmlSche
QDomDocument document;
QXmlSchemaValidator validator(schema);
if (!validator.validate(path)) {
qWarning() << "Schema is not valid, aborting loading of XML document:" << path.toLocalFile();
qCWarning(ARTIKULATE_LOG) << "Schema is not valid, aborting loading of XML document:" << path.toLocalFile();
return document;
}
......@@ -86,10 +86,10 @@ QDomDocument ResourceInterface::loadDomDocument(const QUrl &path, const QXmlSche
QFile file(path.toLocalFile());
if (file.open(QIODevice::ReadOnly)) {
if (!document.setContent(&file, &errorMsg)) {
qWarning() << errorMsg;
qCWarning(ARTIKULATE_LOG) << errorMsg;
}
} else {
qWarning() << "Could not open XML document " << path.toLocalFile() << " for reading, aborting.";
qCWarning(ARTIKULATE_LOG) << "Could not open XML document " << path.toLocalFile() << " for reading, aborting.";
}
return document;
}
......@@ -33,7 +33,7 @@
#include <QIODevice>
#include <QFile>
#include <QDebug>
#include "artikulate_debug.h"
class SkeletonResourcePrivate
{
......@@ -158,13 +158,13 @@ void SkeletonResource::sync()
// if resource was never loaded, it cannot be changed
if (!d->m_skeletonResource) {
qDebug() << "Aborting sync, skeleton was not parsed.";
qCDebug(ARTIKULATE_LOG) << "Aborting sync, skeleton was not parsed.";
return;
}
// // not writing back if not modified
// if (!d->m_skeletonResource->modified()) {
// qDebug() << "Aborting sync, skeleton was not modified.";
// qCDebug(ARTIKULATE_LOG) << "Aborting sync, skeleton was not modified.";
// return;
// }
......@@ -232,7 +232,7 @@ void SkeletonResource::sync()
//TODO port to KSaveFile
QFile file(path().toLocalFile());
if (!file.open(QIODevice::WriteOnly)) {
qWarning() << "Unable to open file " << file.fileName() << " in write mode, aborting.";
qCWarning(ARTIKULATE_LOG) << "Unable to open file " << file.fileName() << " in write mode, aborting.";
return;
}
......@@ -265,7 +265,7 @@ QObject * SkeletonResource::resource()
}
if (!path().isLocalFile()) {
qWarning() << "Cannot open skeleton file at " << path().toLocalFile() << ", aborting.";
qCWarning(ARTIKULATE_LOG) << "Cannot open skeleton file at " << path().toLocalFile() << ", aborting.";
return nullptr;
}
......@@ -276,7 +276,7 @@ QObject * SkeletonResource::resource()
QDomDocument document = loadDomDocument(path(), schema);
if (document.isNull()) {
qWarning() << "Could not parse document " << path().toLocalFile() << ", aborting.";
qCWarning(ARTIKULATE_LOG) << "Could not parse document " << path().toLocalFile() << ", aborting.";
return nullptr;
}
......
......@@ -26,7 +26,7 @@
#include "resourcemanager.h"
#include "phonemegroup.h"
#include <QDebug>
#include "artikulate_debug.h"
#include <KLocalizedString>
#include <QStringList>
#include <QPair>
......@@ -46,7 +46,7 @@ Skeleton::~Skeleton()
void Skeleton::sync()
{
if (!file().isValid() || file().isEmpty() || m_resource == nullptr) {
qWarning() << "No file path set, aborting sync operation.";
qCWarning(ARTIKULATE_LOG) << "No file path set, aborting sync operation.";
return;
}
m_resource->sync();
......
......@@ -24,7 +24,7 @@
#include "core/unit.h"
#include "core/phrase.h"
#include "core/phonemegroup.h"
#include <QDebug>
#include "artikulate_debug.h"
TrainingSession::TrainingSession(QObject *parent)
: QObject(parent)
......@@ -127,7 +127,7 @@ void TrainingSession::showNextPhrase()
void TrainingSession::skipPhrase()
{
//FIXME
qWarning() << "Learning profile update not implemented";
qCWarning(ARTIKULATE_LOG) << "Learning profile update not implemented";
showNextPhrase();
}
......
......@@ -28,7 +28,7 @@
#include <QStringList>
#include <QUuid>
#include <QDebug>
#include "artikulate_debug.h"
#include <KLocalizedString>
#include <QUrl>
......@@ -106,7 +106,7 @@ void Unit::addPhrase(Phrase *phrase)
QList<Phrase *>::ConstIterator iter = m_phraseList.constBegin();
while (iter != m_phraseList.constEnd()) {
if (phrase->id() == (*iter)->id()) {
qWarning() << "Phrase is already contained in this unit, aborting";
qCWarning(ARTIKULATE_LOG) << "Phrase is already contained in this unit, aborting";
return;
}
++iter;
......@@ -149,7 +149,7 @@ void Unit::excludeSkeletonPhrase(const QString &phraseId)
return;
}
}
qWarning() << "Could not exclude phrase with ID " << phraseId << ", no phrase with this ID.";
qCWarning(ARTIKULATE_LOG) << "Could not exclude phrase with ID " << phraseId << ", no phrase with this ID.";
}
void Unit::includeSkeletonPhrase(const QString &phraseId)
......@@ -161,5 +161,5 @@ void Unit::includeSkeletonPhrase(const QString &phraseId)
return;
}
}
qWarning() << "Could not include phrase with ID " << phraseId << ", no phrase with this ID.";
qCWarning(ARTIKULATE_LOG) << "Could not include phrase with ID " << phraseId << ", no phrase with this ID.";
}
......@@ -25,7 +25,7 @@
#include <KAboutData>
#include <KCrash>
#include <KLocalizedString>
#include <QDebug>
#include "artikulate_debug.h"
int main(int argc, char **argv)
{
......
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