From c7dc7381a2992f33bade130f948d9bfeec2cb9ea Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 26 May 2022 14:48:51 +0300 Subject: [PATCH] [bos #29467] [EDF] (2022-T1) Logging of SALOME usage: specific log in SALOME --- src/LightApp/LightApp_Application.cxx | 43 +++++++++++++++++++++++++++ src/LightApp/LightApp_Application.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index e687135f6..d2682e7dc 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -193,6 +193,8 @@ #include #include #include +#include +#include #include @@ -5423,6 +5425,47 @@ bool LightApp_Application::checkExistingDoc( bool closeExistingDoc ) return result; } +/*! + Log GUI action +*/ +void LightApp_Application::logUserEvent(const QString& eventDescription) +{ + static QString _gui_log_file_ = "Not initialized"; + static QMutex aGUILogMutex; + if (_gui_log_file_ == "Not initialized") { + std::cout << "!!!***aaajfa***!!! _gui_log_file_ initialization" << std::endl; + _gui_log_file_ = ""; + QStringList args = QApplication::arguments(); + for (int i = 1; i < args.count(); i++) { + QRegExp rxs ("--gui-log-file=(.+)"); + if (rxs.indexIn( args[i] ) >= 0 && rxs.capturedTexts().count() > 1) { + QString file = rxs.capturedTexts()[1]; + QFileInfo fi ( file ); + if (!fi.isDir()) { + if (fi.dir().exists()) { + _gui_log_file_ = fi.absoluteFilePath(); + if (fi.exists()) { + QFile file (_gui_log_file_); + file.remove(); + } + } + } + break; + } + } + } + if (_gui_log_file_ != "") { + std::cout << "!!!***aaajfa***!!! log User Event: " << eventDescription.toStdString() << std::endl; + QMutexLocker aLocker (&aGUILogMutex); + QFile file (_gui_log_file_); + if (file.open(QFile::Append)) { + QTextStream stream( &file ); + stream << eventDescription << endl; + file.close(); + } + } +} + #ifndef DISABLE_PYCONSOLE PyConsole_Interp* LightApp_Application::getPyInterp() diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 29af725c2..2ad55b938 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -189,6 +189,8 @@ public: virtual bool checkExistingDoc( bool = true ); + static void logUserEvent(const QString& eventDescription); + #ifndef DISABLE_PYCONSOLE PyConsole_Interp* getPyInterp(); #endif -- 2.39.2