Skip to content
Snippets Groups Projects
Commit 030914e9 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

start/stop msg

parent 5b392e44
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......@@ -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)
......
......@@ -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, ...);
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment