You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allen McPherson edited this page Feb 5, 2016
·
2 revisions
Logging
Overview
Using the Logger
** Using the Logger
Put these includes at the beginning of every file that needs logging (and in
main where it is set up):
#if defined(LOGGER) // CoEVP Makefile enforces assert: LOGGER=REDIS=yes
#include"LoggerDB.h"// Includes Logger base class too
#include"Locator.h"
#endif
In exacly one place per process, usually in main, initialize the logger:
#if defined(LOGGER)
// Initialize logging to REDIS databaseLocator::initialize(); // make sure a dummy logger existsif (logging) {
#if defined(COEVP_MPI)
int my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
char my_node[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(my_node, &name_len);
LoggerDB *logger_db = newLoggerDB(logdb, std::string(my_node), my_rank);
#else
LoggerDB *logger_db = newLoggerDB(logdb);
#endifLocator::provide(logger_db);
}
Logger &logger = Locator::getLogger();
#endif
Using the logger:
#if defined(LOGGER)
Logger &logger = Locator::getLogger(); // get reference to logger
logger.logStartTimer("eval_fs_model"); // start a timer
logger.logCountIncr("eval_fs_model"); // increment a counter and send to REDIS
#endif
...
#if defined(LOGGER)
logger.logStopTimer("eval_fs_model"); // stop a time and send et to REDIS
#endif