3636#include " rapidjson/filereadstream.h"
3737#include " rapidjson/filewritestream.h"
3838
39- static const char * serverlogname = " serverlog" ;
40- static const char * workerlogname = " workerlog" ;
41- static const char * mergerlogname = " mergerlog" ;
39+ std::string getServerLogName ()
40+ {
41+ auto & conf = o2::conf::SimConfig::Instance ();
42+ std::stringstream str;
43+ str << conf.getOutPrefix () << " _serverlog" ;
44+ return str.str ();
45+ }
46+
47+ std::string getWorkerLogName ()
48+ {
49+ auto & conf = o2::conf::SimConfig::Instance ();
50+ std::stringstream str;
51+ str << conf.getOutPrefix () << " _workerlog" ;
52+ return str.str ();
53+ }
54+
55+ std::string getMergerLogName ()
56+ {
57+ auto & conf = o2::conf::SimConfig::Instance ();
58+ std::stringstream str;
59+ str << conf.getOutPrefix () << " _mergerlog" ;
60+ return str.str ();
61+ }
4262
4363void cleanup ()
4464{
@@ -49,21 +69,21 @@ void cleanup()
4969 if (getenv (" ALICE_O2SIM_DUMPLOG" )) {
5070 std::cerr << " ------------- START OF EVENTSERVER LOG ----------" << std::endl;
5171 std::stringstream catcommand1;
52- catcommand1 << " cat " << serverlogname << " ;" ;
72+ catcommand1 << " cat " << getServerLogName () << " ;" ;
5373 if (system (catcommand1.str ().c_str ()) != 0 ) {
5474 LOG (WARN ) << " error executing system call" ;
5575 }
5676
5777 std::cerr << " ------------- START OF SIM WORKER(S) LOG --------" << std::endl;
5878 std::stringstream catcommand2;
59- catcommand2 << " cat " << workerlogname << " *;" ;
79+ catcommand2 << " cat " << getWorkerLogName () << " *;" ;
6080 if (system (catcommand2.str ().c_str ()) != 0 ) {
6181 LOG (WARN ) << " error executing system call" ;
6282 }
6383
6484 std::cerr << " ------------- START OF MERGER LOG ---------------" << std::endl;
6585 std::stringstream catcommand3;
66- catcommand3 << " cat " << mergerlogname << " ;" ;
86+ catcommand3 << " cat " << getMergerLogName () << " ;" ;
6787 if (system (catcommand3.str ().c_str ()) != 0 ) {
6888 LOG (WARN ) << " error executing system call" ;
6989 }
@@ -281,7 +301,7 @@ int main(int argc, char* argv[])
281301 // the server
282302 int pid = fork ();
283303 if (pid == 0 ) {
284- int fd = open (serverlogname , O_RDWR | O_CREAT , S_IRUSR | S_IWUSR );
304+ int fd = open (getServerLogName (). c_str () , O_RDWR | O_CREAT , S_IRUSR | S_IWUSR );
285305 setenv (" ALICE_O2SIMSERVERTODRIVER_PIPE" , std::to_string (pipe_serverdriver_fd[1 ]).c_str (), 1 );
286306
287307 dup2 (fd, 1 ); // make stdout go to file
@@ -324,7 +344,7 @@ int main(int argc, char* argv[])
324344 } else {
325345 childpids.push_back (pid);
326346 close (pipe_serverdriver_fd[1 ]);
327- std::cout << " Spawning particle server on PID " << pid << " ; Redirect output to " << serverlogname << " \n " ;
347+ std::cout << " Spawning particle server on PID " << pid << " ; Redirect output to " << getServerLogName () << " \n " ;
328348 launchThreadMonitoringEvents (pipe_serverdriver_fd[0 ], " DISTRIBUTING EVENT : " );
329349 }
330350
@@ -336,7 +356,7 @@ int main(int argc, char* argv[])
336356 for (int id = 0 ; id < nworkers; ++id) {
337357 // the workers
338358 std::stringstream workerlogss;
339- workerlogss << workerlogname << id;
359+ workerlogss << getWorkerLogName () << id;
340360
341361 // the workers
342362 std::stringstream workerss;
@@ -370,7 +390,7 @@ int main(int argc, char* argv[])
370390
371391 pid = fork ();
372392 if (pid == 0 ) {
373- int fd = open (mergerlogname , O_RDWR | O_CREAT , S_IRUSR | S_IWUSR );
393+ int fd = open (getMergerLogName (). c_str () , O_RDWR | O_CREAT , S_IRUSR | S_IWUSR );
374394 dup2 (fd, 1 ); // make stdout go to file
375395 dup2 (fd, 2 ); // make stderr go to file - you may choose to not do this
376396 // or perhaps send stderr to another file
@@ -384,7 +404,7 @@ int main(int argc, char* argv[])
384404 (char *)nullptr );
385405 return 0 ;
386406 } else {
387- std::cout << " Spawning hit merger on PID " << pid << " ; Redirect output to " << mergerlogname << " \n " ;
407+ std::cout << " Spawning hit merger on PID " << pid << " ; Redirect output to " << getMergerLogName () << " \n " ;
388408 childpids.push_back (pid);
389409 close (pipe_mergerdriver_fd[1 ]);
390410 launchThreadMonitoringEvents (pipe_mergerdriver_fd[0 ], " EVENT FINISHED : " );
0 commit comments