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 42 #ifndef AMDIS_INFO_LEVEL 43 #define AMDIS_INFO_LEVEL 1 46 #define AMDIS_UNUSED(var) __attribute__((unused)) var 48 #define AMDIS_FUNCNAME(nn) AMDIS_UNUSED(const char *funcName); funcName = nn; 51 #define AMDIS_FUNCNAME_DBG(nn) 52 #define AMDIS_DBG_VAR(var) 54 #define AMDIS_FUNCNAME_DBG(nn) AMDIS_UNUSED(const char *funcName); funcName = nn; 55 #define AMDIS_DBG_VAR(var) var 63 template <
class OStream,
class... Args>
64 OStream& msg_all(OStream& out, std::string
const& str, Args&&... args)
69 fmt::print(out, str, FWD(args)...);
73 template <
class OStream,
class... Args>
74 OStream&
msg(OStream& out, std::string
const& str, Args&&... args)
76 #ifdef AMDIS_MSG_ALL_RANKS 77 return msg_all(out, str, FWD(args)...);
80 fmt::print(out,
"[0] " + str, FWD(args)...);
82 fmt::print(out, str, FWD(args)...);
97 template <
class... Args>
98 void msg(std::string
const& str, Args&&... args)
100 Impl::msg(std::cout, str +
"\n", FWD(args)...);
104 template <
class... Args>
105 void info(
int noInfoLevel, std::string
const& str, Args&&... args)
107 if (
int(AMDIS_INFO_LEVEL) >= noInfoLevel)
108 Impl::msg(std::cout, str +
"\n", FWD(args)...);
119 template <
class... Args>
120 void msg_(std::string
const& str, Args&&... args)
122 Impl::msg(std::cout, str, FWD(args)...);
126 template <
class... Args>
127 void info_(
int noInfoLevel, std::string
const& str, Args&&... args)
129 if (
int(AMDIS_INFO_LEVEL) >= noInfoLevel)
130 Impl::msg(std::cout, str, FWD(args)...);
141 template <
class... Args>
144 #ifdef AMDIS_NO_THROW 145 Impl::msg_all(std::cerr,
"ERROR: " + str +
"\n", FWD(args)...);
148 throw std::runtime_error( std::string(
"ERROR: ") + fmt::format(str, FWD(args)...));
162 template <
class... Args>
163 void test_exit(
bool condition, std::string
const& str, Args&&... args)
165 if (!condition) {
error_exit(str, FWD(args)...); }
169 template <
class... Args>
170 void warning(std::string
const& str, Args&&... args)
172 Impl::msg(std::cout,
"WARNING: " + str +
"\n", FWD(args)...);
182 template <
class... Args>
183 void test_warning(
bool condition, std::string
const& str, Args&&... args)
185 if (!condition) { warning(str, FWD(args)...); }
189 #if AMDIS_ENABLE_MSG_DBG 195 template <
class... Args>
204 template <
class... Args>
210 template <
class... Args>
213 template <
class... Args>
void error_exit(std::string const &str, Args &&... args)
print a message and exit
Definition: Output.hpp:142
void test_exit_dbg(bool condition, Args &&... args)
call assert_msg, in debug mode only
Definition: Output.hpp:205
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
void info_(int noInfoLevel, std::string const &str, Args &&... args)
prints a message, if Environment::infoLevel() >= noInfoLevel
Definition: Output.hpp:127
static int mpiSize()
Return the MPI_Size of the group created by Dune::MPIHelper.
Definition: Environment.hpp:74
void msg(std::string const &str, Args &&... args)
print a message
Definition: Output.hpp:98
void msg_(std::string const &str, Args &&... args)
print a message (without appended newline)
Definition: Output.hpp:120
void info(int noInfoLevel, std::string const &str, Args &&... args)
prints a message, if Environment::infoLevel() >= noInfoLevel
Definition: Output.hpp:105
void test_exit(bool condition, std::string const &str, Args &&... args)
test for condition and in case of failure print message and exit
Definition: Output.hpp:163
void test_warning(bool condition, std::string const &str, Args &&... args)
test for condition and in case of failure print message
Definition: Output.hpp:183
void msg_dbg(Args &&... args)
print message, in debug mode only
Definition: Output.hpp:196
static int mpiRank()
Return the MPI_Rank of the current processor.
Definition: Environment.hpp:68