|
11 | 11 | #include <string> |
12 | 12 | using namespace std; |
13 | 13 |
|
| 14 | +#ifdef WITH_MPI |
| 15 | + #include <mpi.h> |
| 16 | +#endif |
| 17 | + |
14 | 18 | #include <boost/algorithm/string.hpp> |
15 | 19 |
|
16 | 20 | #include "pfasst/site_config.hpp" |
@@ -220,10 +224,27 @@ namespace pfasst |
220 | 224 | id2print.append(LOGGER_ID_LENGTH - id_length, ' '); |
221 | 225 | } |
222 | 226 |
|
| 227 | + el::Configurations* default_conf = \ |
| 228 | + const_cast<el::Configurations*>(el::Loggers::defaultConfigurations()); |
| 229 | + |
223 | 230 | el::Logger* logger = el::Loggers::getLogger(id); |
224 | 231 | el::Configurations* conf = logger->configurations(); |
225 | 232 | conf->setGlobally(el::ConfigurationType::MillisecondsWidth, |
226 | | - PFASST_LOGGER_DEFAULT_GLOBAL_MILLISECOND_WIDTH); |
| 233 | + default_conf->get(el::Level::Info, |
| 234 | + el::ConfigurationType::MillisecondsWidth)->value()); |
| 235 | + conf->setGlobally(el::ConfigurationType::ToStandardOutput, |
| 236 | + default_conf->get(el::Level::Info, |
| 237 | + el::ConfigurationType::ToStandardOutput)->value()); |
| 238 | +#ifdef WITH_MPI |
| 239 | + int initialized = 0; |
| 240 | + MPI_Initialized(&initialized); |
| 241 | + assert((bool)initialized); |
| 242 | + int rank = 0; |
| 243 | + MPI_Comm_rank(MPI_COMM_WORLD, &rank); |
| 244 | + conf->setGlobally(el::ConfigurationType::ToFile, "true"); |
| 245 | + conf->setGlobally(el::ConfigurationType::Filename, |
| 246 | + string("mpi_run_") + to_string(rank) + string(".log")); |
| 247 | +#endif |
227 | 248 | conf->set(el::Level::Info, el::ConfigurationType::Format, |
228 | 249 | TIMESTAMP + INFO_COLOR + "[" + id2print + ", " + LEVEL + " " + MESSAGE + OUT::reset); |
229 | 250 | conf->set(el::Level::Debug, el::ConfigurationType::Format, |
@@ -251,11 +272,24 @@ namespace pfasst |
251 | 272 | el::Configurations defaultConf; |
252 | 273 | defaultConf.setToDefault(); |
253 | 274 |
|
254 | | - defaultConf.setGlobally(el::ConfigurationType::ToFile, "false"); |
255 | | - defaultConf.setGlobally(el::ConfigurationType::ToStandardOutput, "true"); |
| 275 | + if (!pfasst::config::options::get_instance().get_variables_map().count("quiet")) { |
| 276 | + defaultConf.setGlobally(el::ConfigurationType::ToStandardOutput, "true"); |
| 277 | + } else { |
| 278 | + defaultConf.setGlobally(el::ConfigurationType::ToStandardOutput, "false"); |
| 279 | + } |
| 280 | +#ifdef WITH_MPI |
| 281 | + int initialized = 0; |
| 282 | + MPI_Initialized(&initialized); |
| 283 | + assert((bool)initialized); |
| 284 | + int rank = 0; |
| 285 | + MPI_Comm_rank(MPI_COMM_WORLD, &rank); |
| 286 | + defaultConf.setGlobally(el::ConfigurationType::ToFile, "true"); |
| 287 | + defaultConf.setGlobally(el::ConfigurationType::Filename, |
| 288 | + string("mpi_run_") + to_string(rank) + string(".log")); |
| 289 | +#endif |
256 | 290 | defaultConf.setGlobally(el::ConfigurationType::MillisecondsWidth, |
257 | 291 | PFASST_LOGGER_DEFAULT_GLOBAL_MILLISECOND_WIDTH); |
258 | | - el::Loggers::reconfigureAllLoggers(defaultConf); |
| 292 | + el::Loggers::setDefaultConfigurations(defaultConf, true); |
259 | 293 |
|
260 | 294 | add_custom_logger("default"); |
261 | 295 | add_custom_logger("Controller"); |
|
0 commit comments