Skip to content

Commit 5386a21

Browse files
committed
logging: minor beautifications
- reduce digits for milliseconds from 4 to 2 - increase chars for logger names in output from 8 to 10 Signed-off-by: Torbjörn Klatt <[email protected]>
1 parent 12a4066 commit 5386a21

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

include/pfasst/logging.hpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const string OUT::reset = "\033[0m";
103103

104104
#ifndef PFASST_LOGGER_DEFAULT_GLOBAL_MILLISECOND_WIDTH
105105
//! precision of milliseconds to be printed
106-
#define PFASST_LOGGER_DEFAULT_GLOBAL_MILLISECOND_WIDTH "4"
106+
#define PFASST_LOGGER_DEFAULT_GLOBAL_MILLISECOND_WIDTH "2"
107107
#endif
108108

109109
#ifndef VLOG_FUNC_START
@@ -145,7 +145,7 @@ const string OUT::reset = "\033[0m";
145145
*
146146
* @see pfasst::log::add_custom_logger()
147147
*/
148-
#define LOGGER_ID_LENGTH 8
148+
#define LOGGER_ID_LENGTH 10
149149

150150

151151
namespace pfasst
@@ -177,6 +177,13 @@ namespace pfasst
177177
*/
178178
static size_t stack_position;
179179

180+
/**
181+
* internal flag identifying whether the default logger has been initialized.
182+
*
183+
* @since v1.0.0
184+
*/
185+
static bool initialized = false;
186+
180187
/**
181188
* Formats the local MPI world rank as a string.
182189
*
@@ -275,6 +282,11 @@ namespace pfasst
275282
*
276283
* <TIME> [MYCUSTOM, INFO ] a logging message
277284
*
285+
* In case MPI is enabled, the line will also contain the MPI rank as given by
286+
* pfasst::config::get_rank():
287+
*
288+
* <TIME> [MYCUSTOM, INFO , MPI <rank> ] a logging message
289+
*
278290
* @param[in] id the ID of the logger; this is used in logging calls
279291
*
280292
* @note Please make sure to use `CLOG` (and `CVLOG` for verbose logging) to be able to specify
@@ -303,14 +315,17 @@ namespace pfasst
303315
const string POSITION = "%fbase:%line";
304316
const string MESSAGE = "%msg";
305317
#ifdef WITH_MPI
306-
const string MPI_RANK = ", rank " + format_mpi_rank();
318+
const string MPI_RANK = ", MPI " + format_mpi_rank();
307319
#else
308320
const string MPI_RANK = "";
309321
#endif
310322

311323
const size_t id_length = id.size();
312324
string id2print = id.substr(0, LOGGER_ID_LENGTH);
313325
boost::to_upper(id2print);
326+
if (initialized) {
327+
CLOG(DEBUG, "default") << "initializing custom logger '" << id << "' as '" << id2print << "'";
328+
}
314329
if (id_length < LOGGER_ID_LENGTH) {
315330
id2print.append(LOGGER_ID_LENGTH - id_length, ' ');
316331
}
@@ -352,7 +367,9 @@ namespace pfasst
352367
el::Loggers::setDefaultConfigurations(defaultConf, true);
353368

354369
add_custom_logger("default");
370+
pfasst::log::initialized = true;
355371
add_custom_logger("Controller");
372+
add_custom_logger("Communicator");
356373
add_custom_logger("Sweeper");
357374
add_custom_logger("Encap");
358375
add_custom_logger("Quadrature");

0 commit comments

Comments
 (0)