# HG changeset patch # User thomas_-_s # Date 1292972870 0 # Node ID 4ec2ac09969debf29e892f67f4f75e69db0db1bd # Parent e64c04dc6f61e82b045bd40e5da522c13a6c4ca1 Renamed the logger class and put it into a namespace for later universal tool reuse. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@1031 59b1889a-e5ac-428c-b0c7-476e01d41282 diff -r e64c04dc6f61 -r 4ec2ac09969d UniversalIndentGUI.pro --- a/UniversalIndentGUI.pro Fri Oct 22 16:26:27 2010 +0000 +++ b/UniversalIndentGUI.pro Tue Dec 21 23:07:50 2010 +0000 @@ -189,20 +189,20 @@ src/UiGuiHighlighter.h \ src/UiGuiIndentServer.h \ src/UiGuiIniFileParser.h \ - src/UiGuiLogger.h \ src/UiGuiSettings.h \ src/UiGuiSettingsDialog.h \ src/UiGuiSystemInfo.h \ src/UiGuiVersion.h \ - src/UpdateCheckDialog.h + src/UpdateCheckDialog.h \ + src/debugging/TSLogger.h FORMS += src/MainWindow.ui \ src/ToolBarWidget.ui \ - src/UiGuiLoggerDialog.ui \ src/UiGuiSettingsDialog.ui \ src/AboutDialog.ui \ - src/UpdateCheckDialog.ui + src/UpdateCheckDialog.ui \ + src/debugging/TSLoggerDialog.ui SOURCES += src/AboutDialog.cpp \ src/AboutDialogGraphicsView.cpp \ @@ -215,12 +215,12 @@ src/UiGuiHighlighter.cpp \ src/UiGuiIndentServer.cpp \ src/UiGuiIniFileParser.cpp \ - src/UiGuiLogger.cpp \ src/UiGuiSettings.cpp \ src/UiGuiSettingsDialog.cpp \ src/UiGuiSystemInfo.cpp \ src/UiGuiVersion.cpp \ - src/UpdateCheckDialog.cpp + src/UpdateCheckDialog.cpp \ + src/debugging/TSLogger.cpp RESOURCES += resources/Icons.qrc RC_FILE = resources/programicon.rc diff -r e64c04dc6f61 -r 4ec2ac09969d src/MainWindow.cpp --- a/src/MainWindow.cpp Fri Oct 22 16:26:27 2010 +0000 +++ b/src/MainWindow.cpp Tue Dec 21 23:07:50 2010 +0000 @@ -21,7 +21,7 @@ #include "ui_MainWindow.h" #include "UiGuiVersion.h" -#include "UiGuiLogger.h" +#include "debugging/TSLogger.h" #include "SettingsPaths.h" #include "ui_ToolBarWidget.h" @@ -57,6 +57,8 @@ #include #include +using namespace tschweitzer; + //! \defgroup grp_MainWindow All concerning main window functionality. /*! @@ -206,7 +208,7 @@ connect( _mainWindowForm->actionExportPDF, SIGNAL(triggered()), this, SLOT(exportToPDF()) ); connect( _mainWindowForm->actionExportHTML, SIGNAL(triggered()), this, SLOT(exportToHTML()) ); connect( _mainWindowForm->actionCheck_for_update, SIGNAL(triggered()), _updateCheckDialog, SLOT(checkForUpdateAndShowDialog()) ); - connect( _mainWindowForm->actionShowLog, SIGNAL(triggered()), UiGuiLogger::getInstance(), SLOT(show()) ); + connect( _mainWindowForm->actionShowLog, SIGNAL(triggered()), debugging::TSLogger::getInstance(), SLOT(show()) ); // Init the menu for selecting one of the recently opened files. updateRecentlyOpenedList(); diff -r e64c04dc6f61 -r 4ec2ac09969d src/UiGuiLogger.cpp --- a/src/UiGuiLogger.cpp Fri Oct 22 16:26:27 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,239 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * 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 in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiLogger.h" -#include "ui_UiGuiLoggerDialog.h" - -#include "SettingsPaths.h" - -#include -#include -#include -#include -#include -#include - -#include - -UiGuiLogger* UiGuiLogger::_instance = NULL; - -/*! - \class UiGuiLogger - \brief This class handles any kind of data logging, for debugging and whatever purpose. - - Beneath being able of displaying a dialog window containing all log messages of the - current session, a log file in the systems temporary directory is used. Its name - is "UiGUI_log.html". - - Setting a verbose level allows to only write messages that have the selected minimum - priority to the log. - */ - -/*! - \brief Returns the only existing instance of UiGuiLogger. If the instance doesn't exist, it will be created. - */ -UiGuiLogger* UiGuiLogger::getInstance(int verboseLevel) { - if ( _instance == NULL ) - _instance = new UiGuiLogger(verboseLevel); - - return _instance; -} - - -/*! - \brief Returns the only existing instance of UiGuiLogger. If the instance doesn't exist, it will be created. - */ -UiGuiLogger* UiGuiLogger::getInstance() { -#ifdef _DEBUG - return UiGuiLogger::getInstance(QtDebugMsg); -#else - return UiGuiLogger::getInstance(QtWarningMsg); -#endif -} - - -/*! - \brief Initializes the dialog and sets the path to the log file in the systems temporary directory. - Sets the default verbose level to warning level. - */ -UiGuiLogger::UiGuiLogger(int verboseLevel) : QDialog() { - _uiGuiLoggerDialogForm = new Ui::UiGuiLoggerDialog(); - _uiGuiLoggerDialogForm->setupUi(this); -#ifdef _DEBUG - _verboseLevel = QtDebugMsg; -#else - _verboseLevel = QtMsgType(verboseLevel); -#endif - - _logFileInitState = NOTINITIALZED; - - connect( _uiGuiLoggerDialogForm->openLogFileFolderToolButton, SIGNAL(clicked()), this, SLOT(openLogFileFolder()) ); - - // Make the main application not to wait for the logging window to close. - setAttribute(Qt::WA_QuitOnClose, false); -} - - -/*! - \brief Logs all incoming messages \a msg to the dialogs text edit and to the log file. - - Only messages whos \a type have a higher priority than the set verbose level are logged. - */ -void UiGuiLogger::messageHandler(QtMsgType type, const char *msg) { - if ( _instance == NULL ) - _instance = UiGuiLogger::getInstance(); - - // Only log messages that have a higher or equal priority than set with the verbose level. - if ( type < _instance->_verboseLevel ) - return; - - // Init log message with prepended date and time. - QString message = QDateTime::currentDateTime().toString(); - - // Depending on the QtMsgType prepend a different colored Debug, Warning, Critical or Fatal. - switch (type) { - case QtDebugMsg : - message += " Debug: "; - break; - case QtWarningMsg : - message += " Warning: "; - break; - case QtCriticalMsg : - message += "Critical: "; - break; - case QtFatalMsg : - message += " Fatal: "; - // This one is no Qt message type, but can be used to send info messages to the log - // by calling UiGuiLogger::messageHandler() directly. - case UiGuiInfoMsg : - message += " Info: "; - break; - } - - // Append the ti UTF-8 back converted message parameter. - message += QString::fromUtf8( msg ) + "
\n"; - - // Write the message to the log windows text edit. - _instance->_uiGuiLoggerDialogForm->logTextEdit->append( message ); - - // Write/append the log message to the log file. - _instance->writeToLogFile( message ); - - // In case of a fatal error abort the application. - if ( type == QtFatalMsg ) - abort(); -} - - -/*! - \brief Calling this the verbose level can be set in a range from 0 to 3 - which is equal to debug, warning, critical and fatal priority. - */ -void UiGuiLogger::setVerboseLevel(int level) { - if ( level < 0 ) - _verboseLevel = QtDebugMsg; - if ( level > 3 ) - _verboseLevel = QtFatalMsg; - else - _verboseLevel = QtMsgType(level); -} - - -/*! - \brief Deletes the existing _instance of UiGuiLogger. - */ -void UiGuiLogger::deleteInstance() { - if ( _instance != NULL ) { - delete _instance; - _instance = NULL; - } -} - - -/*! - \brief Opens the folder that contains the created log file with the name "UiGUI_log.html". - */ -void UiGuiLogger::openLogFileFolder() { - QDesktopServices::openUrl( QFileInfo( _logFile ).absolutePath() ); -} - - -/*! - \brief Writes the \a message to the used log file. - */ -void UiGuiLogger::writeToLogFile(const QString &message) { - // If the file where all logging messages should go to isn't initilized yet, do that now. - if ( _logFileInitState == NOTINITIALZED ) { - _logFileInitState = INITIALIZING; - - // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this. - // Remove any trailing slashes. - QString tempPath = QFileInfo( SettingsPaths::getTempPath() ).absolutePath(); - while ( tempPath.right(1) == "/" ) { - tempPath.chop(1); - } - - // To make the temporary log file invulnerable against file symbolic link hacks - // append the current date and time up to milliseconds to its name and a random character. - QString logFileName = "UiGUI_log_" + QDateTime::currentDateTime().toString("yyyyMMdd"); - logFileName += "-" + QDateTime::currentDateTime().toString("hhmmsszzz"); - // By random decide whether to append a number or an upper or lower case character. - qsrand( time(NULL) ); - unsigned char randomChar; - switch ( qrand() % 3 ) { - // Append a number from 0 to 9. - case 0 : - randomChar = qrand() % 10 + '0'; - break; - // Append a upper case characer between A and Z. - case 1 : - randomChar = qrand() % 26 + 'A'; - break; - // Append a lower case characer between a and z. - default : - randomChar = qrand() % 26 + 'a'; - break; - } - logFileName += "_" + QString(randomChar) + ".html"; - - _logFile.setFileName( tempPath + "/" + logFileName ); - - // Set the tooltip of the open log file folder button to show the unique name of the log file. - _uiGuiLoggerDialogForm->openLogFileFolderToolButton->setToolTip( _uiGuiLoggerDialogForm->openLogFileFolderToolButton->toolTip() + " (" + logFileName + ")" ); - - _logFileInitState = INITIALZED; - } - - // Add the message to the message queue. - _messageQueue << message; - - // If the logging file is initialzed, write all messages contained in the message queue into the file. - if ( _logFileInitState == INITIALZED ) { - // Write/append the log message to the log file. - if ( _logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append) ) { - QTextStream out(&_logFile); - - while ( !_messageQueue.isEmpty() ) { - out << _messageQueue.takeFirst() << "\n"; - } - - _logFile.close(); - } - } -} diff -r e64c04dc6f61 -r 4ec2ac09969d src/UiGuiLogger.h --- a/src/UiGuiLogger.h Fri Oct 22 16:26:27 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * 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 in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUILOGGER_H -#define UIGUILOGGER_H - -#define UiGuiInfoMsg QtMsgType(4) - -#include -#include - -namespace Ui { - class UiGuiLoggerDialog; -} - - -class UiGuiLogger : public QDialog -{ - Q_OBJECT - -public: - static UiGuiLogger* getInstance(int verboseLevel); - static UiGuiLogger* getInstance(); - static void messageHandler(QtMsgType type, const char *msg); - static void deleteInstance(); - void setVerboseLevel(int level); - -private slots: - void openLogFileFolder(); - -private: - Ui::UiGuiLoggerDialog *_uiGuiLoggerDialogForm; - - enum LogFileInitState { NOTINITIALZED, INITIALIZING, INITIALZED } _logFileInitState; - UiGuiLogger(int verboseLevel); - void writeToLogFile(const QString &message); - - static UiGuiLogger* _instance; - QtMsgType _verboseLevel; - QFile _logFile; - QStringList _messageQueue; -}; - -#endif // UIGUILOGGER_H diff -r e64c04dc6f61 -r 4ec2ac09969d src/UiGuiLoggerDialog.ui --- a/src/UiGuiLoggerDialog.ui Fri Oct 22 16:26:27 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ - - - UiGuiLoggerDialog - - - - 0 - 0 - 1030 - 263 - - - - Log - - - - :/mainWindow/document-properties.png:/mainWindow/document-properties.png - - - - - - Logged messages - - - - - - - true - - - - - - - - - Clear log - - - ... - - - - :/mainWindow/edit-clear.png:/mainWindow/edit-clear.png - - - - - - - Open folder containing log file. - - - Open folder containing log file. - - - - :/mainWindow/document-open.png:/mainWindow/document-open.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QDialogButtonBox::Close - - - - - - - - - - - - - UiGuiLoggerDialog - finished(int) - UiGuiLoggerDialog - close() - - - 2 - 45 - - - 5 - 59 - - - - - buttonBox - clicked(QAbstractButton*) - UiGuiLoggerDialog - close() - - - 419 - 280 - - - 477 - 263 - - - - - cleanUpToolButton - clicked() - logTextEdit - clear() - - - 27 - 282 - - - 22 - 231 - - - - - diff -r e64c04dc6f61 -r 4ec2ac09969d src/debugging/TSLogger.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/debugging/TSLogger.cpp Tue Dec 21 23:07:50 2010 +0000 @@ -0,0 +1,251 @@ +/*************************************************************************** + * Copyright (C) 2006-2010 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * 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 in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "TSLogger.h" +#include "ui_TSLoggerDialog.h" + +#include "SettingsPaths.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace tschweitzer; +using namespace tschweitzer::debugging; + +TSLogger* TSLogger::_instance = NULL; + +/*! + \class TSLogger + \brief This class handles any kind of data logging, for debugging and whatever purpose. + + Beneath being able of displaying a dialog window containing all log messages of the + current session, a log file in the systems temporary directory is used. Its name + is "UiGUI_log.html". + + Setting a verbose level allows to only write messages that have the selected minimum + priority to the log. + */ + +/*! + \brief Returns the only existing instance of TSLogger. If the instance doesn't exist, it will be created. + */ +TSLogger* TSLogger::getInstance(int verboseLevel) { + if ( _instance == NULL ) + _instance = new TSLogger(verboseLevel); + + return _instance; +} + + +/*! + \brief Returns the only existing instance of TSLogger. If the instance doesn't exist, it will be created. + */ +TSLogger* TSLogger::getInstance() { +#ifdef _DEBUG + return TSLogger::getInstance(QtDebugMsg); +#else + return TSLogger::getInstance(QtWarningMsg); +#endif +} + + +/*! + \brief Initializes the dialog and sets the path to the log file in the systems temporary directory. + Sets the default verbose level to warning level. + */ +TSLogger::TSLogger(int verboseLevel) : QDialog() { + _TSLoggerDialogForm = new Ui::TSLoggerDialog(); + _TSLoggerDialogForm->setupUi(this); +#ifdef _DEBUG + _verboseLevel = QtDebugMsg; +#else + _verboseLevel = QtMsgType(verboseLevel); +#endif + + _logFileInitState = NOTINITIALZED; + + connect( _TSLoggerDialogForm->openLogFileFolderToolButton, SIGNAL(clicked()), this, SLOT(openLogFileFolder()) ); + + // Make the main application not to wait for the logging window to close. + setAttribute(Qt::WA_QuitOnClose, false); +} + + +/*! + \brief Logs all incoming messages \a msg to the dialogs text edit and to the log file. + + Only messages whos \a type have a higher priority than the set verbose level are logged. + */ +void TSLogger::messageHandler(QtMsgType type, const char *msg) { + if ( _instance == NULL ) + _instance = TSLogger::getInstance(); + +//* + QMessageBox messageBox; + QString messageBoxText = QString::fromUtf8( msg ); + messageBox.setText( messageBoxText ); + messageBox.setWindowModality( Qt::ApplicationModal ); + messageBox.exec(); +//*/ + + // Only log messages that have a higher or equal priority than set with the verbose level. + if ( type < _instance->_verboseLevel ) + return; + + // Init log message with prepended date and time. + QString message = QDateTime::currentDateTime().toString(); + + // Depending on the QtMsgType prepend a different colored Debug, Warning, Critical or Fatal. + switch (type) { + case QtDebugMsg : + message += " Debug: "; + break; + case QtWarningMsg : + message += " Warning: "; + break; + case QtCriticalMsg : + message += "Critical: "; + break; + case QtFatalMsg : + message += " Fatal: "; + // This one is no Qt message type, but can be used to send info messages to the log + // by calling TSLogger::messageHandler() directly. + case TSLoggerInfoMsg : + message += " Info: "; + break; + } + + // Append the to UTF-8 back converted message parameter. + message += QString::fromUtf8( msg ) + "
\n"; + + // Write the message to the log windows text edit. + _instance->_TSLoggerDialogForm->logTextEdit->append( message ); + + // Write/append the log message to the log file. + _instance->writeToLogFile( message ); + + // In case of a fatal error abort the application. + if ( type == QtFatalMsg ) + abort(); +} + + +/*! + \brief Calling this the verbose level can be set in a range from 0 to 3 + which is equal to debug, warning, critical and fatal priority. + */ +void TSLogger::setVerboseLevel(int level) { + if ( level < 0 ) + _verboseLevel = QtDebugMsg; + if ( level > 3 ) + _verboseLevel = QtFatalMsg; + else + _verboseLevel = QtMsgType(level); +} + + +/*! + \brief Deletes the existing _instance of TSLogger. + */ +void TSLogger::deleteInstance() { + if ( _instance != NULL ) { + delete _instance; + _instance = NULL; + } +} + + +/*! + \brief Opens the folder that contains the created log file with the name "UiGUI_log.html". + */ +void TSLogger::openLogFileFolder() { + QDesktopServices::openUrl( QFileInfo( _logFile ).absolutePath() ); +} + + +/*! + \brief Writes the \a message to the used log file. + */ +void TSLogger::writeToLogFile(const QString &message) { + // If the file where all logging messages should go to isn't initilized yet, do that now. + if ( _logFileInitState == NOTINITIALZED ) { + _logFileInitState = INITIALIZING; + + // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this. + // Remove any trailing slashes. + QString tempPath = QFileInfo( SettingsPaths::getTempPath() ).absolutePath(); + while ( tempPath.right(1) == "/" ) { + tempPath.chop(1); + } + + // To make the temporary log file invulnerable against file symbolic link hacks + // append the current date and time up to milliseconds to its name and a random character. + QString logFileName = "UiGUI_log_" + QDateTime::currentDateTime().toString("yyyyMMdd"); + logFileName += "-" + QDateTime::currentDateTime().toString("hhmmsszzz"); + // By random decide whether to append a number or an upper or lower case character. + qsrand( time(NULL) ); + unsigned char randomChar; + switch ( qrand() % 3 ) { + // Append a number from 0 to 9. + case 0 : + randomChar = qrand() % 10 + '0'; + break; + // Append a upper case characer between A and Z. + case 1 : + randomChar = qrand() % 26 + 'A'; + break; + // Append a lower case characer between a and z. + default : + randomChar = qrand() % 26 + 'a'; + break; + } + logFileName += "_" + QString(randomChar) + ".html"; + + _logFile.setFileName( tempPath + "/" + logFileName ); + + // Set the tooltip of the open log file folder button to show the unique name of the log file. + _TSLoggerDialogForm->openLogFileFolderToolButton->setToolTip( _TSLoggerDialogForm->openLogFileFolderToolButton->toolTip() + " (" + logFileName + ")" ); + + _logFileInitState = INITIALZED; + } + + // Add the message to the message queue. + _messageQueue << message; + + // If the logging file is initialzed, write all messages contained in the message queue into the file. + if ( _logFileInitState == INITIALZED ) { + // Write/append the log message to the log file. + if ( _logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append) ) { + QTextStream out(&_logFile); + + while ( !_messageQueue.isEmpty() ) { + out << _messageQueue.takeFirst() << "\n"; + } + + _logFile.close(); + } + } +} diff -r e64c04dc6f61 -r 4ec2ac09969d src/debugging/TSLogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/debugging/TSLogger.h Tue Dec 21 23:07:50 2010 +0000 @@ -0,0 +1,63 @@ +/*************************************************************************** + * Copyright (C) 2006-2010 by Thomas Schweitzer * + * thomas-schweitzer(at)arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2.0 as * + * published by the Free Software Foundation. * + * * + * 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 in the file LICENSE.GPL; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef TSLogger_H +#define TSLogger_H + +#include +#include + +namespace Ui { + class TSLoggerDialog; +} + +namespace tschweitzer { namespace debugging { + +#define TSLoggerInfoMsg QtMsgType(4) + +class TSLogger : public QDialog +{ + Q_OBJECT + +public: + static TSLogger* getInstance(int verboseLevel); + static TSLogger* getInstance(); + static void messageHandler(QtMsgType type, const char *msg); + static void deleteInstance(); + void setVerboseLevel(int level); + +private slots: + void openLogFileFolder(); + +private: + Ui::TSLoggerDialog *_TSLoggerDialogForm; + + enum LogFileInitState { NOTINITIALZED, INITIALIZING, INITIALZED } _logFileInitState; + TSLogger(int verboseLevel); + void writeToLogFile(const QString &message); + + static TSLogger* _instance; + QtMsgType _verboseLevel; + QFile _logFile; + QStringList _messageQueue; +}; + +}} // namespace tschweitzer::debugging + +#endif // TSLogger_H diff -r e64c04dc6f61 -r 4ec2ac09969d src/debugging/TSLoggerDialog.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/debugging/TSLoggerDialog.ui Tue Dec 21 23:07:50 2010 +0000 @@ -0,0 +1,142 @@ + + + TSLoggerDialog + + + + 0 + 0 + 1030 + 263 + + + + Log + + + + :/mainWindow/document-properties.png:/mainWindow/document-properties.png + + + + + + Logged messages + + + + + + + true + + + + + + + + + Clear log + + + ... + + + + :/mainWindow/edit-clear.png:/mainWindow/edit-clear.png + + + + + + + Open folder containing log file. + + + Open folder containing log file. + + + + :/mainWindow/document-open.png:/mainWindow/document-open.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QDialogButtonBox::Close + + + + + + + + + + + + + TSLoggerDialog + finished(int) + TSLoggerDialog + close() + + + 2 + 45 + + + 5 + 59 + + + + + buttonBox + clicked(QAbstractButton*) + TSLoggerDialog + close() + + + 419 + 280 + + + 477 + 263 + + + + + cleanUpToolButton + clicked() + logTextEdit + clear() + + + 27 + 282 + + + 22 + 231 + + + + + diff -r e64c04dc6f61 -r 4ec2ac09969d src/main.cpp --- a/src/main.cpp Fri Oct 22 16:26:27 2010 +0000 +++ b/src/main.cpp Tue Dec 21 23:07:50 2010 +0000 @@ -20,7 +20,7 @@ #include "MainWindow.h" #include "UiGuiIndentServer.h" -#include "UiGuiLogger.h" +#include "debugging/TSLogger.h" #include "UiGuiIniFileParser.h" #include "UiGuiSettings.h" #include "UiGuiVersion.h" @@ -102,7 +102,7 @@ } #endif - +using namespace tschweitzer::debugging; /*! /brief Entry point to UniversalIndentGUI application. @@ -217,15 +217,15 @@ // Setting UTF-8 as default 8-Bit encoding to ensure that qDebug does no false string conversion. QTextCodec::setCodecForCStrings( QTextCodec::codecForName("UTF-8") ); QTextCodec::setCodecForLocale( QTextCodec::codecForName("UTF-8") ); - // Force creation of an UiGuiLogger instance here, to avoid recursion with SettingsPaths init function. + // Force creation of an TSLogger instance here, to avoid recursion with SettingsPaths init function. #ifdef _DEBUG - UiGuiLogger::getInstance(0); + TSLogger::getInstance(0); #else - UiGuiLogger::getInstance(verboseLevel); + TSLogger::getInstance(verboseLevel); #endif - qInstallMsgHandler( UiGuiLogger::messageHandler ); - UiGuiLogger::messageHandler( UiGuiInfoMsg, QString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii() ); - UiGuiLogger::messageHandler( UiGuiInfoMsg, QString("Running on %1").arg(UiGuiSystemInfo::getOperatingSystem()).toAscii() ); + qInstallMsgHandler( TSLogger::messageHandler ); + TSLogger::messageHandler( TSLoggerInfoMsg, QString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii() ); + TSLogger::messageHandler( TSLoggerInfoMsg, QString("Running on %1").arg(UiGuiSystemInfo::getOperatingSystem()).toAscii() ); // Set default values for all by UniversalIndentGUI used settings objects. QCoreApplication::setOrganizationName("UniversalIndentGUI"); @@ -257,7 +257,7 @@ delete mainWindow; SettingsPaths::cleanAndRemoveTempDir(); - UiGuiLogger::deleteInstance(); + TSLogger::deleteInstance(); return returnValue; }