Salome HOME
Use logStructuredUserEvent() for log message format consistency. po/29467_gui_log_file
authorPascal Obry <pascal.obry@edf.fr>
Fri, 12 May 2023 07:32:36 +0000 (09:32 +0200)
committerPascal Obry <pascal.obry@edf.fr>
Tue, 5 Sep 2023 09:15:10 +0000 (11:15 +0200)
src/SHAPERGUI/SHAPERGUI.cpp

index 156141d8ba409403e782897cece133abadd2d714..eebf6e6c422ece0e69c5544973008316ad1b99ba 100644 (file)
@@ -500,40 +500,45 @@ void SHAPERGUI::logShaperGUIEvent()
   QAction* anAction = static_cast<QAction*>(sender());
   if ( !anAction )
     return;
-  QString anId = anAction->data().toString();
-  QStringList message = (QStringList() << moduleName());
-  if (anId.contains("Sketch"))
-    message << tr("sketcher");
-  message << tr("operation %1 has been activated").arg(anAction->text());
-  CAM_Application::logUserEvent(message.join(": "));
+  const QString anId = anAction->data().toString();
+  const QString section = anId.contains("Sketch") ? "sketcher" : "";
+
+  CAM_Application::logStructuredUserEvent( moduleName(),
+                                           section,
+                                           anAction->text(),
+                                           "activated" );
 }
 
 //******************************************************
-void SHAPERGUI::onOperationCommitted(ModuleBase_Operation* theOperation)
+static void onOperationGeneric( ModuleBase_Operation* theOperation,
+                                const QString moduleName,
+                                const QString &event )
 {
-  QStringList message = (QStringList() << moduleName());
   QString anId = theOperation->id();
+  QString section = "";
+
   if (anId.contains("Sketch"))
   {
-    message << tr("sketcher");
+    section = "sketcher";
     anId.remove("Sketch");
   }
-  message << tr("operation %1 has been committed").arg(anId);
-  CAM_Application::logUserEvent(message.join(": "));
+
+  CAM_Application::logStructuredUserEvent( moduleName,
+                                           section,
+                                           anId,
+                                           event );
+}
+
+//******************************************************
+void SHAPERGUI::onOperationCommitted(ModuleBase_Operation* theOperation)
+{
+  onOperationGeneric(theOperation, moduleName(), "committed");
 }
 
 //******************************************************
 void SHAPERGUI::onOperationAborted(ModuleBase_Operation* theOperation)
 {
-  QStringList message = (QStringList() << moduleName());
-  QString anId = theOperation->id();
-  if (anId.contains("Sketch"))
-  {
-    message << tr("sketcher");
-    anId.remove("Sketch");
-  }
-  message << tr("operation %1 has been aborted").arg(anId);
-  CAM_Application::logUserEvent(message.join(": "));
+  onOperationGeneric(theOperation, moduleName(), "aborted");
 }
 
 //******************************************************