Salome HOME
Add timestamp to logged messages.
authorPascal Obry <pascal.obry@edf.fr>
Tue, 11 Apr 2023 11:38:38 +0000 (13:38 +0200)
committerPascal Obry <pascal.obry@edf.fr>
Tue, 5 Sep 2023 09:36:26 +0000 (11:36 +0200)
We need an early timestamp to trace the log message instead of
a timestamp recorded when the message is pushed to the server.

This is important to be able to get proper timestamp when a log
is stalling on user's machine when the remote server is not
running.

src/CAM/CAM_Application.cxx

index 2735234a15bb57f95225e4117abe27236d97fff1..8dab93d7152bd622e51fb53848467e8e76e35bf4 100644 (file)
@@ -42,6 +42,7 @@
 #include <QMutexLocker>
 #include <QRegExp>
 #include <QTextStream>
+#include <QDateTime>
 
 #ifdef WIN32
 #include <windows.h>
@@ -1029,8 +1030,9 @@ void CAM_Application::logUserEvent( const QString& eventDescription )
     QFile file ( guiLogFile );
     if ( file.open( QFile::Append ) ) // append to log file
     {
+      QDateTime current = QDateTime::currentDateTime();
       QTextStream stream( &file );
-      stream << eventDescription << endl;
+      stream << current.toString("yyyyMMdd-hhmmss") << ": " << eventDescription << endl;
       file.close();
     }
   }