diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp index 83c11bf6cc2722a405f29daa89ec04e378281a29..b181ec6effaaf2c760458cadd4cdce4fb1d64b1a 100644 --- a/Common/Gmsh.cpp +++ b/Common/Gmsh.cpp @@ -4,6 +4,7 @@ // bugs and problems to <gmsh@geuz.org>. #include <string> +#include <time.h> #include "GmshDefines.h" #include "GModel.h" #include "GmshMessage.h" @@ -83,6 +84,9 @@ int GmshBatch() { if(!GModel::current()) return 0; + Msg::Info("Running '%s'", Msg::GetCommandLine().c_str()); + Msg::Info("Started on %s", Msg::GetLaunchDate().c_str()); + OpenProject(CTX.filename); for(unsigned int i = 1; i < CTX.files.size(); i++){ if(CTX.files[i] == "-new") @@ -124,5 +128,11 @@ int GmshBatch() CreateOutputFile(CTX.output_filename, CTX.mesh.format); } + time_t now; + time(&now); + std::string currtime = ctime(&now); + currtime.resize(currtime.size() - 1); + Msg::Info("Stopped on %s", currtime.c_str()); + return 1; } diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index cd082efc55caa021857bdd1203ef473d5ad8ee16..5239188a2ed54ddcb99891849715190a04f0605e 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -6,6 +6,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <time.h> #include "GmshMessage.h" #include "Gmsh.h" #include "Options.h" @@ -34,6 +35,8 @@ std::map<std::string, double> Msg::_timers; int Msg::_warningCount = 0; int Msg::_errorCount = 0; GmshMessage *Msg::_callback = 0; +std::string Msg::_commandLine; +std::string Msg::_launchDate; #if defined(HAVE_NO_VSNPRINTF) static int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) @@ -59,6 +62,15 @@ void Msg::Init(int argc, char **argv) MPI_Comm_size(MPI_COMM_WORLD, &_commSize); MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); #endif + time_t now; + time(&now); + _launchDate = ctime(&now); + _launchDate.resize(_launchDate.size() - 1); + _commandLine.clear(); + for(int i = 0; i < argc; i++){ + if(i) _commandLine += " "; + _commandLine += argv[i]; + } } void Msg::Exit(int level) diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index 90feb6505a23d4f967ae81c93eed6d3344f6ac26..f9a11a97f61c7fe3c44f42447b17911311975202 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -33,6 +33,8 @@ class Msg { static int _warningCount, _errorCount; // callback static GmshMessage *_callback; + // command-line and startup time + static std::string _commandLine, _launchDate; public: Msg() {} static void Init(int argc, char **argv); @@ -48,6 +50,8 @@ class Msg { static int GetThreadNum(); static void SetVerbosity(int val){ _verbosity = val; } static int GetVerbosity(){ return _verbosity; } + static std::string GetLaunchDate(){ return _launchDate; } + static std::string GetCommandLine(){ return _commandLine; } static void Fatal(const char *fmt, ...); static void Error(const char *fmt, ...); static void Warning(const char *fmt, ...); diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp index 539aa1113925e99a433456e33ef01f81a1ceec8a..7a047186a0a098e0b5b97221e5346215cba21cfd 100644 --- a/Fltk/Main.cpp +++ b/Fltk/Main.cpp @@ -4,7 +4,6 @@ // bugs and problems to <gmsh@geuz.org>. #include <string> -#include <time.h> #include "GUI.h" #include "menuWindow.h" #include "Gmsh.h" @@ -26,17 +25,6 @@ extern Context_T CTX; int main(int argc, char *argv[]) { - // Log some info - time_t now; - time(&now); - std::string currtime(ctime(&now)); - currtime[currtime.size() - 1] = '\0'; - std::string cmdline; - for(int i = 0; i < argc; i++){ - if(i) cmdline += " "; - cmdline += argv[i]; - } - // Hack to generate automatic documentation (before getting // user-defined options) if(argc == 2 && std::string(argv[1]) == "-doc"){ @@ -59,14 +47,8 @@ int main(int argc, char *argv[]) // Non-interactive Gmsh if(CTX.batch) { - Msg::Info("Running '%s'", cmdline.c_str()); - Msg::Info("Started on %s", currtime.c_str()); GmshBatch(); GmshFinalize(); - time(&now); - currtime = ctime(&now); - currtime[currtime.size() - 1] = '\0'; - Msg::Info("Stopped on %s", currtime.c_str()); Msg::Exit(0); } @@ -89,8 +71,8 @@ int main(int argc, char *argv[]) Msg::Info("Build host : %s", Get_GmshBuildHost()); Msg::Info("Packager : %s", Get_GmshPackager()); Msg::Info("Home directory : %s", CTX.home_dir); - Msg::Info("Launch date : %s", currtime.c_str()); - Msg::Info("Command line : %s", cmdline.c_str()); + Msg::Info("Launch date : %s", Msg::GetLaunchDate().c_str()); + Msg::Info("Command line : %s", Msg::GetCommandLine().c_str()); Msg::Info("-------------------------------------------------------"); // Display the GUI immediately to have a quick "a la Windows" launch time