18 #include "carma/szautil/Directives.h"
19 #include "carma/szautil/IoLock.h"
20 #include "carma/szautil/Logger.h"
41 Exception(std::string str,
const char * filename,
42 const int lineNumber,
bool report);
51 Exception(std::ostringstream& os,
const char * filename,
52 const int lineNumber,
bool report);
57 Exception(sza::util::LogStream& ls,
58 const char* filename,
const int lineNumber,
bool report);
63 Exception(sza::util::LogStream* ls,
64 const char* filename,
const int lineNumber,
bool report);
77 inline void report() {}
84 inline void report(std::string& what)
86 sza::util::IoLock::lockCerr();
88 sza::util::IoLock::unlockCerr();
96 inline void report(std::string what)
98 sza::util::IoLock::lockCerr();
100 sza::util::IoLock::unlockCerr();
103 inline const char* what() {
104 return message_.c_str();
109 std::string message_;
116 #define Error(x) sza::util::Exception((x), __FILE__, __LINE__, true)
117 #define ErrorNoReport(x) sza::util::Exception((x), __FILE__, __LINE__, false)
118 #define ErrorDef(x,y) sza::util::Exception (x)((y), __FILE__, __LINE__, true)
124 #define ThrowError(text) \
126 std::ostringstream _macroOs; \
128 sza::util::ErrHandler::throwError(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, true, false, false);\
131 #ifdef ThrowColorError
132 #undef ThrowColorError
135 #define ThrowColorError(text, color) \
137 XtermManip _macroXtm;\
138 std::ostringstream _macroOs; \
139 _macroOs << _macroXtm.bg("black") << _macroXtm.fg(color) << _macroXtm.textMode("bold");\
141 _macroOs << _macroXtm.bg("default") << _macroXtm.fg("default") << _macroXtm.textMode("normal");\
142 sza::util::ErrHandler::throwError(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, true, false, false);\
145 #ifdef ThrowSimpleError
146 #undef ThrowSimpleError
149 #define ThrowSimpleError(text) \
151 std::ostringstream _macroOs; \
153 sza::util::ErrHandler::throwError(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, true, true, false);\
160 #define ThrowSysError(text) \
162 std::ostringstream _macroOs; \
164 sza::util::ErrHandler::throwError(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, true, false, true);\
171 #define ReportError(text) \
173 std::ostringstream _macroOs; \
175 sza::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, true, false, false);\
178 #ifdef ReportSimpleError
179 #undef ReportSimpleError
182 #define ReportSimpleError(text) \
184 std::ostringstream _macroOs; \
186 sza::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, true, true, false);\
189 #ifdef ReportSysError
190 #undef ReportSysError
193 #define ReportSysError(text) \
195 std::ostringstream _macroOs; \
197 sza::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, true, false, true);\
204 #define ReportMessage(text) \
206 std::ostringstream _macroOs; \
208 sza::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, false, true, false);\
215 #define LogMessage(error, text) \
217 std::ostringstream _macroOs; \
219 sza::util::ErrHandler::log(_macroOs, __FILE__, __LINE__, __PRETTY_FUNCTION__, false, true, false);\
222 #define COUT(statement) \
224 std::ostringstream _macroOs; \
225 _macroOs << statement << std::endl; \
226 sza::util::Logger::printToStdout(_macroOs.str()); \
229 #define COUTCOLOR(statement, color) \
231 XtermManip _macroXtm;\
232 std::ostringstream _macroOs; \
233 _macroOs << _macroXtm.bg("black") << _macroXtm.fg(color) << _macroXtm.textMode("bold");\
234 _macroOs << statement << std::endl; \
235 _macroOs << _macroXtm.bg("default") << _macroXtm.fg("default") << _macroXtm.textMode("normal");\
236 sza::util::Logger::printToStdout(_macroOs.str()); \
239 #define COUTCOLORNNL(statement, color) \
241 sza::util::XtermManip _macroXtm; \
242 std::ostringstream _macroOs; \
243 _macroOs << _macroXtm.bg("black") << _macroXtm.fg(color) << _macroXtm.textMode("bold");\
244 _macroOs << statement; \
245 _macroOs << _macroXtm.bg("default") << _macroXtm.fg("default") << _macroXtm.textMode("normal");\
246 sza::util::Logger::printToStdout(_macroOs.str()); \
249 #define CTOUT(statement) \
251 sza::util::TimeVal _macroTimeVal;\
252 _macroTimeVal.setToCurrentTime();\
253 std::ostringstream _macroOs; \
254 _macroOs << _macroTimeVal << ": " << statement << std::endl; \
255 sza::util::Logger::printToStdout(_macroOs.str()); \
258 #define CERR(statement) \
260 std::ostringstream _macroOs; \
261 _macroOs << statement << std::endl; \
262 sza::util::Logger::printToStderr(_macroOs.str()); \
265 #define CTERR(statement) \
267 sza::util::TimeVal _macroTimeVal;\
268 _macroTimeVal.setToCurrentTime();\
269 std::ostringstream _macroOs; \
270 _macroOs << _macroTimeVal << ": " << statement << std::endl; \
271 sza::util::Logger::printToStderr(_macroOs.str()); \
Tagged: Mon Apr 10 13:32:05 PDT 2006.
Tagged: Sun Jan 20 13:34:20 NZDT 2008.