Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Debug.h

Go to the documentation of this file.
00001 #ifndef _Debug_h_
00002 #define _Debug_h_
00003 #include <fstream>
00004 
00005 #include "config.h"
00006 #include "Logger.h"
00007 // Insert the following lines into your main app
00008 //TRACE(ofstream ctrace("trace"));
00009 //DEBUG(ofstream cdbg("debug"));
00010 //int verbose=0
00011 //int verbose_what=0
00012 
00013 // Verbosity levels
00014 // See logger.h
00015 
00016 #ifdef ENABLE_DEBUG
00017 extern Logger slog;
00018 #define DEBUG(x) x
00019 #define VERB(x) x
00020 #define VERBLV(lv,x) if(lv<verbose) { x; }
00021 #define VERBTY(w,x) if(verbose_what==w) { x; }
00022 #else
00023 #define DEBUG(x)
00024 #define VERB(x)
00025 #define VERBLV(lv,x)
00026 #define VERBTY(w,x)
00027 #endif
00028 
00029 #ifdef ENABLE_ASSERTIONS
00030 extern Logger slog;
00031 #define ASSERT(x) x
00032 #define ASSERT2(x)
00033 #else
00034 #define ASSERT(x)
00035 #define ASSERT2(x)
00036 #endif
00037 
00038 #define NC_CATCH_ALL(text) \
00039 catch(sockerr e) \
00040 { \
00041         slog.p(Logger::Error) << text << " caught " \
00042             << "sockbuf " << e.operation() \
00043             << e.serrno() \
00044             << " " << e.errstr() << "\n"; \
00045         throw; \
00046 } \
00047  \
00048 catch(UsageError e) \
00049 { \
00050         slog.p(Logger::Error) << text << " caught " << "UsageError "; \
00051         e.print(); \
00052         throw; \
00053 } \
00054  \
00055 catch(NotAllowedError e) \
00056 { \
00057         slog.p(Logger::Error) << text << " caught " << "NotAllowdError "; \
00058         e.print(); \
00059         throw; \
00060 } \
00061  \
00062 catch(NoSuchArticleError e) \
00063 { \
00064         slog.p(Logger::Error) << text << " caught " << "NoSuchArticleError "; \
00065         e.print(); \
00066         throw; \
00067 } \
00068  \
00069 catch(DuplicateArticleError e) \
00070 { \
00071         slog.p(Logger::Error) << text << " caught " \
00072             << "DuplicateArticleError "; \
00073         e.print(); \
00074         throw; \
00075 } \
00076  \
00077 catch(NoSuchGroupError e) \
00078 { \
00079         slog.p(Logger::Error) << text << " caught " << "NoSuchGroupError "; \
00080         e.print(); \
00081         throw; \
00082 } \
00083  \
00084 catch(NoNewsServerError e) \
00085 { \
00086         slog.p(Logger::Error) << text << " caught " << "NoNewsServerError "; \
00087         e.print(); \
00088         throw; \
00089 } \
00090  \
00091 catch(NoSuchFieldError e) \
00092 { \
00093         slog.p(Logger::Error) << text << " caught " << "NoSuchFieldError "; \
00094         e.print(); \
00095         throw; \
00096 } \
00097  \
00098 catch(NSError e) \
00099 { \
00100         slog.p(Logger::Error) << text << " caught " << "NSError "; \
00101         e.print(); \
00102         throw; \
00103 } \
00104  \
00105 catch(AssertionError e) \
00106 { \
00107         slog.p(Logger::Error) << text << " caught " << "AssertionError "; \
00108         e.print(); \
00109         throw; \
00110 } \
00111  \
00112 catch(IOError e) \
00113 { \
00114         slog.p(Logger::Error) << text << " caught " << "IOError "; \
00115         e.print(); \
00116         throw; \
00117 } \
00118  \
00119 catch(SystemError e) \
00120 { \
00121         slog.p(Logger::Error) << text << " caught " << "SystemError "; \
00122         e.print(); \
00123         throw; \
00124 } \
00125  \
00126 catch(Error e) \
00127 { \
00128         slog.p(Logger::Error) << text << " caught " << "Error "; \
00129         e.print(); \
00130         throw; \
00131 } \
00132  \
00133 catch(...) \
00134 { \
00135         slog.p(Logger::Error) << text << " caught " << "unknown!!" << "\n"; \
00136         throw; \
00137 }
00138 
00139 #endif

Generated on Sun Oct 24 21:08:17 2004 for NewsCache by doxygen 1.3.6-20040222