From 281a7702cf2b83f13eab74d38758893584e7ecb6 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 6 Sep 2024 10:16:09 +0900 Subject: [PATCH] Remove logger code Signed-off-by: Michele Calgaro --- icons/CMakeLists.txt | 1 - icons/document-properties.png | Bin 1115 -> 0 bytes src/CMakeLists.txt | 7 +- src/MainWindow.cpp | 8 - src/MainWindowBase.ui | 16 -- src/debugging/TSLogger.cpp | 301 -------------------------------- src/debugging/TSLogger.h | 72 -------- src/debugging/TSLoggerDialog.ui | 142 --------------- src/main.cpp | 20 +-- 9 files changed, 5 insertions(+), 562 deletions(-) delete mode 100755 icons/document-properties.png delete mode 100644 src/debugging/TSLogger.cpp delete mode 100644 src/debugging/TSLogger.h delete mode 100755 src/debugging/TSLoggerDialog.ui diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index 0739cd4..50abe3b 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -3,7 +3,6 @@ install( accessories-text-editor.png applications-system.png document-open.png - document-properties.png document-save.png document-save-as.png edit-clear.png diff --git a/icons/document-properties.png b/icons/document-properties.png deleted file mode 100755 index fa697db405aa4f9623d839d18449132402a10aac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1115 zcmV-h1f=_kP)XA7znF`Ov6&>(Gu>U)dl9?n>GWhWaqsrPp}NjMeP4a&oT?i5 zznhc;_wV2T-S_^6Jj8>~fk|c{$31nI37R$XjKMjFN@k#>L+DbqXVQXs(V@&0O zRWYqKola*W_*4Q#a1r6kl`EA>Od?RWT-~Vzs?s1Lynp{5V@xIBBn7(N?ra2#0OdO9 zbUI_Z55tgGuU=uTWnp1~^XJdgZnuvu##0f<=Vb-bG$o26(lli-7_hUm!`9Xo&1Mr3 zL2J$G>gwqUJb(V28#ivadAHj=lK*bE%j3t7iJ}Ol6iJeB?%X-r?e?!J0C4;EZP))I z!n=3xDr=zGZ1VBrN369NV|e}gHQ&E~$MZba*4AbxkYyPna-=0YoeoN=%Cq6~=g+`l z;fV;>u3b9kdnNUc^wDaG>gGS{zP|1|~5T`)H{M-)XEV|euF z5kU~3wPr9F5Jizw#ac@khP-(3f*=UEdiAQ?{fP-wN!4gHSXx@*;NXBHNr>Z^BuU)S zEF$>6kLP&=L4Yxa)z#IpVy#+Nl>=#-j?MGMl~P>3e3|@>pp?S%Jbd3L2m+^w=Xofl zh@yzi%}uvPuFi=RC;}IW^m;w!=jYko-E~KHF;&)Dr%D{hL{Y^2{5+Q~U7DQ$z>_CW zxOMB6o3E{{xi>->hD1?BtyZJeYB3lLc=qfWS(dp}_`XlS-)DP!n~N7O9s#c;kfy22 z)tx(ch~wBP@b>N7vFkV=d%Ye2XU?3V*XuDH4$)epwPs~yg?_(Z34W{s<%0-deSQ5% zd*%mI?qL|Rxw(nf+9{#6o}ECIy?OIytm=#8ir;xFYOT3&;lgYLiYX{tu0VO$RceG` z$hU9bT(_K%itkGyRT+e%+H?c0JnTSxY*8vEEU=LUUegLB~fjY4K_3PKa?%uuor-=M^ zD#Xb){PgM5-#{DCz&2ou8rFao&;%BL&L{WJjNlw@_5j!gz5x4B@#pj>@Z8UF`eXlO hW`Kl4*++oO=f7U1bolmc1l0fl002ovPDHLkV1h9_E3E(k diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 85b8358..64f9e9a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,15 +18,13 @@ link_directories( ) -##### other data ################################ - - ##### tdeio_appinfo (module) ####################### set( target universal-indent-gui-tqt ) set( ${target}_SRCS # completed + AboutDialogBase.ui MainWindowBase.ui ToolBarWidget.ui @@ -36,10 +34,9 @@ set( ${target}_SRCS UiGuiErrorMessage.cpp UiGuiHighlighter.cpp UiGuiIniFileParser.cpp - UiGuiSettings.cpp + UiGuiSettings.cpp # ongoing - AboutDialogBase.ui UiGuiSettingsDialogBase.ui AboutDialog.cpp diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index b5aed4c..14c10dd 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -20,8 +20,6 @@ #include "config.h" #include "MainWindow.h" -///-- #include "debugging/TSLogger.h" - #include "stdlib.h" #include "AboutDialog.h" @@ -57,8 +55,6 @@ #include ///-- #include -///-- using namespace tschweitzer; - /* \brief Main window of UniversalIndentGUI-tqt @@ -174,7 +170,6 @@ void MainWindow::initMainWindow() actionIndenterParameterTooltipsEnabled->setIconSet(TQPixmap(ICONS_PATH + "tooltip.png")); actionShowSettings->setIconSet(TQPixmap(ICONS_PATH + "preferences-system.png")); // - Help menu - actionShowLog->setIconSet(TQPixmap(ICONS_PATH + "document-properties.png")); actionAboutUniversalIndentGUITQt->setIconSet(TQPixmap(ICONS_PATH + "info.png")); // Menu ids m_actionClearRecentlyOpenedListId = popupMenuRecentlyOpenedFiles->idAt( @@ -245,9 +240,6 @@ void MainWindow::initMainWindow() connect(m_settings, TQ_SIGNAL(indenterParameterTooltipsEnabled(bool)), this, TQ_SLOT(setIndenterParameterTooltips(bool))); -///-- connect(actionShowLog, TQ_SIGNAL(activated()), -///-- debugging::TSLogger::getInstance(), TQ_SLOT(show())); - // Init the menu for selecting one of the recently opened files. initRecentlyOpenedList(); updateRecentlyOpenedList(); diff --git a/src/MainWindowBase.ui b/src/MainWindowBase.ui index 720e8aa..087352e 100755 --- a/src/MainWindowBase.ui +++ b/src/MainWindowBase.ui @@ -65,8 +65,6 @@ - - @@ -397,20 +395,6 @@ Opens the settings dialog, to set language etc. - - - actionShowLog - - - Show Log - - - Displays logging information. - - - Displays logging info about the currently running UiGUI application. - - actionAboutUniversalIndentGUITQt diff --git a/src/debugging/TSLogger.cpp b/src/debugging/TSLogger.cpp deleted file mode 100644 index a64ccfb..0000000 --- a/src/debugging/TSLogger.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 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::m_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 (m_instance == NULL) - { - m_instance = new TSLogger(verboseLevel); - } - - return m_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(TQtDebugMsg); -#else - return TSLogger::getInstance(TQtWarningMsg); -#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) : - TQDialog() -{ - m_TSLoggerDialogForm = new Ui::TSLoggerDialog(); - m_TSLoggerDialogForm->setupUi(this); -#ifdef _DEBUG - m_verboseLevel = TQtDebugMsg; -#else - m_verboseLevel = TQtMsgType(verboseLevel); -#endif - - m_logFileInitState = NOTINITIALZED; - - connect(m_TSLoggerDialogForm->openLogFileFolderToolButton, TQ_SIGNAL(clicked()), this, - TQ_SLOT(openLogFileFolder())); - - // Make the main application not to wait for the logging window to close. - setAttribute(TQt::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(TQtMsgType type, const char *msg) -{ - if (m_instance == NULL) - { - m_instance = TSLogger::getInstance(); - } - - /* - TQMessageBox messageBox; - TQString messageBoxText = TQString::fromUtf8( msg ); - messageBox.setText( messageBoxText ); - messageBox.setWindowModality( TQt::ApplicationModal ); - messageBox.exec(); - */ - - // Only log messages that have a higher or equal priority than set with the verbose level. - if (type < m_instance->m_verboseLevel) - { - return; - } - - // Init log message with prepended date and time. - TQString message = TQDateTime::currentDateTime().toString(); - - // Depending on the TQtMsgType prepend a different colored Debug, Warning, Critical or Fatal. - switch (type) - { - case TQtDebugMsg: - { - message += " Debug: "; - break; - } - - case TQtWarningMsg: - { - message += " Warning: "; - break; - } - - case TQtCriticalMsg: - { - message += "Critical: "; - break; - } - - case TQtFatalMsg: - { - message += " Fatal: "; - } - - // This one is no TQt 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 += TQString::fromUtf8(msg) + "
\n"; - - // Write the message to the log windows text edit. - m_instance->m_TSLoggerDialogForm->logTextEdit->append(message); - - // Write/append the log message to the log file. - m_instance->writeToLogFile(message); - - // In case of a fatal error abort the application. - if (type == TQtFatalMsg) - { - 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) - { - m_verboseLevel = TQtDebugMsg; - } - if (level > 3) - { - m_verboseLevel = TQtFatalMsg; - } - else - { - m_verboseLevel = TQtMsgType(level); - } -} - -/*! - \brief Deletes the existing m_instance of TSLogger. - */ -void TSLogger::deleteInstance() -{ - if (m_instance != NULL) - { - delete m_instance; - m_instance = NULL; - } -} - -/*! - \brief Opens the folder that contains the created log file with the name "UiGUI_log.html". - */ -void TSLogger::openLogFileFolder() -{ - TQDesktopServices::openUrl(TQFileInfo(m_logFile).absolutePath()); -} - -/*! - \brief Writes the \a message to the used log file. - */ -void TSLogger::writeToLogFile(const TQString &message) -{ - // If the file where all logging messages should go to isn't initilized yet, do that now. - if (m_logFileInitState == NOTINITIALZED) - { - m_logFileInitState = INITIALIZING; - - // On different systems it may be that "TQDir::tempPath()" ends with a "/" or not. So check - // this. - // Remove any trailing slashes. - TQString tempPath = TQFileInfo(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. - TQString logFileName = "UiGUI_log_" + TQDateTime::currentDateTime().toString("yyyyMMdd"); - logFileName += "-" + TQDateTime::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 += "_" + TQString(randomChar) + ".html"; - - m_logFile.setFileName(tempPath + "/" + logFileName); - - // Set the tooltip of the open log file folder button to show the unique name of the log file. - m_TSLoggerDialogForm->openLogFileFolderToolButton->setToolTip( - m_TSLoggerDialogForm->openLogFileFolderToolButton->toolTip() + " (" + logFileName + ")"); - - m_logFileInitState = INITIALZED; - } - - // Add the message to the message queue. - m_messageQueue << message; - - // If the logging file is initialzed, write all messages contained in the message queue into the - // file. - if (m_logFileInitState == INITIALZED) - { - // Write/append the log message to the log file. - if (m_logFile.open(TQIODevice::WriteOnly | TQIODevice::Text | TQIODevice::Append)) - { - TQTextStream out(&m_logFile); - - while (!m_messageQueue.isEmpty()) - { - out << m_messageQueue.takeFirst() << "\n"; - } - - m_logFile.close(); - } - } -} diff --git a/src/debugging/TSLogger.h b/src/debugging/TSLogger.h deleted file mode 100644 index 0e20214..0000000 --- a/src/debugging/TSLogger.h +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 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 TQtMsgType(4) - - class TSLogger : public TQDialog - { - TQ_OBJECT - - public: - static TSLogger* getInstance(int verboseLevel); - static TSLogger* getInstance(); - static void messageHandler(TQtMsgType type, const char *msg); - static void deleteInstance(); - void setVerboseLevel(int level); - - private slots: - void openLogFileFolder(); - - private: - Ui::TSLoggerDialog *m_TSLoggerDialogForm; - - enum LogFileInitState - { - NOTINITIALZED, - INITIALIZING, - INITIALZED - } m_logFileInitState; - TSLogger(int verboseLevel); - - void writeToLogFile(const TQString &message); - - static TSLogger *m_instance; - TQtMsgType m_verboseLevel; - TQFile m_logFile; - TQStringList m_messageQueue; - }; - } -} // namespace tschweitzer::debugging - -#endif // TSLogger_H diff --git a/src/debugging/TSLoggerDialog.ui b/src/debugging/TSLoggerDialog.ui deleted file mode 100755 index 1956229..0000000 --- a/src/debugging/TSLoggerDialog.ui +++ /dev/null @@ -1,142 +0,0 @@ - - - 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 - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - TQDialogButtonBox::Close - - - - - - - - - - - - - TSLoggerDialog - finished(int) - TSLoggerDialog - close() - - - 2 - 45 - - - 5 - 59 - - - - - buttonBox - clicked(TQAbstractButton*) - TSLoggerDialog - close() - - - 419 - 280 - - - 477 - 263 - - - - - cleanUpToolButton - clicked() - logTextEdit - clear() - - - 27 - 282 - - - 22 - 231 - - - - - diff --git a/src/main.cpp b/src/main.cpp index dded8ed..826ddfe 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,6 @@ #include "MainWindow.h" -// -- #include "debugging/TSLogger.h" // -- #include "IndentHandler.h" #include "SettingsPaths.h" // -- #include "UiGuiIndentServer.h" @@ -37,8 +36,6 @@ #include -// -- using namespace tschweitzer::debugging; - /*! /brief Entry point to UniversalIndentGUI application. @@ -128,20 +125,11 @@ int main(int argc, char *argv[]) // -- UiGuiIndentServer server; MainWindow *mainWindow = NULL; // -- IndentHandler *indentHandler = NULL; -// -- - // Init and install the logger function. - // Setting UTF-8 as default 8-Bit encoding to ensure that tqDebug does no false string conversion. + + // Setting UTF-8 as default 8-Bit encoding TQTextCodec::setCodecForCStrings(TQTextCodec::codecForName("UTF-8")); TQTextCodec::setCodecForLocale(TQTextCodec::codecForName("UTF-8")); -// -- // Force creation of an TSLogger instance here, to avoid recursion with SettingsPaths init function. -// -- #ifdef _DEBUG -// -- TSLogger::getInstance(0); -// -- #else -// -- TSLogger::getInstance(verboseLevel); -// -- #endif -// -- qInstallMsgHandler(TSLogger::messageHandler); -// -- TSLogger::messageHandler(TSLoggerInfoMsg, TQString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).toAscii()); -// -- + // Start normal with full gui and without server. if (!startAsPlugin && !startAsServer) { mainWindow = new MainWindow(file2OpenOnStart); @@ -174,7 +162,5 @@ int main(int argc, char *argv[]) // -- delete indentHandler; delete mainWindow; -// -- TSLogger::deleteInstance(); - return returnValue; }