19 #include <fmt/ostream.h> 21 #include <amdis/Environment.hpp> 22 #include <amdis/common/TypeTraits.hpp> 33 #ifndef AMDIS_ENABLE_MSG_DBG 35 #define AMDIS_ENABLE_MSG_DBG 1 37 #define AMDIS_ENABLE_MSG_DBG 0 41 #define AMDIS_FUNCNAME(nn) [[maybe_unused]] const char *funcName = nn; 44 #define AMDIS_FUNCNAME_DBG(nn) 45 #define AMDIS_DBG_VAR(var) 47 #define AMDIS_FUNCNAME_DBG(nn) [[maybe_unused]] const char *funcName = nn; 48 #define AMDIS_DBG_VAR(var) var 56 template <
class OStream,
class... Args>
57 OStream& msg_all(OStream& out, std::string
const& str, Args&&... args)
62 fmt::print(out, str, FWD(args)...);
66 template <
class OStream,
class... Args>
67 OStream& msg(OStream& out, std::string
const& str, Args&&... args)
70 return msg_all(out, str, FWD(args)...);
73 fmt::print(out,
"[0] " + str, FWD(args)...);
75 fmt::print(out, str, FWD(args)...);
89 template <
class... Args>
90 void msg(std::string
const& str, Args&&... args)
92 Impl::msg(std::cout, str +
"\n", FWD(args)...);
96 template <
class... Args>
97 void info(
int noInfoLevel, std::string
const& str, Args&&... args)
100 Impl::msg(std::cout, str +
"\n", FWD(args)...);
111 template <
class... Args>
112 void msg_(std::string
const& str, Args&&... args)
114 Impl::msg(std::cout, str, FWD(args)...);
118 template <
class... Args>
119 void info_(
int noInfoLevel, std::string
const& str, Args&&... args)
122 Impl::msg(std::cout, str, FWD(args)...);
133 template <
class... Args>
134 void error_exit(std::string
const& str, Args&&... args)
136 #ifdef AMDIS_NO_THROW 137 Impl::msg_all(std::cerr,
"ERROR: " + str +
"\n", FWD(args)...);
140 throw std::runtime_error( std::string(
"ERROR: ") + fmt::format(str, FWD(args)...));
154 template <
class... Args>
155 void test_exit(
bool condition, std::string
const& str, Args&&... args)
157 if (!condition) { error_exit(str, FWD(args)...); }
161 template <
class... Args>
162 void warning(std::string
const& str, Args&&... args)
164 Impl::msg(std::cout,
"WARNING: " + str +
"\n", FWD(args)...);
174 template <
class... Args>
175 void test_warning(
bool condition, std::string
const& str, Args&&... args)
177 if (!condition) { warning(str, FWD(args)...); }
181 #if AMDIS_ENABLE_MSG_DBG 187 template <
class... Args>
188 void msg_dbg(Args&&... args) { msg(FWD(args)...); }
196 template <
class... Args>
197 void test_exit_dbg(
bool condition, Args&&... args)
199 test_exit(condition, FWD(args)...);
202 template <
class... Args>
203 void msg_dbg(Args&&...) {}
205 template <
class... Args>
206 void test_exit_dbg(
bool, Args&&...) {}
static int infoLevel()
Return the info level for messages in info()
Definition: Environment.cpp:63
Definition: AdaptBase.hpp:6
static int mpiSize()
Return the MPI_Size of the group created by Dune::MPIHelper.
Definition: Environment.hpp:74
static bool msgAllRanks()
Return whether all ranks print msg()
Definition: Environment.cpp:71
static int mpiRank()
Return the MPI_Rank of the current processor.
Definition: Environment.hpp:68