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 #ifndef ODEBUG_H
00034 #define ODEBUG_H
00035
00036 #include <qstring.h>
00037
00038 class QWidget;
00039 class QDateTime;
00040 class QDate;
00041 class QTime;
00042 class QPoint;
00043 class QSize;
00044 class QRect;
00045 class QRegion;
00046 class QStringList;
00047 class QColor;
00048 class QBrush;
00049
00050 namespace Opie {
00051 namespace Core {
00052
00053 class odbgstream;
00054 class ondbgstream;
00055
00056 #ifdef __GNUC__
00057 #define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] "
00058 #else
00059 #define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
00060 #endif
00061
00062 #define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
00063
00064 #define owarn Opie::Core::odWarning()
00065 #define oerr Opie::Core::odError()
00066 #define odebug Opie::Core::odDebug()
00067 #define ofatal Opie::Core::odFatal()
00068 #define oendl "\n"
00069
00070 const int ODEBUG_IGNORE = -1;
00071 const int ODEBUG_FILE = 0;
00072 const int ODEBUG_MSGBOX = 1;
00073 const int ODEBUG_STDERR = 2;
00074 const int ODEBUG_SYSLOG = 3;
00075 const int ODEBUG_SOCKET = 4;
00076
00077 class odbgstreamprivate;
00092
00093
00094
00095
00096 class odbgstream
00097 {
00098 public:
00102 odbgstream(unsigned int _area, unsigned int _level, bool _print = true);
00103 odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true);
00104 odbgstream(odbgstream &str);
00105 odbgstream(const odbgstream &str);
00106 virtual ~odbgstream();
00107
00113 odbgstream &operator<<(bool i);
00119 odbgstream &operator<<(short i);
00125 odbgstream &operator<<(unsigned short i);
00131 odbgstream &operator<<(char i);
00137 odbgstream &operator<<(unsigned char i);
00143 odbgstream &operator<<(int i);
00149 odbgstream &operator<<(unsigned int i);
00155 odbgstream &operator<<(long i);
00161 odbgstream &operator<<(unsigned long i);
00165 virtual void flush();
00171 odbgstream &operator<<(const QString& string);
00177 odbgstream &operator<<(const char *string);
00183 odbgstream &operator<<(const QCString& string);
00189 odbgstream& operator<<(const void * p);
00195 odbgstream& operator<<(double d);
00202 odbgstream &form(const char *format, ...);
00208 odbgstream& operator<< (QWidget* widget);
00209
00215 odbgstream& operator<< ( const QDateTime& dateTime );
00216
00222 odbgstream& operator<< ( const QDate& date );
00223
00229 odbgstream& operator<< ( const QTime& time );
00230
00236 odbgstream& operator<< ( const QPoint& point );
00237
00243 odbgstream& operator<< ( const QSize& size );
00244
00250 odbgstream& operator<< ( const QRect& rect);
00251
00257 odbgstream& operator<< ( const QRegion& region);
00258
00264 odbgstream& operator<< ( const QStringList& list);
00265
00271 odbgstream& operator<< ( const QColor& color);
00272
00278 odbgstream& operator<< ( const QBrush& brush );
00279
00280 private:
00281 QString output;
00282 unsigned int area, level;
00283 bool print;
00284 odbgstreamprivate* d;
00285 };
00286
00292 inline odbgstream& endl( odbgstream &s) { s << "\n"; return s; }
00298 inline odbgstream& flush( odbgstream &s) { s.flush(); return s; }
00299
00300 odbgstream &perror( odbgstream &s);
00301
00307 class ondbgstream {
00308 public:
00310 ondbgstream() {}
00311 ~ondbgstream() {}
00316 ondbgstream &operator<<(short int ) { return *this; }
00321 ondbgstream &operator<<(unsigned short int ) { return *this; }
00326 ondbgstream &operator<<(char ) { return *this; }
00331 ondbgstream &operator<<(unsigned char ) { return *this; }
00336 ondbgstream &operator<<(int ) { return *this; }
00341 ondbgstream &operator<<(unsigned int ) { return *this; }
00345 void flush() {}
00350 ondbgstream &operator<<(const QString& ) { return *this; }
00355 ondbgstream &operator<<(const QCString& ) { return *this; }
00360 ondbgstream &operator<<(const char *) { return *this; }
00365 ondbgstream& operator<<(const void *) { return *this; }
00370 ondbgstream& operator<<(void *) { return *this; }
00375 ondbgstream& operator<<(double) { return *this; }
00380 ondbgstream& operator<<(long) { return *this; }
00385 ondbgstream& operator<<(unsigned long) { return *this; }
00390 ondbgstream& operator << (QWidget*) { return *this; }
00395 ondbgstream &form(const char *, ...) { return *this; }
00396
00397 ondbgstream& operator<<( const QDateTime& ) { return *this; }
00398 ondbgstream& operator<<( const QDate& ) { return *this; }
00399 ondbgstream& operator<<( const QTime& ) { return *this; }
00400 ondbgstream& operator<<( const QPoint & ) { return *this; }
00401 ondbgstream& operator<<( const QSize & ) { return *this; }
00402 ondbgstream& operator<<( const QRect & ) { return *this; }
00403 ondbgstream& operator<<( const QRegion & ) { return *this; }
00404 ondbgstream& operator<<( const QStringList & ) { return *this; }
00405 ondbgstream& operator<<( const QColor & ) { return *this; }
00406 ondbgstream& operator<<( const QBrush & ) { return *this; }
00407
00408 private:
00409 class Private;
00410 Private *d;
00411 };
00412
00413
00414
00415
00416
00422 inline ondbgstream& endl( ondbgstream & s) { return s; }
00428 inline ondbgstream& flush( ondbgstream & s) { return s; }
00429 inline ondbgstream& perror( ondbgstream & s) { return s; }
00430
00436 odbgstream odDebug(int area = 0);
00437 odbgstream odDebug(bool cond, int area = 0);
00443 QString odBacktrace(int levels = -1);
00449 inline ondbgstream ondDebug(int = 0) { return ondbgstream(); }
00450 inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); }
00451 inline QString ondBacktrace() { return QString::null; }
00452 inline QString ondBacktrace(int) { return QString::null; }
00453
00459 odbgstream odWarning(int area = 0);
00460 odbgstream odWarning(bool cond, int area = 0);
00466 odbgstream odError(int area = 0);
00467 odbgstream odError(bool cond, int area = 0);
00473 odbgstream odFatal(int area = 0);
00474 odbgstream odFatal(bool cond, int area = 0);
00475
00480 void odClearDebugConfig();
00481
00482 #ifdef OPIE_NO_DEBUG
00483 #define odDebug ondDebug
00484 #define odBacktrace ondBacktrace
00485 #endif
00486
00487 }
00488 }
00489
00490 #endif
00491