changeset 691:2af225b848bb

Enhanced the logger by an info message type and until now use it at start to log the version. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@960 59b1889a-e5ac-428c-b0c7-476e01d41282
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Thu, 28 May 2009 10:20:05 +0000
parents eec59baf5bee
children e3ff3c85d271
files src/UiGuiLogger.cpp src/UiGuiLogger.h src/UiGuiLoggerDialog.ui src/main.cpp
diffstat 4 files changed, 23 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/UiGuiLogger.cpp	Thu May 28 10:18:34 2009 +0000
+++ b/src/UiGuiLogger.cpp	Thu May 28 10:20:05 2009 +0000
@@ -48,11 +48,11 @@
     setupUi(this);
     verboseLevel = QtWarningMsg;
 
-    // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this.
+    // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this.
     // Remove any trailing slashes.
-    QString tempPath = QDir::tempPath();
-    while ( tempPath.right(1) == "/" ) {
-        tempPath.chop(1);
+    QString tempPath = QDir::tempPath();
+    while ( tempPath.right(1) == "/" ) {
+        tempPath.chop(1);
     }
     logFile.setFileName( tempPath + "/UiGUI_log.html" );
 
@@ -93,6 +93,11 @@
             break;
         case QtFatalMsg:
             message += " <span style=\"font-weight:bold; color:#D60000;\">Fatal:</span> ";
+        // 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 += " <span style=\"font-weight:bold; color:darkgray;\">Info:</span> ";
+            break;
     }
 
     // Append the ti UTF-8 back converted message parameter.
--- a/src/UiGuiLogger.h	Thu May 28 10:18:34 2009 +0000
+++ b/src/UiGuiLogger.h	Thu May 28 10:20:05 2009 +0000
@@ -20,6 +20,8 @@
 #ifndef UIGUILOGGER_H
 #define UIGUILOGGER_H
 
+#define UiGuiInfoMsg QtMsgType(4)
+
 #include <QDialog>
 #include <QFile>
 
--- a/src/UiGuiLoggerDialog.ui	Thu May 28 10:18:34 2009 +0000
+++ b/src/UiGuiLoggerDialog.ui	Thu May 28 10:20:05 2009 +0000
@@ -37,7 +37,7 @@
      <item>
       <widget class="QToolButton" name="cleanUpToolButton">
        <property name="toolTip">
-        <string>Cleanup log</string>
+        <string>Clear log</string>
        </property>
        <property name="text">
         <string>...</string>
--- a/src/main.cpp	Thu May 28 10:18:34 2009 +0000
+++ b/src/main.cpp	Thu May 28 10:20:05 2009 +0000
@@ -24,6 +24,7 @@
 #include "UiGuiLogger.h"
 #include "UiGuiIniFileParser.h"
 #include "UiGuiSettings.h"
+#include "UiGuiVersion.h"
 
 /*!
     /brief Entry point to UniversalIndentGUI application.
@@ -46,6 +47,15 @@
     MainWindow *mainWindow = NULL;
     IndentHandler *indentHandler = NULL;
 
+    // Init and install the logger function.
+    // 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.
+    UiGuiLogger::getInstance();
+    qInstallMsgHandler( UiGuiLogger::messageHandler );
+    UiGuiLogger::messageHandler( UiGuiInfoMsg, QString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii() );
+
     // Parse command line arguments. First parameter is the executable itself.
     for ( int i = 1; i < argc; i++ ) {
         QString currentArg = argv[i];
@@ -99,12 +109,7 @@
         }
     }
 
-    // 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.
-    UiGuiLogger::getInstance();
-    qInstallMsgHandler( UiGuiLogger::messageHandler );
+    // Set the verbose level for the logger. If not in debug, use the value given via command line or default to 1.
 #ifdef _DEBUG
     UiGuiLogger::getInstance()->setVerboseLevel(0);
 #else