24 MPILogger(
int rank,
bool quiet =
false) : mpi_rank(rank), quiet_mode(quiet) {}
31 void log(
const std::string& message)
const {
32 if (!quiet_mode && mpi_rank == 0) {
33 std::cout << message << std::endl;
42 void error(
const std::string& message)
const {
44 std::cerr <<
"ERROR: " << message << std::endl;
MPI-aware logger that handles rank filtering and quiet mode.
Definition mpi_logger.hpp:12
void exitWithError(const std::string &message) const
Logs an error and terminates the program.
Definition mpi_logger.hpp:54
void log(const std::string &message) const
Logs a message to stdout (rank 0 only, respects quiet mode).
Definition mpi_logger.hpp:31
void error(const std::string &message) const
Logs an error message to stderr (rank 0 only).
Definition mpi_logger.hpp:42
MPILogger(int rank, bool quiet=false)
Constructs an MPI logger.
Definition mpi_logger.hpp:24