66#include < string>
77using namespace std ;
88
9+ #ifdef WITH_MPI
10+ #include < mpi.h>
11+ #endif
12+
913#include < boost/algorithm/string.hpp>
1014
1115struct OUT
@@ -168,6 +172,20 @@ namespace pfasst
168172 el::Configurations* conf = logger->configurations ();
169173 conf->setGlobally (el::ConfigurationType::MillisecondsWidth,
170174 PFASST_LOGGER_DEFAULT_GLOBAL_MILLISECOND_WIDTH);
175+ #ifdef WITH_MPI
176+ int initialized = 0 ;
177+ MPI_Initialized (&initialized);
178+ assert ((bool )initialized);
179+ int rank = 0 ;
180+ MPI_Comm_rank (MPI_COMM_WORLD, &rank);
181+ conf->setGlobally (el::ConfigurationType::ToFile, " true" );
182+ conf->setGlobally (el::ConfigurationType::ToStandardOutput, " false" );
183+ conf->setGlobally (el::ConfigurationType::Filename,
184+ string (" mpi_run_" ) + to_string (rank) + string (" .log" ));
185+ #else
186+ conf->setGlobally (el::ConfigurationType::ToFile, " false" );
187+ conf->setGlobally (el::ConfigurationType::ToStandardOutput, " true" );
188+ #endif
171189 conf->set (el::Level::Info, el::ConfigurationType::Format,
172190 TIMESTAMP + INFO_COLOR + " [" + id2print + " , " + LEVEL + " " + MESSAGE + OUT::reset);
173191 conf->set (el::Level::Debug, el::ConfigurationType::Format,
@@ -191,8 +209,20 @@ namespace pfasst
191209 el::Configurations defaultConf;
192210 defaultConf.setToDefault ();
193211
212+ #ifdef WITH_MPI
213+ int initialized = 0 ;
214+ MPI_Initialized (&initialized);
215+ assert ((bool )initialized);
216+ int rank = 0 ;
217+ MPI_Comm_rank (MPI_COMM_WORLD, &rank);
218+ defaultConf.setGlobally (el::ConfigurationType::ToFile, " true" );
219+ defaultConf.setGlobally (el::ConfigurationType::ToStandardOutput, " false" );
220+ defaultConf.setGlobally (el::ConfigurationType::Filename,
221+ string (" mpi_run_" ) + to_string (rank) + string (" .log" ));
222+ #else
194223 defaultConf.setGlobally (el::ConfigurationType::ToFile, " false" );
195224 defaultConf.setGlobally (el::ConfigurationType::ToStandardOutput, " true" );
225+ #endif
196226 defaultConf.setGlobally (el::ConfigurationType::MillisecondsWidth, PFASST_LOGGER_DEFAULT_GLOBAL_MILLISECOND_WIDTH);
197227 el::Loggers::reconfigureAllLoggers (defaultConf);
198228
0 commit comments