00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef _LALERROR_H
00045 #define _LALERROR_H
00046
00047 #include <lal/LALDatatypes.h>
00048
00049 #include <lal/XLALError.h>
00050
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054
00055
00056 NRCSID( LALERRORH, "$Id: LALError.h,v 1.3 2007/06/08 14:41:52 bema Exp $" );
00057
00058
00059 enum
00060 {
00061 LALNDEBUG = 0,
00062 LALERROR = 1,
00063 LALWARNING = 2,
00064 LALINFO = 4,
00065 LALTRACE = 8,
00066 LALMEMINFO = 16,
00067 LALNMEMDBG = 32,
00068 LALNMEMPAD = 64,
00069 LALNMEMTRK = 128,
00070 LALMEMDBG = 16384
00071 };
00072
00073
00074 enum { LALMSGLVL1 = LALERROR };
00075 enum { LALMSGLVL2 = LALERROR | LALWARNING };
00076 enum { LALMSGLVL3 = LALERROR | LALWARNING | LALINFO };
00077 enum { LALMEMTRACE = LALTRACE | LALMEMINFO };
00078 enum { LALALLDBG = ~( LALNMEMDBG | LALNMEMPAD | LALNMEMTRK ) };
00079
00080 extern int ( *lalRaiseHook )( int, const char *, ... );
00081 extern void ( *lalAbortHook )( const char *, ... );
00082
00083 int
00084 LALPrintError( const char *fmt, ... );
00085
00086 int
00087 LALRaise( int sig, const char *fmt, ... );
00088
00089 void
00090 LALAbort( const char *fmt, ... );
00091
00092 int
00093 LALError( LALStatus *status, const char *statement );
00094
00095 int
00096 LALWarning( LALStatus *status, const char *warning );
00097
00098 int
00099 LALInfo( LALStatus *status, const char *info );
00100
00101 int
00102 LALTrace( LALStatus *status, int exitflg );
00103
00104 int
00105 LALInitStatus( LALStatus *status, const char *function, const char *id,
00106 const char *file, const int line );
00107
00108 int
00109 LALPrepareReturn( LALStatus *status, const char *file, const int line );
00110
00111 int
00112 LALAttatchStatusPtr( LALStatus *status, const char *file, const int line );
00113
00114 int
00115 LALDetatchStatusPtr( LALStatus *status, const char *file, const int line );
00116
00117 int
00118 LALPrepareAbort( LALStatus *status, const INT4 code, const char *mesg,
00119 const char *file, const int line );
00120
00121 int
00122 LALPrepareAssertFail( LALStatus *status, const INT4 code, const char *mesg,
00123 const char *statement, const char *file,
00124 const int line );
00125
00126 int
00127 LALCheckStatusPtr( LALStatus *status, const char *statement, const char *file,
00128 const int line );
00129
00130 void
00131 FREESTATUSPTR( LALStatus *status );
00132
00133 void
00134 REPORTSTATUS( LALStatus *status );
00135
00136 #ifdef NDEBUG
00137
00138 #define LALError( statusptr, statement ) 0
00139 #define LALWarning( statusptr, warning ) 0
00140 #define LALInfo( statusptr, info ) 0
00141 #define LALTrace( statusptr, exitflg ) 0
00142
00143 #else
00144
00145 #ifndef NOLALMACROS
00146
00147 #define LALError( statusptr, statement ) \
00148 ( lalDebugLevel & LALERROR ? \
00149 LALPrintError( "Error[%d] %d: function %s, file %s, line %d, %s\n" \
00150 " %s %s\n", (statusptr)->level, (statusptr)->statusCode, \
00151 (statusptr)->function, (statusptr)->file, (statusptr)->line, \
00152 (statusptr)->Id, (statement) ? (statement) : "", \
00153 (statusptr)->statusDescription ) : 0 )
00154
00155 #define LALWarning( statusptr, warning ) \
00156 ( lalDebugLevel & LALWARNING ? \
00157 LALPrintError( "Warning[%d]: function %s, file %s, line %d, %s\n" \
00158 " %s\n", (statusptr)->level, (statusptr)->function, \
00159 (statusptr)->file, (statusptr)->line, (statusptr)->Id, (warning) ) \
00160 : 0 )
00161
00162 #define LALInfo( statusptr, info ) \
00163 ( lalDebugLevel & LALINFO ? \
00164 LALPrintError( "Info[%d]: function %s, file %s, line %d, %s\n" \
00165 " %s\n", (statusptr)->level, (statusptr)->function, \
00166 (statusptr)->file, (statusptr)->line, (statusptr)->Id, (info) ) \
00167 : 0 )
00168
00169 #define LALTrace( statusptr, exitflg ) \
00170 ( lalDebugLevel & LALTRACE ? \
00171 LALPrintError( "%s[%d]: function %s, file %s, line %d, %s\n", \
00172 (exitflg) ? "Leave" : "Enter", (statusptr)->level, \
00173 (statusptr)->function, (statusptr)->file, (statusptr)->line, \
00174 (statusptr)->Id ) \
00175 : 0 )
00176
00177 #endif
00178
00179 #endif
00180
00181 #ifdef __cplusplus
00182 }
00183 #endif
00184
00185 #endif