GEOS
Logger.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_COMMON_LOGGER_HPP
21 #define GEOS_COMMON_LOGGER_HPP
22 
23 // Source incldes
24 #include "common/GeosxConfig.hpp"
25 #include "common/GeosxMacros.hpp"
26 #include "common/format/Format.hpp"
27 #include "LvArray/src/Macros.hpp"
29 
30 // System includes
31 #include <stdexcept>
32 
33 #if defined(GEOS_USE_MPI)
34  #include <mpi.h>
35 #endif
36 
41 #define GEOS_LOG( ... ) LVARRAY_LOG( __VA_ARGS__ )
42 
47 #define GEOS_LOG_VAR( ... ) LVARRAY_LOG_VAR( __VA_ARGS__ )
48 
49 
55 #if defined(GEOS_DEVICE_COMPILE)
56 #define GEOS_LOG_IF( EXP, msg )
57 #else
58 #define GEOS_LOG_IF( EXP, msg ) \
59  do { \
60  if( EXP ) \
61  { \
62  std::cout<< msg << std::endl; \
63  } \
64  } while( false )
65 #endif
66 
67 
73 #define GEOS_LOG_RANK_0_IF( EXP, msg ) \
74  do { \
75  if( ::geos::logger::internal::g_rank == 0 && EXP ) \
76  { \
77  std::ostringstream oss; \
78  oss << msg; \
79  std::cout << oss.str() << std::endl; \
80  } \
81  } while( false )
82 
88 #define GEOS_LOG_RANK_0_IF_NLR( EXP, msg ) \
89  do { \
90  if( ::geos::logger::internal::g_rank == 0 && EXP ) \
91  { \
92  std::ostringstream oss; \
93  oss << msg; \
94  std::cout << oss.str(); \
95  } \
96  } while( false )
97 
102 #define GEOS_LOG_RANK_0( msg ) GEOS_LOG_RANK_0_IF( true, msg )
103 
109 #if defined(GEOS_DEVICE_COMPILE)
110 #define GEOS_LOG_RANK_IF( EXP, msg )
111 #else
112 #define GEOS_LOG_RANK_IF( EXP, msg ) \
113  do { \
114  if( EXP ) \
115  { \
116  std::ostringstream oss; \
117  oss << "Rank " << ::geos::logger::internal::g_rankString << ": " << msg; \
118  *logger::internal::g_rankStream << oss.str() << std::endl; \
119  } \
120  } while( false )
121 #endif
122 
127 #define GEOS_LOG_RANK( msg ) GEOS_LOG_RANK_IF( true, msg )
128 
133 #define GEOS_LOG_RANK_VAR( var ) GEOS_LOG_RANK( #var " = " << var )
134 
140 #if !defined(GEOS_DEVICE_COMPILE) && !defined(GEOS_ERROR_LOGGER_INSTANCE)
141 #define GEOS_ERROR_LOGGER_INSTANCE ErrorLogger::global()
142 #endif
143 
153 #if !defined(GEOS_DEVICE_COMPILE)
154 #define GEOS_ERROR_IF_CAUSE( COND, CAUSE_MESSAGE, ... ) \
155  do \
156  { \
157  if( COND ) \
158  { \
159  std::ostringstream __msgoss; \
160  __msgoss << GEOS_DETAIL_FIRST_ARG( __VA_ARGS__ ); \
161  std::string __message = __msgoss.str(); \
162  __msgoss = std::ostringstream(); \
163  __msgoss << CAUSE_MESSAGE; \
164  std::string __cause = __msgoss.str(); \
165  std::ostringstream __oss; \
166  __oss << "***** ERROR\n"; \
167  __oss << "***** LOCATION: " LOCATION "\n"; \
168  __oss << "***** " << __cause << "\n"; \
169  __oss << "***** Rank " << ::geos::logger::internal::g_rankString << ": " << __message << "\n"; \
170  std::string stackHistory = LvArray::system::stackTrace( true ); \
171  __oss << stackHistory; \
172  std::cout << __oss.str() << std::endl; \
173  if( GEOS_ERROR_LOGGER_INSTANCE.isOutputFileEnabled() ) \
174  { \
175  ErrorLogger::ErrorMsg msgStruct( ErrorLogger::MsgType::Error, \
176  __message, \
177  ::geos::logger::internal::g_rank, \
178  __FILE__, \
179  __LINE__ ); \
180  msgStruct.setCause( __cause ); \
181  msgStruct.addCallStackInfo( stackHistory ); \
182  msgStruct.addContextInfo( GEOS_DETAIL_REST_ARGS( __VA_ARGS__ ) ); \
183  GEOS_ERROR_LOGGER_INSTANCE.flushErrorMsg( msgStruct ); \
184  } \
185  LvArray::system::callErrorHandler(); \
186  } \
187  } while( false )
188 #elif __CUDA_ARCH__
189 #define GEOS_ERROR_IF_CAUSE( COND, CAUSE_MESSAGE, ... ) \
190  do \
191  { \
192  if( COND ) \
193  { \
194  constexpr char const * formatString = "***** ERROR\n" \
195  "***** LOCATION" LOCATION "\n" \
196  "***** BLOCK: [%u, %u, %u]\n" \
197  "***** THREAD: [%u, %u, %u]\n" \
198  "***** " STRINGIZE( CAUSE_MESSAGE ) "\n" \
199  "***** " STRINGIZE( GEOS_DETAIL_FIRST_ARG( __VA_ARGS__ ) ) "\n\n"; \
200  printf( formatString, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, threadIdx.z ); \
201  asm ( "trap;" ); \
202  } \
203  } while( false )
204 #endif
205 
213 #define GEOS_ERROR_IF( COND, ... ) \
214  GEOS_ERROR_IF_CAUSE( COND, "Error cause: " STRINGIZE( COND ), __VA_ARGS__ )
215 
222 #define GEOS_ERROR( ... ) GEOS_ERROR_IF_CAUSE( true, "", __VA_ARGS__ )
223 
233 #if !defined(GEOS_DEVICE_COMPILE)
234 #define GEOS_THROW_IF_CAUSE( COND, CAUSE_MESSAGE, MSG, ... ) \
235  do \
236  { \
237  if( COND ) \
238  { \
239  std::ostringstream __msgoss; \
240  __msgoss << MSG; \
241  std::string __message = __msgoss.str(); \
242  __msgoss = std::ostringstream(); \
243  __msgoss << CAUSE_MESSAGE; \
244  std::string __cause = __msgoss.str(); \
245  std::ostringstream __oss; \
246  __oss << "***** EXCEPTION\n"; \
247  __oss << "***** LOCATION: " LOCATION "\n"; \
248  __oss << "***** " << __cause << "\n"; \
249  __oss << "***** Rank " << ::geos::logger::internal::g_rankString << ": " << __message << "\n"; \
250  std::string stackHistory = LvArray::system::stackTrace( true ); \
251  __oss << stackHistory; \
252  if( GEOS_ERROR_LOGGER_INSTANCE.isOutputFileEnabled() ) \
253  { \
254  if( GEOS_ERROR_LOGGER_INSTANCE.currentErrorMsg().m_type == ErrorLogger::MsgType::Undefined ) \
255  { /* first throw site, we initialize the error message completly */ \
256  GEOS_ERROR_LOGGER_INSTANCE.currentErrorMsg() \
257  .setType( ErrorLogger::MsgType::Exception ) \
258  .setCodeLocation( __FILE__, __LINE__ ) \
259  .setCause( __cause ) \
260  .addRank( ::geos::logger::internal::g_rank ) \
261  .addCallStackInfo( stackHistory ); \
262  } \
263  GEOS_ERROR_LOGGER_INSTANCE.currentErrorMsg() \
264  .addToMsg( __message ) \
265  .addContextInfo( GEOS_DETAIL_REST_ARGS( __VA_ARGS__ ) ); \
266  } \
267  throw GEOS_DETAIL_FIRST_ARG( __VA_ARGS__ )( __oss.str() ); \
268  } \
269  } while( false )
270 #elif __CUDA_ARCH__
271 #define GEOS_THROW_IF_CAUSE( COND, CAUSE_MESSAGE, MSG, ... ) \
272  do \
273  { \
274  if( COND ) \
275  { \
276  static char const formatString[] = "***** ERROR\n" \
277  "***** LOCATION" LOCATION "\n" \
278  "***** BLOCK: [%u, %u, %u]\n" \
279  "***** THREAD: [%u, %u, %u]\n" \
280  "***** " STRINGIZE( CAUSE_MESSAGE ) "\n" \
281  "***** " STRINGIZE( GEOS_DETAIL_FIRST_ARG( __VA_ARGS__ ) ) "\n\n"; \
282  printf( formatString, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, threadIdx.z ); \
283  asm ( "trap;" ); \
284  } \
285  } while( false )
286 #endif
287 
296 #define GEOS_THROW_IF( COND, MSG, ... ) \
297  GEOS_THROW_IF_CAUSE( COND, "Error cause: " STRINGIZE( COND ), MSG, __VA_ARGS__ )
298 
306 #define GEOS_THROW( MSG, ... ) GEOS_THROW_IF_CAUSE( true, "", MSG, __VA_ARGS__ )
307 
316 #if !defined(GEOS_DEVICE_COMPILE)
317 #define GEOS_WARNING_IF_CAUSE( COND, CAUSE_MESSAGE, ... ) \
318  do \
319  { \
320  if( COND ) \
321  { \
322  std::ostringstream __msgoss; \
323  __msgoss << GEOS_DETAIL_FIRST_ARG( __VA_ARGS__ ); \
324  std::string __message = __msgoss.str(); \
325  __msgoss = std::ostringstream(); \
326  __msgoss << CAUSE_MESSAGE; \
327  std::string __cause = __msgoss.str(); \
328  std::ostringstream __oss; \
329  __oss << "***** WARNING\n"; \
330  __oss << "***** LOCATION: " LOCATION "\n"; \
331  __oss << "***** " << __cause << "\n"; \
332  __oss << "***** Rank " << ::geos::logger::internal::g_rankString << ": " << __message << "\n"; \
333  std::cout << __oss.str() << std::endl; \
334  if( GEOS_ERROR_LOGGER_INSTANCE.isOutputFileEnabled() ) \
335  { \
336  ErrorLogger::ErrorMsg msgStruct( ErrorLogger::MsgType::Warning, \
337  __message, \
338  ::geos::logger::internal::g_rank, \
339  __FILE__, \
340  __LINE__ ); \
341  msgStruct.setCause( __cause ); \
342  msgStruct.addContextInfo( GEOS_DETAIL_REST_ARGS( __VA_ARGS__ ) ); \
343  GEOS_ERROR_LOGGER_INSTANCE.flushErrorMsg( msgStruct ); \
344  } \
345  } \
346  } while( false )
347 #elif __CUDA_ARCH__
348 #define GEOS_WARNING_IF_CAUSE( COND, CAUSE_MESSAGE, ... ) \
349  do \
350  { \
351  if( COND ) \
352  { \
353  static char const formatString[] = "***** WARNING\n" \
354  "***** LOCATION" LOCATION "\n" \
355  "***** BLOCK: [%u, %u, %u]\n" \
356  "***** THREAD: [%u, %u, %u]\n" \
357  "***** " STRINGIZE( CAUSE_MESSAGE ) "\n" \
358  "***** " STRINGIZE( GEOS_DETAIL_FIRST_ARG( __VA_ARGS__ ) ) "\n\n"; \
359  printf( formatString, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, threadIdx.z ); \
360  asm ( "trap;" ); \
361  } \
362  } while( false )
363 #endif
364 
372 #define GEOS_WARNING_IF( COND, ... ) \
373  GEOS_WARNING_IF_CAUSE( COND, "Warning cause: " STRINGIZE( COND ), __VA_ARGS__ )
374 
381 #define GEOS_WARNING( ... ) GEOS_WARNING_IF_CAUSE( true, "", __VA_ARGS__ )
382 
388 #define GEOS_INFO_IF( EXP, msg ) LVARRAY_INFO_IF( EXP, msg )
389 
394 #define GEOS_INFO( msg ) LVARRAY_INFO( msg )
395 
401 #define GEOS_ERROR_LHS_RHS_DECLS( lhs, rhs ) \
402  GEOS_MAYBE_UNUSED auto const lhsResult = (lhs); \
403  GEOS_MAYBE_UNUSED auto const rhsResult = (rhs)
404 
415 #define GEOS_ERROR_IF_OP_MSG( lhs, OP, NOP, rhs, ... ) \
416  do { \
417  GEOS_ERROR_LHS_RHS_DECLS( lhs, rhs ); \
418  GEOS_ERROR_IF_CAUSE( lhsResult OP rhsResult, \
419  "Expected: " #lhs " " #NOP " " #rhs "\n* " #lhs " = " << lhsResult << "\n* " #rhs " = " << rhsResult << "\n", \
420  __VA_ARGS__ ); \
421  } while(false)
422 
423 
432 #define GEOS_ERROR_IF_EQ_MSG( lhs, rhs, ... ) GEOS_ERROR_IF_OP_MSG( lhs, ==, !=, rhs, __VA_ARGS__ )
433 
439 #define GEOS_ERROR_IF_EQ( lhs, rhs ) GEOS_ERROR_IF_EQ_MSG( lhs, rhs, "" )
440 
449 #define GEOS_ERROR_IF_NE_MSG( lhs, rhs, ... ) GEOS_ERROR_IF_OP_MSG( lhs, !=, ==, rhs, __VA_ARGS__ )
450 
456 #define GEOS_ERROR_IF_NE( lhs, rhs ) GEOS_ERROR_IF_NE_MSG( lhs, rhs, "" )
457 
466 #define GEOS_ERROR_IF_GT_MSG( lhs, rhs, ... ) GEOS_ERROR_IF_OP_MSG( lhs, >, <=, rhs, __VA_ARGS__ )
467 
473 #define GEOS_ERROR_IF_GT( lhs, rhs ) GEOS_ERROR_IF_GT_MSG( lhs, rhs, "" )
474 
483 #define GEOS_ERROR_IF_GE_MSG( lhs, rhs, ... ) GEOS_ERROR_IF_OP_MSG( lhs, >=, <, rhs, __VA_ARGS__ )
484 
490 #define GEOS_ERROR_IF_GE( lhs, rhs ) GEOS_ERROR_IF_GE_MSG( lhs, rhs, "" )
491 
500 #define GEOS_ERROR_IF_LT_MSG( lhs, rhs, ... ) GEOS_ERROR_IF_OP_MSG( lhs, <, >=, rhs, __VA_ARGS__ )
501 
507 #define GEOS_ERROR_IF_LT( lhs, rhs ) GEOS_ERROR_IF_LT_MSG( lhs, rhs, "" )
508 
517 #define GEOS_ERROR_IF_LE_MSG( lhs, rhs, ... ) GEOS_ERROR_IF_OP_MSG( lhs, <=, >, rhs, __VA_ARGS__ )
518 
519 
525 #define GEOS_ERROR_IF_LE( lhs, rhs ) GEOS_ERROR_IF_LE_MSG( lhs, rhs, "" )
526 
537 #define GEOS_WARNING_IF_OP_MSG( lhs, OP, NOP, rhs, ... ) \
538  do { \
539  GEOS_ERROR_LHS_RHS_DECLS( lhs, rhs ); \
540  GEOS_WARNING_IF_CAUSE( lhsResult OP rhsResult, \
541  "Expected: " #lhs " " #NOP " " #rhs "\n* " #lhs " = " << lhsResult << "\n* " #rhs " = " << rhsResult << "\n", \
542  __VA_ARGS__ ); \
543  } while(false)
544 
545 
554 #define GEOS_WARNING_IF_EQ_MSG( lhs, rhs, ... ) GEOS_WARNING_IF_OP_MSG( lhs, ==, !=, rhs, __VA_ARGS__ )
555 
561 #define GEOS_WARNING_IF_EQ( lhs, rhs ) GEOS_WARNING_IF_EQ_MSG( lhs, rhs, "" )
562 
571 #define GEOS_WARNING_IF_NE_MSG( lhs, rhs, ... ) GEOS_WARNING_IF_OP_MSG( lhs, !=, ==, rhs, __VA_ARGS__ )
572 
578 #define GEOS_WARNING_IF_NE( lhs, rhs ) GEOS_WARNING_IF_NE_MSG( lhs, rhs, "" )
579 
588 #define GEOS_WARNING_IF_GT_MSG( lhs, rhs, ... ) GEOS_WARNING_IF_OP_MSG( lhs, >, <=, rhs, __VA_ARGS__ )
589 
595 #define GEOS_WARNING_IF_GT( lhs, rhs ) GEOS_WARNING_IF_GT_MSG( lhs, rhs, "" )
596 
605 #define GEOS_WARNING_IF_GE_MSG( lhs, rhs, ... ) GEOS_WARNING_IF_OP_MSG( lhs, >=, <, rhs, __VA_ARGS__ )
606 
612 #define GEOS_WARNING_IF_GE( lhs, rhs ) GEOS_WARNING_IF_GE_MSG( lhs, rhs, "" )
613 
622 #define GEOS_WARNING_IF_LT_MSG( lhs, rhs, ... ) GEOS_WARNING_IF_OP_MSG( lhs, <, >=, rhs, __VA_ARGS__ )
623 
629 #define GEOS_WARNING_IF_LT( lhs, rhs ) GEOS_WARNING_IF_LT_MSG( lhs, rhs, "" )
630 
639 #define GEOS_WARNING_IF_LE_MSG( lhs, rhs, ... ) GEOS_WARNING_IF_OP_MSG( lhs, <=, >, rhs, __VA_ARGS__ )
640 
646 #define GEOS_WARNING_IF_LE( lhs, rhs ) GEOS_WARNING_IF_LE_MSG( lhs, rhs, "" )
647 
659 #define GEOS_THROW_IF_OP_MSG( lhs, OP, NOP, rhs, MSG, ... ) \
660  do { \
661  GEOS_ERROR_LHS_RHS_DECLS( lhs, rhs ); \
662  GEOS_THROW_IF_CAUSE( lhsResult OP rhsResult, \
663  "Expected: " #lhs " " #NOP " " #rhs "\n* " #lhs " = " << lhsResult << "\n* " #rhs " = " << rhsResult << "\n", \
664  MSG, __VA_ARGS__ ); \
665  } while(false)
666 
667 
668 
678 #define GEOS_THROW_IF_EQ_MSG( lhs, rhs, MSG, ... ) GEOS_THROW_IF_OP_MSG( lhs, ==, !=, rhs, MSG, __VA_ARGS__ )
679 
688 #define GEOS_THROW_IF_EQ( lhs, rhs, ... ) GEOS_THROW_IF_EQ_MSG( lhs, rhs, "", __VA_ARGS__ )
689 
699 #define GEOS_THROW_IF_NE_MSG( lhs, rhs, MSG, ... ) GEOS_THROW_IF_OP_MSG( lhs, !=, ==, rhs, MSG, __VA_ARGS__ )
700 
709 #define GEOS_THROW_IF_NE( lhs, rhs, ... ) GEOS_THROW_IF_NE_MSG( lhs, rhs, "", __VA_ARGS__ )
710 
720 #define GEOS_THROW_IF_GT_MSG( lhs, rhs, MSG, ... ) GEOS_THROW_IF_OP_MSG( lhs, >, <=, rhs, MSG, __VA_ARGS__ )
721 
730 #define GEOS_THROW_IF_GT( lhs, rhs, ... ) GEOS_THROW_IF_GT_MSG( lhs, rhs, "", __VA_ARGS__ )
731 
741 #define GEOS_THROW_IF_GE_MSG( lhs, rhs, MSG, ... ) GEOS_THROW_IF_OP_MSG( lhs, >=, <, rhs, MSG, __VA_ARGS__ )
742 
751 #define GEOS_THROW_IF_GE( lhs, rhs, ... ) GEOS_THROW_IF_GE_MSG( lhs, rhs, "", __VA_ARGS__ )
752 
762 #define GEOS_THROW_IF_LT_MSG( lhs, rhs, MSG, ... ) GEOS_THROW_IF_OP_MSG( lhs, <, >=, rhs, MSG, __VA_ARGS__ )
763 
772 #define GEOS_THROW_IF_LT( lhs, rhs, ... ) GEOS_THROW_IF_LT_MSG( lhs, rhs, "", __VA_ARGS__ )
773 
783 #define GEOS_THROW_IF_LE_MSG( lhs, rhs, MSG, ... ) GEOS_THROW_IF_OP_MSG( lhs, <=, >, rhs, MSG, __VA_ARGS__ )
784 
793 #define GEOS_THROW_IF_LE( lhs, rhs, ... ) GEOS_THROW_IF_LE_MSG( lhs, rhs, "", __VA_ARGS__ )
794 
795 #if !defined(NDEBUG) || defined(GEOS_ASSERT_ENABLED)
796 
800 #define GEOS_ASSERT_ENABLED
801 
814 #define GEOS_ASSERT_MSG( COND, ... ) \
815  GEOS_ERROR_IF_CAUSE( !( COND ), "Expected: " STRINGIZE( COND ), __VA_ARGS__ )
816 
826 #define GEOS_ASSERT_OP_MSG( lhs, OP, rhs, ... ) \
827  { \
828  GEOS_ERROR_LHS_RHS_DECLS( lhs, rhs ); \
829  GEOS_ERROR_IF_CAUSE( !( lhsResult OP rhsResult ), \
830  "Expected: " #lhs " " #OP " " #rhs "\n* " #lhs " = " << lhsResult << "\n* " #rhs " = " << rhsResult << "\n", \
831  __VA_ARGS__ ); \
832  }
833 
834 #else
835 
836 #define GEOS_ASSERT_MSG( ... ) ((void) 0)
837 #define GEOS_ASSERT_OP_MSG( ... ) ((void) 0)
838 
839 #endif
840 
845 #define GEOS_ASSERT( COND ) GEOS_ASSERT_MSG( COND, "" )
846 
855 #define GEOS_ASSERT_EQ_MSG( lhs, rhs, ... ) GEOS_ASSERT_OP_MSG( lhs, ==, rhs, __VA_ARGS__ )
856 
862 #define GEOS_ASSERT_EQ( lhs, rhs ) GEOS_ASSERT_EQ_MSG( lhs, rhs, "" )
863 
872 #define GEOS_ASSERT_NE_MSG( lhs, rhs, ... ) GEOS_ASSERT_OP_MSG( lhs, !=, rhs, __VA_ARGS__ )
873 
879 #define GEOS_ASSERT_NE( lhs, rhs ) GEOS_ASSERT_NE_MSG( lhs, rhs, "" )
880 
889 #define GEOS_ASSERT_GT_MSG( lhs, rhs, ... ) GEOS_ASSERT_OP_MSG( lhs, >, rhs, __VA_ARGS__ )
890 
896 #define GEOS_ASSERT_GT( lhs, rhs ) GEOS_ASSERT_GT_MSG( lhs, rhs, "" )
897 
906 #define GEOS_ASSERT_GE_MSG( lhs, rhs, ... ) GEOS_ASSERT_OP_MSG( lhs, >=, rhs, __VA_ARGS__ )
907 
913 #define GEOS_ASSERT_GE( lhs, rhs ) GEOS_ASSERT_GE_MSG( lhs, rhs, "" )
914 
923 #define GEOS_ASSERT_LT_MSG( lhs, rhs, ... ) GEOS_ASSERT_OP_MSG( lhs, <, rhs, __VA_ARGS__ )
924 
930 #define GEOS_ASSERT_LT( lhs, rhs ) GEOS_ASSERT_LT_MSG( lhs, rhs, "" )
931 
940 #define GEOS_ASSERT_LE_MSG( lhs, rhs, ... ) GEOS_ASSERT_OP_MSG( lhs, <=, rhs, __VA_ARGS__ )
941 
947 #define GEOS_ASSERT_LE( lhs, rhs ) GEOS_ASSERT_LE_MSG( lhs, rhs, "" )
948 
949 namespace geos
950 {
951 
955 struct InputError : public std::runtime_error
956 {
961  InputError( std::string const & what ):
962  std::runtime_error( what )
963  {}
964 
969  InputError( char const * const what ):
970  std::runtime_error( what )
971  {}
972 
978  InputError( std::exception const & subException, std::string const & msgToInsert );
979 };
980 
984 struct SimulationError : public std::runtime_error
985 {
990  SimulationError( std::string const & what ):
991  std::runtime_error( what )
992  {}
993 
998  SimulationError( char const * const what ):
999  std::runtime_error( what )
1000  {}
1001 
1008  SimulationError( std::exception const & subException, std::string const & msgToInsert );
1009 };
1010 
1017 struct BadTypeError : public std::runtime_error
1018 {
1023  BadTypeError( std::string const & what ):
1024  std::runtime_error( what )
1025  {}
1026 };
1027 
1031 class NotAnError : public std::exception
1032 {};
1033 
1034 namespace logger
1035 {
1036 
1037 namespace internal
1038 {
1039 
1040 extern int g_rank;
1041 
1042 extern std::string g_rankString;
1043 
1044 extern std::ostream * g_rankStream;
1045 
1046 } // namespace internal
1047 
1048 #if defined(GEOS_USE_MPI)
1054 void InitializeLogger( MPI_Comm comm, const std::string & rank_output_dir="" );
1055 #endif
1056 
1061 void InitializeLogger( const std::string & rank_output_dir="" );
1062 
1067 
1068 } // namespace logger
1069 
1070 } // namespace geos
1071 
1072 #endif /* GEOS_COMMON_LOGGER_HPP */
This file provides the infrastructure to capture external errors.
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.
Definition: Logger.hpp:1032
std::string string
String type.
Definition: DataTypes.hpp:90
Exception class used to report errors from type conversion.
Definition: Logger.hpp:1018
BadTypeError(std::string const &what)
Constructor.
Definition: Logger.hpp:1023
Exception class used to report errors in user input.
Definition: Logger.hpp:956
InputError(char const *const what)
Constructor.
Definition: Logger.hpp:969
InputError(std::exception const &subException, std::string const &msgToInsert)
Constructs an InputError from an underlying exception.
InputError(std::string const &what)
Constructor.
Definition: Logger.hpp:961
Exception class used to report errors in user input.
Definition: Logger.hpp:985
SimulationError(std::exception const &subException, std::string const &msgToInsert)
Construct a SimulationError from an underlying exception.
SimulationError(std::string const &what)
Constructor.
Definition: Logger.hpp:990
SimulationError(char const *const what)
Constructor.
Definition: Logger.hpp:998