[SCM] Kaboom - Debian KDE 3->4 migration tool branch, master, updated. master/1.1.0-6-g13c1214
George Kiagiadakis
gkiagia-guest at alioth.debian.org
Sun Apr 12 10:14:35 UTC 2009
The following commit has been merged in the master branch:
commit 13c1214ec8070c39519cdd1f1474f4bde2b73510
Author: George Kiagiadakis <gkiagia at users.sourceforge.net>
Date: Sun Apr 12 13:14:00 2009 +0300
Add support for logging output to a file.
diff --git a/debian/changelog b/debian/changelog
index ddeefd7..57808fd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,7 @@ kaboom (1.1.1~pre1) UNRELEASED; urgency=low
* Force showing kaboom at the upper left corner of the screen,
so that it doesn't get outside of the screen when it grows bigger.
* Fix integer overflow bug in 32-bit architectures. (Closes: #522834)
+ * Add support for logging output to a file.
-- Debian Qt/KDE Maintainers <debian-qt-kde at lists.debian.org> Fri, 10 Apr 2009 00:57:13 +0300
diff --git a/kaboom.pro b/kaboom.pro
index 126c7a8..06e5f7b 100644
--- a/kaboom.pro
+++ b/kaboom.pro
@@ -43,6 +43,7 @@ SOURCES += \
diroperations/diroperations.cpp \
diroperations/recursivedirjob.cpp \
diroperations/progresswidget.cpp \
- richradiobutton.cpp
+ richradiobutton.cpp \
+ kaboomlog.cpp
RESOURCES += resources.qrc
diff --git a/kaboomlog.cpp b/kaboomlog.cpp
new file mode 100644
index 0000000..ad23943
--- /dev/null
+++ b/kaboomlog.cpp
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2009 George Kiagiadakis <gkiagia at users.sourceforge.net>
+
+ 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 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 "kaboomlog.h"
+#include <QtCore/QFile>
+#include <QtCore/QDebug>
+#include <iostream>
+
+QFile *KaboomLog::m_logFile = 0;
+
+void KaboomLog::init(const QString & fileName)
+{
+ m_logFile = new QFile(fileName);
+ if ( !m_logFile->open(QIODevice::WriteOnly) ) {
+ delete m_logFile;
+ qCritical() << "Could not open log file" << fileName;
+ } else {
+ qInstallMsgHandler(logMessageOutput);
+ }
+}
+
+void KaboomLog::cleanup()
+{
+ if ( m_logFile != 0 ) {
+ qInstallMsgHandler(0); //restore the default message handler
+ m_logFile->close();
+ delete m_logFile;
+ m_logFile = 0;
+ }
+}
+
+void KaboomLog::logMessageOutput(QtMsgType type, const char *msg)
+{
+ m_logFile->write(msg);
+ m_logFile->write("\n");
+ std::cerr << msg << std::endl;
+ if ( type == QtFatalMsg ) {
+ cleanup();
+ abort();
+ }
+}
diff --git a/warningpage.h b/kaboomlog.h
similarity index 65%
copy from warningpage.h
copy to kaboomlog.h
index 814b110..82b1eeb 100644
--- a/warningpage.h
+++ b/kaboomlog.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2009 Sune Vuorela <sune at vuorela.dk>
+ Copyright (C) 2009 George Kiagiadakis <gkiagia at users.sourceforge.net>
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
@@ -14,16 +14,21 @@
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 WARNINGPAGE_H
-#define WARNINGPAGE_H
+#ifndef KABOOMLOG_H
+#define KABOOMLOG_H
-#include <QtGui>
+#include <QtCore/QtGlobal>
+class QFile;
-class WarningPage : public QWizardPage
+class KaboomLog
{
- Q_OBJECT
- public:
- WarningPage(QWidget *parent=0);
+public:
+ static void init(const QString & fileName);
+ static void cleanup();
+
+private:
+ static QFile *m_logFile;
+ static void logMessageOutput(QtMsgType type, const char *msg);
};
-#endif // WARNINGPAGE_H
+#endif
diff --git a/kaboomsettings.cpp b/kaboomsettings.cpp
index 9ed63a4..ab33f4c 100644
--- a/kaboomsettings.cpp
+++ b/kaboomsettings.cpp
@@ -15,13 +15,14 @@
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 "kaboomsettings.h"
+#include "kaboomlog.h"
+
#include <QtCore/QStringList>
#include <QtCore/QDebug>
#include <cstring>
#include <unistd.h>
-#include "kaboomsettings.h"
-
#define DEFAULT_KDEDIR "/.kde"
#define DEFAULT_KDE4DIR "/.kde4"
#define DEFAULT_KDE3BACKUPDIR "/kde3-backup"
@@ -63,6 +64,8 @@ KaboomSettings::KaboomSettings(int argc, char** argv)
setKdehomePath(Kde3Backup, QFile::decodeName(argv[++i]));
} else if (strcmp(argv[i], "--stamp") == 0 && i+1 < argc) {
m_stampFile.setFileName(QFile::decodeName(argv[++i]));
+ } else if (qstrcmp(argv[i], "--log") == 0) {
+ KaboomLog::init(argv[++i]);
} else if (strcmp(argv[i], "--help") == 0) {
// TODO: show help
}
diff --git a/main.cpp b/main.cpp
index b19e0dc..e582f56 100644
--- a/main.cpp
+++ b/main.cpp
@@ -16,6 +16,7 @@
*/
#include "migrationtool.h"
#include "kaboomsettings.h"
+#include "kaboomlog.h"
#include <QApplication>
#include <QFile>
#include <QTranslator>
@@ -64,5 +65,6 @@ int main(int argc, char* argv[])
}
}
+ KaboomLog::cleanup();
return exitvalue;
}
--
Kaboom - Debian KDE 3->4 migration tool
More information about the pkg-kde-commits
mailing list