20 #ifndef GEOS_COMMON_LOGGER_HPP
21 #define GEOS_COMMON_LOGGER_HPP
26 #include "common/format/Format.hpp"
27 #include "LvArray/src/Macros.hpp"
32 #if defined(GEOS_USE_MPI)
40 #define GEOS_LOG( ... ) LVARRAY_LOG( __VA_ARGS__ )
46 #define GEOS_LOG_VAR( ... ) LVARRAY_LOG_VAR( __VA_ARGS__ )
54 #if defined(GEOS_DEVICE_COMPILE)
55 #define GEOS_LOG_IF( EXP, msg )
57 #define GEOS_LOG_IF( EXP, msg ) \
61 std::cout<< msg << std::endl; \
72 #define GEOS_LOG_RANK_0_IF( EXP, msg ) \
74 if( ::geos::logger::internal::rank == 0 && EXP ) \
76 std::ostringstream oss; \
78 std::cout << oss.str() << std::endl; \
87 #define GEOS_LOG_RANK_0_IF_NLR( EXP, msg ) \
89 if( ::geos::logger::internal::rank == 0 && EXP ) \
91 std::ostringstream oss; \
93 std::cout << oss.str(); \
101 #define GEOS_LOG_RANK_0( msg ) GEOS_LOG_RANK_0_IF( true, msg )
108 #if defined(GEOS_DEVICE_COMPILE)
109 #define GEOS_LOG_RANK_IF( EXP, msg )
111 #define GEOS_LOG_RANK_IF( EXP, msg ) \
115 std::ostringstream oss; \
116 oss << "Rank " << ::geos::logger::internal::rankString << ": " << msg; \
117 *logger::internal::rankStream << oss.str() << std::endl; \
126 #define GEOS_LOG_RANK( msg ) GEOS_LOG_RANK_IF( true, msg )
132 #define GEOS_LOG_RANK_VAR( var ) GEOS_LOG_RANK( #var " = " << var )
139 #if defined(GEOS_DEVICE_COMPILE)
140 #define GEOS_ERROR_IF( EXP, msg ) LVARRAY_ERROR_IF( EXP, msg )
142 #define GEOS_ERROR_IF( EXP, msg ) LVARRAY_ERROR_IF( EXP, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
151 #define GEOS_THROW_IF( EXP, msg, TYPE ) LVARRAY_THROW_IF( EXP, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg, TYPE )
157 #define GEOS_ERROR( msg ) GEOS_ERROR_IF( true, msg )
164 #define GEOS_THROW( msg, TYPE ) GEOS_THROW_IF( true, msg, TYPE )
171 #define GEOS_ASSERT_MSG( EXP, msg ) LVARRAY_ASSERT_MSG( EXP, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
177 #define GEOS_ASSERT( EXP ) GEOS_ASSERT_MSG( EXP, "" )
184 #define GEOS_WARNING_IF( EXP, msg ) LVARRAY_WARNING_IF( EXP, msg )
190 #define GEOS_WARNING( msg ) LVARRAY_WARNING( msg )
197 #define GEOS_INFO_IF( EXP, msg ) LVARRAY_INFO_IF( EXP, msg )
203 #define GEOS_INFO( msg ) LVARRAY_INFO( msg )
211 #define GEOS_ERROR_IF_EQ_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_EQ_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
220 #define GEOS_THROW_IF_EQ_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_EQ_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg, TYPE )
227 #define GEOS_ERROR_IF_EQ( lhs, rhs ) GEOS_ERROR_IF_EQ_MSG( lhs, rhs, "" )
235 #define GEOS_THROW_IF_EQ( lhs, rhs, TYPE ) GEOS_THROW_IF_EQ_MSG( lhs, rhs, "", TYPE )
243 #define GEOS_ERROR_IF_NE_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_NE_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
252 #define GEOS_THROW_IF_NE_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_NE_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg, TYPE )
259 #define GEOS_ERROR_IF_NE( lhs, rhs ) GEOS_ERROR_IF_NE_MSG( lhs, rhs, "" )
267 #define GEOS_THROW_IF_NE( lhs, rhs, TYPE ) GEOS_THROW_IF_NE_MSG( lhs, rhs, "", TYPE )
275 #define GEOS_ERROR_IF_GT_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_GT_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
284 #define GEOS_THROW_IF_GT_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_GT_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg, TYPE )
291 #define GEOS_ERROR_IF_GT( lhs, rhs ) GEOS_ERROR_IF_GT_MSG( lhs, rhs, "" )
299 #define GEOS_THROW_IF_GT( lhs, rhs, TYPE ) GEOS_ERROR_IF_GT_MSG( lhs, rhs, "", TYPE )
307 #define GEOS_ERROR_IF_GE_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_GE_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
316 #define GEOS_THROW_IF_GE_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_GE_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg, TYPE )
323 #define GEOS_ERROR_IF_GE( lhs, rhs ) GEOS_ERROR_IF_GE_MSG( lhs, rhs, "" )
331 #define GEOS_THROW_IF_GE( lhs, rhs, TYPE ) GEOS_ERROR_IF_GE_MSG( lhs, rhs, "", TYPE )
339 #define GEOS_ERROR_IF_LT_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_LT_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
348 #define GEOS_THROW_IF_LT_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_LT_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg, TYPE )
355 #define GEOS_ERROR_IF_LT( lhs, rhs ) GEOS_ERROR_IF_LT_MSG( lhs, rhs, "" )
363 #define GEOS_THROW_IF_LT( lhs, rhs, TYPE ) GEOS_ERROR_IF_LT_MSG( lhs, rhs, "", TYPE )
371 #define GEOS_ERROR_IF_LE_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_LE_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
380 #define GEOS_THROW_IF_LE_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_LE_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg, TYPE )
387 #define GEOS_ERROR_IF_LE( lhs, rhs ) GEOS_ERROR_IF_LE_MSG( lhs, rhs, "" )
395 #define GEOS_THROW_IF_LE( lhs, rhs, TYPE ) GEOS_ERROR_IF_LE_MSG( lhs, rhs, "", TYPE )
403 #define GEOS_ASSERT_EQ_MSG( lhs, rhs, msg ) LVARRAY_ASSERT_EQ_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
410 #define GEOS_ASSERT_EQ( lhs, rhs ) GEOS_ASSERT_EQ_MSG( lhs, rhs, "" )
418 #define GEOS_ASSERT_NE_MSG( lhs, rhs, msg ) LVARRAY_ASSERT_NE_MSG( lhs, rhs, msg )
425 #define GEOS_ASSERT_NE( lhs, rhs ) LVARRAY_ASSERT_NE( lhs, rhs )
433 #define GEOS_ASSERT_GT_MSG( lhs, rhs, msg ) LVARRAY_ASSERT_GT_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
440 #define GEOS_ASSERT_GT( lhs, rhs ) GEOS_ASSERT_GT_MSG( lhs, rhs, "" )
448 #define GEOS_ASSERT_GE_MSG( lhs, rhs, msg ) LVARRAY_ASSERT_GE_MSG( lhs, rhs, "***** Rank " << ::geos::logger::internal::rankString << ": " << msg )
455 #define GEOS_ASSERT_GE( lhs, rhs ) GEOS_ASSERT_GE_MSG( lhs, rhs, "" )
462 #define GEOS_LOG_LEVEL_FN( minLevel, fn ) \
464 if( this->getLogLevel() >= minLevel ) \
476 #define GEOS_LOG_LEVEL( minLevel, msg ) GEOS_LOG_IF( this->getLogLevel() >= minLevel, msg );
484 #define GEOS_LOG_LEVEL_RANK_0( minLevel, msg ) GEOS_LOG_RANK_0_IF( this->getLogLevel() >= minLevel, msg )
492 #define GEOS_LOG_LEVEL_BY_RANK( minLevel, msg ) GEOS_LOG_RANK_IF( this->getLogLevel() >= minLevel, msg )
508 std::runtime_error( what )
516 std::runtime_error( what )
537 std::runtime_error( what )
545 std::runtime_error( what )
570 std::runtime_error( what )
592 extern std::ostream * rankStream;
594 #if defined(GEOS_USE_MPI)
595 extern MPI_Comm comm;
599 #if defined(GEOS_USE_MPI)
605 void InitializeLogger( MPI_Comm comm,
const std::string & rank_output_dir=
"" );
void FinalizeLogger()
Finalize the logger and close the rank streams.
void InitializeLogger(const std::string &rank_output_dir="")
Initialize the logger in a serial build.
Exception class used for special control flow.
std::string string
String type.
Exception class used to report errors from type conversion.
BadTypeError(std::string const &what)
Constructor.
Exception class used to report errors in user input.
SimulationError(std::exception const &subException, std::string const &msgToInsert)
Construct a SimulationError from an underlying exception.
SimulationError(std::string const &what)
Constructor.
SimulationError(char const *const what)
Constructor.