summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-06-22 10:36:11 (UTC)
committer mickeyl <mickeyl>2004-06-22 10:36:11 (UTC)
commit9cff98cb70d8e3a69cefe718bf02720134c10bca (patch) (unidiff)
tree750f086afefc20e05b5860bf3065697cb75f98ab
parent526031c34fff4e789b05fddbd7effe83ef057361 (diff)
downloadopie-9cff98cb70d8e3a69cefe718bf02720134c10bca.zip
opie-9cff98cb70d8e3a69cefe718bf02720134c10bca.tar.gz
opie-9cff98cb70d8e3a69cefe718bf02720134c10bca.tar.bz2
introduce numeric constants for the odebug output destinations
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/odebug.cpp12
-rw-r--r--libopie2/opiecore/odebug.h9
2 files changed, 14 insertions, 7 deletions
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index 3bffdd0..d8dfe26 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -1,645 +1,645 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) 3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
4 (C) 2002 Holger Freyther (freyther@kde.org) 4 (C) 2002 Holger Freyther (freyther@kde.org)
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo 32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo
33// functions inlined to noops (which would then conflict with their definition here). 33// functions inlined to noops (which would then conflict with their definition here).
34 34
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37#ifdef OPIE_NO_DEBUG 37#ifdef OPIE_NO_DEBUG
38#undef odDebug 38#undef odDebug
39#undef odBacktrace 39#undef odBacktrace
40#endif 40#endif
41 41
42/* OPIE */ 42/* OPIE */
43 43
44#include <opie2/oapplication.h> 44#include <opie2/oapplication.h>
45#include <opie2/oglobalsettings.h> 45#include <opie2/oglobalsettings.h>
46#include <opie2/oconfig.h> 46#include <opie2/oconfig.h>
47 47
48/* QT */ 48/* QT */
49 49
50#include <qfile.h> 50#include <qfile.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qsocketdevice.h> 52#include <qsocketdevice.h>
53 53
54/* UNIX */ 54/* UNIX */
55 55
56#include <stdlib.h> // abort 56#include <stdlib.h> // abort
57#include <unistd.h> // getpid 57#include <unistd.h> // getpid
58#include <stdarg.h> // vararg stuff 58#include <stdarg.h> // vararg stuff
59#include <ctype.h> // isprint 59#include <ctype.h> // isprint
60#include <syslog.h> 60#include <syslog.h>
61#include <errno.h> 61#include <errno.h>
62#include <string.h> 62#include <string.h>
63 63
64#ifndef OPIE_NO_BACKTRACE 64#ifndef OPIE_NO_BACKTRACE
65#include <execinfo.h> 65#include <execinfo.h>
66#endif 66#endif
67 67
68namespace Opie { 68namespace Opie {
69namespace Core { 69namespace Core {
70namespace Internal { 70namespace Internal {
71/*====================================================================================== 71/*======================================================================================
72 * debug levels 72 * debug levels
73 *======================================================================================*/ 73 *======================================================================================*/
74 74
75enum DebugLevels { 75enum DebugLevels {
76 ODEBUG_INFO = 0, 76 ODEBUG_INFO = 0,
77 ODEBUG_WARN = 1, 77 ODEBUG_WARN = 1,
78 ODEBUG_ERROR = 2, 78 ODEBUG_ERROR = 2,
79 ODEBUG_FATAL = 3 79 ODEBUG_FATAL = 3
80}; 80};
81 81
82/*====================================================================================== 82/*======================================================================================
83 * oDebug private data 83 * oDebug private data
84 *======================================================================================*/ 84 *======================================================================================*/
85 85
86/*====================================================================================== 86/*======================================================================================
87 * the main debug function 87 * the main debug function
88 *======================================================================================*/ 88 *======================================================================================*/
89 89
90 90
91 91
92struct DebugBackend { 92struct DebugBackend {
93 DebugBackend() : m_opened( false ), m_file( 0 ) ,m_port( -1 ),m_sock( 0 ) { 93 DebugBackend() : m_opened( false ), m_file( 0 ) ,m_port( -1 ),m_sock( 0 ) {
94 m_outp = OGlobalSettings::debugMode(); 94 m_outp = OGlobalSettings::debugMode();
95 } 95 }
96 ~DebugBackend() { 96 ~DebugBackend() {
97 delete m_file; 97 delete m_file;
98 delete m_sock; 98 delete m_sock;
99 } 99 }
100 void debug( unsigned short level, unsigned int, const QString& data ); 100 void debug( unsigned short level, unsigned int, const QString& data );
101 101
102private: 102private:
103 void debugFile( const QString&, const QString& data ); 103 void debugFile( const QString&, const QString& data );
104 void debugMsgB( const QString&, const QString& data ); 104 void debugMsgB( const QString&, const QString& data );
105 void debugShel( const QString&, const QString& data ); 105 void debugShel( const QString&, const QString& data );
106 void debugSysl( int, const QString& ); 106 void debugSysl( int, const QString& );
107 void debugSock( const QString&, const QString& data ); 107 void debugSock( const QString&, const QString& data );
108 QCString line( const QString&, const QString& data ); 108 QCString line( const QString&, const QString& data );
109 bool m_opened : 1; 109 bool m_opened : 1;
110 QFile *m_file; 110 QFile *m_file;
111 QHostAddress m_addr; 111 QHostAddress m_addr;
112 int m_port; 112 int m_port;
113 QSocketDevice *m_sock; 113 QSocketDevice *m_sock;
114 short m_outp; 114 short m_outp;
115}; 115};
116 116
117void DebugBackend::debug(unsigned short level, unsigned int, const QString& data) { 117void DebugBackend::debug(unsigned short level, unsigned int, const QString& data) {
118 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); 118 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
119 119
120 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an 120 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
121 // ML: example use. I think it's not necessary to implement such a strategy here. 121 // ML: example use. I think it's not necessary to implement such a strategy here.
122 // ML: Comments? 122 // ML: Comments?
123 123
124 int priority = 0; 124 int priority = 0;
125 QString caption; 125 QString caption;
126 QString lev; 126 QString lev;
127 switch( level ) 127 switch( level )
128 { 128 {
129 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; 129 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
130 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; 130 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
131 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; 131 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
132 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); 132 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
133 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; 133 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
134 } 134 }
135 135
136 if (!oApp && (m_outp == 1)) { 136 if (!oApp && (m_outp == 1)) {
137 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); 137 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
138 m_outp = 2; // need an application object to use MsgBox 138 m_outp = 2; // need an application object to use MsgBox
139 } 139 }
140 140
141 // gcc 2.9x is dumb and sucks... can you hear it? 141 // gcc 2.9x is dumb and sucks... can you hear it?
142 //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; 142 //QString areaName = (oApp) ? oApp->appName() : "<unknown>";
143 QString areaName; 143 QString areaName;
144 if ( oApp ) areaName = oApp->appName(); 144 if ( oApp ) areaName = oApp->appName();
145 else areaName = "<unknown>"; 145 else areaName = "<unknown>";
146 146
147 switch( m_outp ) { 147 switch( m_outp ) {
148 case -1: // ignore 148 case ODEBUG_IGNORE:
149 return; 149 return;
150 case 0: // File 150 case ODEBUG_FILE:
151 return debugFile( areaName, data ); 151 return debugFile( areaName, data );
152 case 1: // Message Box 152 case ODEBUG_MSGBOX:
153 return debugMsgB( areaName, data ); 153 return debugMsgB( areaName, data );
154 case 2: 154 case ODEBUG_STDERR:
155 return debugShel( areaName,data ); 155 return debugShel( areaName,data );
156 case 3: // syslog 156 case ODEBUG_SYSLOG:
157 return debugSysl( priority, data ); 157 return debugSysl( priority, data );
158 case 4: // socket 158 case ODEBUG_SOCKET:
159 return debugSock( areaName, data ); 159 return debugSock( areaName, data );
160 } 160 }
161} 161}
162 162
163inline void DebugBackend::debugFile(const QString& area, const QString& data) { 163inline void DebugBackend::debugFile(const QString& area, const QString& data) {
164 /* something went wrong with the file don't bother.. */ 164 /* something went wrong with the file don't bother.. */
165 if ( m_opened && !m_file ) 165 if ( m_opened && !m_file )
166 return; 166 return;
167 else if ( !m_opened ) { 167 else if ( !m_opened ) {
168 m_opened = true; 168 m_opened = true;
169 m_file = new QFile( OGlobalSettings::debugOutput() ); 169 m_file = new QFile( OGlobalSettings::debugOutput() );
170 if (!m_file->open( IO_WriteOnly | IO_Append ) ) { 170 if (!m_file->open( IO_WriteOnly | IO_Append ) ) {
171 delete m_file; m_file = 0; 171 delete m_file; m_file = 0;
172 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*)OGlobalSettings::debugOutput(), 172 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*)OGlobalSettings::debugOutput(),
173 strerror(errno) ); 173 strerror(errno) );
174 return; 174 return;
175 } 175 }
176 } 176 }
177 177
178 /* go to end of file */ 178 /* go to end of file */
179 m_file->at( m_file->size() ); 179 m_file->at( m_file->size() );
180 QCString li = line( area, data ); 180 QCString li = line( area, data );
181 m_file->writeBlock(li.data(), li.length() ); 181 m_file->writeBlock(li.data(), li.length() );
182} 182}
183 183
184void DebugBackend::debugMsgB( const QString& area, const QString& data ) { 184void DebugBackend::debugMsgB( const QString& area, const QString& data ) {
185 QMessageBox::warning( 0l, "("+area+")", data, ("Ok") ); 185 QMessageBox::warning( 0l, "("+area+")", data, ("Ok") );
186} 186}
187 187
188void DebugBackend::debugShel( const QString& are, const QString& data ) { 188void DebugBackend::debugShel( const QString& are, const QString& data ) {
189 FILE *output = stderr; 189 FILE *output = stderr;
190 fprintf( output, "%s: %s", are.local8Bit().data(), 190 fprintf( output, "%s: %s", are.local8Bit().data(),
191 data.local8Bit().data() ); 191 data.local8Bit().data() );
192} 192}
193 193
194void DebugBackend::debugSysl( int prio, const QString& data ) { 194void DebugBackend::debugSysl( int prio, const QString& data ) {
195 ::syslog( prio, "%s", data.local8Bit().data() ); 195 ::syslog( prio, "%s", data.local8Bit().data() );
196} 196}
197 197
198void DebugBackend::debugSock( const QString& are, const QString& data ) { 198void DebugBackend::debugSock( const QString& are, const QString& data ) {
199 if ( m_opened && !m_sock ) 199 if ( m_opened && !m_sock )
200 return; 200 return;
201 else if ( !m_opened ){ 201 else if ( !m_opened ){
202 m_opened = true; 202 m_opened = true;
203 QString destination = OGlobalSettings::debugOutput(); 203 QString destination = OGlobalSettings::debugOutput();
204 if ( destination && destination.find(":") != -1 ) { 204 if ( destination && destination.find(":") != -1 ) {
205 QString host = destination.left( destination.find(":") ); 205 QString host = destination.left( destination.find(":") );
206 m_port = destination.right( destination.length()-host.length()-1 ).toInt(); 206 m_port = destination.right( destination.length()-host.length()-1 ).toInt();
207 m_addr.setAddress( host ); 207 m_addr.setAddress( host );
208 m_sock = new QSocketDevice( QSocketDevice::Datagram ); 208 m_sock = new QSocketDevice( QSocketDevice::Datagram );
209 }else{ 209 }else{
210 m_sock = 0; 210 m_sock = 0;
211 return; 211 return;
212 } 212 }
213 } 213 }
214 214
215 QCString li = line( are, data ); 215 QCString li = line( are, data );
216 int result = m_sock->writeBlock(li.data(), li.length(), m_addr, m_port ); 216 int result = m_sock->writeBlock(li.data(), li.length(), m_addr, m_port );
217 if ( result == -1 ) { 217 if ( result == -1 ) {
218 qDebug( "ODebug: can't send to address '"+ m_addr.toString() +":%d' (%s)", 218 qDebug( "ODebug: can't send to address '"+ m_addr.toString() +":%d' (%s)",
219 m_port, strerror(errno) ); 219 m_port, strerror(errno) );
220 } 220 }
221} 221}
222 222
223QCString DebugBackend::line( const QString& area, const QString& data ) { 223QCString DebugBackend::line( const QString& area, const QString& data ) {
224 QString str = area +":"+data; 224 QString str = area +":"+data;
225 return str.local8Bit(); 225 return str.local8Bit();
226} 226}
227 227
228static DebugBackend *backEnd = 0; 228static DebugBackend *backEnd = 0;
229} 229}
230static void clean_up_routine() { 230static void clean_up_routine() {
231 qWarning( "Clean up Debug" ); 231 qWarning( "Clean up Debug" );
232 delete Internal::backEnd; 232 delete Internal::backEnd;
233 Internal::backEnd = 0; 233 Internal::backEnd = 0;
234} 234}
235/*====================================================================================== 235/*======================================================================================
236 * odbgstream 236 * odbgstream
237 *======================================================================================*/ 237 *======================================================================================*/
238 238
239odbgstream& perror( odbgstream &s) 239odbgstream& perror( odbgstream &s)
240{ 240{
241 return s << QString::fromLocal8Bit(strerror(errno)); 241 return s << QString::fromLocal8Bit(strerror(errno));
242} 242}
243 243
244odbgstream odDebug(int area) 244odbgstream odDebug(int area)
245{ 245{
246 return odbgstream(area, Internal::ODEBUG_INFO); 246 return odbgstream(area, Internal::ODEBUG_INFO);
247} 247}
248odbgstream odDebug(bool cond, int area) 248odbgstream odDebug(bool cond, int area)
249{ 249{
250 if (cond) return odbgstream(area, Internal::ODEBUG_INFO); 250 if (cond) return odbgstream(area, Internal::ODEBUG_INFO);
251 else return odbgstream(0, 0, false); 251 else return odbgstream(0, 0, false);
252} 252}
253 253
254odbgstream odError(int area) 254odbgstream odError(int area)
255{ 255{
256 return odbgstream("ERROR: ", area, Internal::ODEBUG_ERROR); 256 return odbgstream("ERROR: ", area, Internal::ODEBUG_ERROR);
257} 257}
258 258
259odbgstream odError(bool cond, int area) 259odbgstream odError(bool cond, int area)
260{ 260{
261 if (cond) return odbgstream("ERROR: ", area, Internal::ODEBUG_ERROR); else return odbgstream(0,0,false); 261 if (cond) return odbgstream("ERROR: ", area, Internal::ODEBUG_ERROR); else return odbgstream(0,0,false);
262} 262}
263 263
264odbgstream odWarning(int area) 264odbgstream odWarning(int area)
265{ 265{
266 return odbgstream("WARNING: ", area, Internal::ODEBUG_WARN); 266 return odbgstream("WARNING: ", area, Internal::ODEBUG_WARN);
267} 267}
268 268
269odbgstream odWarning(bool cond, int area) 269odbgstream odWarning(bool cond, int area)
270{ 270{
271 if (cond) return odbgstream("WARNING: ", area, Internal::ODEBUG_WARN); else return odbgstream(0,0,false); 271 if (cond) return odbgstream("WARNING: ", area, Internal::ODEBUG_WARN); else return odbgstream(0,0,false);
272} 272}
273 273
274odbgstream odFatal(int area) 274odbgstream odFatal(int area)
275{ 275{
276 return odbgstream("FATAL: ", area, Internal::ODEBUG_FATAL); 276 return odbgstream("FATAL: ", area, Internal::ODEBUG_FATAL);
277} 277}
278 278
279odbgstream odFatal(bool cond, int area) 279odbgstream odFatal(bool cond, int area)
280{ 280{
281 if (cond) return odbgstream("FATAL: ", area, Internal::ODEBUG_FATAL); else return odbgstream(0,0,false); 281 if (cond) return odbgstream("FATAL: ", area, Internal::ODEBUG_FATAL); else return odbgstream(0,0,false);
282} 282}
283 283
284odbgstream::odbgstream(unsigned int _area, unsigned int _level, bool _print) 284odbgstream::odbgstream(unsigned int _area, unsigned int _level, bool _print)
285 :area(_area), level(_level), print(_print) 285 :area(_area), level(_level), print(_print)
286{ 286{
287} 287}
288 288
289 289
290odbgstream::odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print) 290odbgstream::odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print)
291 :output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) 291 :output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print)
292{ 292{
293} 293}
294 294
295 295
296odbgstream::odbgstream(odbgstream &str) 296odbgstream::odbgstream(odbgstream &str)
297 :output(str.output), area(str.area), level(str.level), print(str.print) 297 :output(str.output), area(str.area), level(str.level), print(str.print)
298{ 298{
299 str.output.truncate(0); 299 str.output.truncate(0);
300} 300}
301 301
302 302
303odbgstream::odbgstream(const odbgstream &str) 303odbgstream::odbgstream(const odbgstream &str)
304 :output(str.output), area(str.area), level(str.level), print(str.print) 304 :output(str.output), area(str.area), level(str.level), print(str.print)
305{ 305{
306} 306}
307 307
308odbgstream& odbgstream::operator<<(bool i) 308odbgstream& odbgstream::operator<<(bool i)
309{ 309{
310 if (!print) return *this; 310 if (!print) return *this;
311 output += QString::fromLatin1(i ? "true" : "false"); 311 output += QString::fromLatin1(i ? "true" : "false");
312 return *this; 312 return *this;
313} 313}
314 314
315 315
316odbgstream& odbgstream::operator<<(short i) 316odbgstream& odbgstream::operator<<(short i)
317{ 317{
318 if (!print) return *this; 318 if (!print) return *this;
319 QString tmp; tmp.setNum(i); output += tmp; 319 QString tmp; tmp.setNum(i); output += tmp;
320 return *this; 320 return *this;
321} 321}
322 322
323 323
324odbgstream& odbgstream::operator<<(unsigned short i) 324odbgstream& odbgstream::operator<<(unsigned short i)
325{ 325{
326 if (!print) return *this; 326 if (!print) return *this;
327 QString tmp; tmp.setNum(i); output += tmp; 327 QString tmp; tmp.setNum(i); output += tmp;
328 return *this; 328 return *this;
329} 329}
330 330
331 331
332odbgstream& odbgstream::operator<<(unsigned char i) 332odbgstream& odbgstream::operator<<(unsigned char i)
333{ 333{
334 return operator<<( static_cast<char>( i ) ); 334 return operator<<( static_cast<char>( i ) );
335} 335}
336 336
337 337
338odbgstream& odbgstream::operator<<(int i) 338odbgstream& odbgstream::operator<<(int i)
339{ 339{
340 if (!print) return *this; 340 if (!print) return *this;
341 QString tmp; tmp.setNum(i); output += tmp; 341 QString tmp; tmp.setNum(i); output += tmp;
342 return *this; 342 return *this;
343} 343}
344 344
345 345
346odbgstream& odbgstream::operator<<(unsigned int i) 346odbgstream& odbgstream::operator<<(unsigned int i)
347{ 347{
348 if (!print) return *this; 348 if (!print) return *this;
349 QString tmp; tmp.setNum(i); output += tmp; 349 QString tmp; tmp.setNum(i); output += tmp;
350 return *this; 350 return *this;
351} 351}
352 352
353 353
354odbgstream& odbgstream::operator<<(long i) 354odbgstream& odbgstream::operator<<(long i)
355{ 355{
356 if (!print) return *this; 356 if (!print) return *this;
357 QString tmp; tmp.setNum(i); output += tmp; 357 QString tmp; tmp.setNum(i); output += tmp;
358 return *this; 358 return *this;
359} 359}
360 360
361 361
362odbgstream& odbgstream::operator<<(unsigned long i) 362odbgstream& odbgstream::operator<<(unsigned long i)
363{ 363{
364 if (!print) return *this; 364 if (!print) return *this;
365 QString tmp; tmp.setNum(i); output += tmp; 365 QString tmp; tmp.setNum(i); output += tmp;
366 return *this; 366 return *this;
367} 367}
368 368
369 369
370odbgstream& odbgstream::operator<<(const QString& string) 370odbgstream& odbgstream::operator<<(const QString& string)
371{ 371{
372 if (!print) return *this; 372 if (!print) return *this;
373 output += string; 373 output += string;
374 if (output.at(output.length() -1 ) == '\n') 374 if (output.at(output.length() -1 ) == '\n')
375 flush(); 375 flush();
376 return *this; 376 return *this;
377} 377}
378 378
379 379
380odbgstream& odbgstream::operator<<(const char *string) 380odbgstream& odbgstream::operator<<(const char *string)
381{ 381{
382 if (!print) return *this; 382 if (!print) return *this;
383 output += QString::fromUtf8(string); 383 output += QString::fromUtf8(string);
384 if (output.at(output.length() - 1) == '\n') 384 if (output.at(output.length() - 1) == '\n')
385 flush(); 385 flush();
386 return *this; 386 return *this;
387} 387}
388 388
389 389
390odbgstream& odbgstream::operator<<(const QCString& string) 390odbgstream& odbgstream::operator<<(const QCString& string)
391{ 391{
392 *this << string.data(); 392 *this << string.data();
393 return *this; 393 return *this;
394} 394}
395 395
396 396
397odbgstream& odbgstream::operator<<(const void * p) 397odbgstream& odbgstream::operator<<(const void * p)
398{ 398{
399 form("%p", p); 399 form("%p", p);
400 return *this; 400 return *this;
401} 401}
402 402
403odbgstream& odbgstream::operator<<(double d) 403odbgstream& odbgstream::operator<<(double d)
404{ 404{
405 QString tmp; tmp.setNum(d); output += tmp; 405 QString tmp; tmp.setNum(d); output += tmp;
406 return *this; 406 return *this;
407} 407}
408 408
409/* 409/*
410odbgstream::odbgstream &form(const char *format, ...) 410odbgstream::odbgstream &form(const char *format, ...)
411#ifdef __GNUC__ 411#ifdef __GNUC__
412 __attribute__ ( ( format ( printf, 2, 3 ) ) ) 412 __attribute__ ( ( format ( printf, 2, 3 ) ) )
413#endif 413#endif
414 ; 414 ;
415*/ 415*/
416 416
417void odbgstream::flush() 417void odbgstream::flush()
418{ 418{
419 if ( output.isEmpty() || !print ) 419 if ( output.isEmpty() || !print )
420 { 420 {
421 return; 421 return;
422 } 422 }
423 else 423 else
424 { 424 {
425 if ( !Internal::backEnd ) { 425 if ( !Internal::backEnd ) {
426 Internal::backEnd = new Internal::DebugBackend; 426 Internal::backEnd = new Internal::DebugBackend;
427 qAddPostRoutine( clean_up_routine ); 427 qAddPostRoutine( clean_up_routine );
428 } 428 }
429 Internal::backEnd->debug( level, area, output ); 429 Internal::backEnd->debug( level, area, output );
430 output = QString::null; 430 output = QString::null;
431 } 431 }
432} 432}
433 433
434odbgstream& odbgstream::form(const char *format, ...) 434odbgstream& odbgstream::form(const char *format, ...)
435{ 435{
436 char buf[4096]; 436 char buf[4096];
437 va_list arguments; 437 va_list arguments;
438 va_start( arguments, format ); 438 va_start( arguments, format );
439 buf[sizeof(buf)-1] = '\0'; 439 buf[sizeof(buf)-1] = '\0';
440 vsnprintf( buf, sizeof(buf)-1, format, arguments ); 440 vsnprintf( buf, sizeof(buf)-1, format, arguments );
441 va_end(arguments); 441 va_end(arguments);
442 *this << buf; 442 *this << buf;
443 return *this; 443 return *this;
444} 444}
445 445
446odbgstream::~odbgstream() 446odbgstream::~odbgstream()
447{ 447{
448 if (!output.isEmpty()) 448 if (!output.isEmpty())
449 { 449 {
450 fprintf(stderr, "ASSERT: debug output not ended with \\n\n"); 450 fprintf(stderr, "ASSERT: debug output not ended with \\n\n");
451 *this << "\n"; 451 *this << "\n";
452 } 452 }
453} 453}
454 454
455odbgstream& odbgstream::operator<<(char ch) 455odbgstream& odbgstream::operator<<(char ch)
456{ 456{
457 if (!print) return *this; 457 if (!print) return *this;
458 if (!isprint(ch)) 458 if (!isprint(ch))
459 { 459 {
460 output += "\\x" + QString::number( static_cast<uint>( ch ) + 0x100, 16 ).right(2); 460 output += "\\x" + QString::number( static_cast<uint>( ch ) + 0x100, 16 ).right(2);
461 } 461 }
462 else 462 else
463 { 463 {
464 output += ch; 464 output += ch;
465 if (ch == '\n') flush(); 465 if (ch == '\n') flush();
466 } 466 }
467 return *this; 467 return *this;
468} 468}
469 469
470odbgstream& odbgstream::operator<<( QWidget* widget ) 470odbgstream& odbgstream::operator<<( QWidget* widget )
471{ 471{
472 QString string, temp; 472 QString string, temp;
473 // ----- 473 // -----
474 if(widget==0) 474 if(widget==0)
475 { 475 {
476 string=(QString)"[Null pointer]"; 476 string=(QString)"[Null pointer]";
477 } else 477 } else
478 { 478 {
479 temp.setNum((ulong)widget, 16); 479 temp.setNum((ulong)widget, 16);
480 string=(QString)"["+widget->className()+" pointer " + "(0x" + temp + ")"; 480 string=(QString)"["+widget->className()+" pointer " + "(0x" + temp + ")";
481 if(widget->name(0)==0) 481 if(widget->name(0)==0)
482 { 482 {
483 string += " to unnamed widget, "; 483 string += " to unnamed widget, ";
484 } else 484 } else
485 { 485 {
486 string += (QString)" to widget " + widget->name() + ", "; 486 string += (QString)" to widget " + widget->name() + ", ";
487 } 487 }
488 string += "geometry=" 488 string += "geometry="
489 + QString().setNum(widget->width()) 489 + QString().setNum(widget->width())
490 + "x"+QString().setNum(widget->height()) 490 + "x"+QString().setNum(widget->height())
491 + "+"+QString().setNum(widget->x()) 491 + "+"+QString().setNum(widget->x())
492 + "+"+QString().setNum(widget->y()) 492 + "+"+QString().setNum(widget->y())
493 + "]"; 493 + "]";
494 } 494 }
495 if (!print) return *this; 495 if (!print) return *this;
496 496
497 output += string; 497 output += string;
498 if (output.at(output.length()-1) == '\n') 498 if (output.at(output.length()-1) == '\n')
499 { 499 {
500 flush(); 500 flush();
501 } 501 }
502 return *this; 502 return *this;
503} 503}
504 504
505/* 505/*
506 * either use 'output' directly and do the flush if needed 506 * either use 'output' directly and do the flush if needed
507 * or use the QString operator which calls the char* operator 507 * or use the QString operator which calls the char* operator
508 * 508 *
509 */ 509 */
510odbgstream& odbgstream::operator<<( const QDateTime& time) 510odbgstream& odbgstream::operator<<( const QDateTime& time)
511{ 511{
512 *this << time.toString(); 512 *this << time.toString();
513 return *this; 513 return *this;
514} 514}
515 515
516 516
517odbgstream& odbgstream::operator<<( const QDate& date) 517odbgstream& odbgstream::operator<<( const QDate& date)
518{ 518{
519 *this << date.toString(); 519 *this << date.toString();
520 520
521 return *this; 521 return *this;
522} 522}
523 523
524 524
525odbgstream& odbgstream::operator<<( const QTime& time ) 525odbgstream& odbgstream::operator<<( const QTime& time )
526{ 526{
527 *this << time.toString(); 527 *this << time.toString();
528 return *this; 528 return *this;
529} 529}
530 530
531 531
532odbgstream& odbgstream::operator<<( const QPoint& p ) 532odbgstream& odbgstream::operator<<( const QPoint& p )
533{ 533{
534 *this << "(" << p.x() << ", " << p.y() << ")"; 534 *this << "(" << p.x() << ", " << p.y() << ")";
535 return *this; 535 return *this;
536} 536}
537 537
538 538
539odbgstream& odbgstream::operator<<( const QSize& s ) 539odbgstream& odbgstream::operator<<( const QSize& s )
540{ 540{
541 *this << "[" << s.width() << "x" << s.height() << "]"; 541 *this << "[" << s.width() << "x" << s.height() << "]";
542 return *this; 542 return *this;
543} 543}
544 544
545 545
546odbgstream& odbgstream::operator<<( const QRect& r ) 546odbgstream& odbgstream::operator<<( const QRect& r )
547{ 547{
548 *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]"; 548 *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]";
549 return *this; 549 return *this;
550} 550}
551 551
552 552
553odbgstream& odbgstream::operator<<( const QRegion& reg ) 553odbgstream& odbgstream::operator<<( const QRegion& reg )
554{ 554{
555 *this << "[ "; 555 *this << "[ ";
556 QArray<QRect>rs=reg.rects(); 556 QArray<QRect>rs=reg.rects();
557 for (uint i=0;i<rs.size();++i) 557 for (uint i=0;i<rs.size();++i)
558 *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ; 558 *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ;
559 *this <<"]"; 559 *this <<"]";
560 return *this; 560 return *this;
561} 561}
562 562
563 563
564odbgstream& odbgstream::operator<<( const QStringList& l ) 564odbgstream& odbgstream::operator<<( const QStringList& l )
565{ 565{
566 *this << "("; 566 *this << "(";
567 *this << l.join(","); 567 *this << l.join(",");
568 *this << ")"; 568 *this << ")";
569 569
570 return *this; 570 return *this;
571} 571}
572 572
573 573
574odbgstream& odbgstream::operator<<( const QColor& c ) 574odbgstream& odbgstream::operator<<( const QColor& c )
575{ 575{
576 if ( c.isValid() ) 576 if ( c.isValid() )
577 *this << c.name(); 577 *this << c.name();
578 else 578 else
579 *this << "(invalid/default)"; 579 *this << "(invalid/default)";
580 return *this; 580 return *this;
581} 581}
582 582
583 583
584odbgstream& odbgstream::operator<<( const QBrush& b) 584odbgstream& odbgstream::operator<<( const QBrush& b)
585{ 585{
586 static const char* const s_brushStyles[] = { 586 static const char* const s_brushStyles[] = {
587 "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern", 587 "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern",
588 "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern", 588 "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern",
589 "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern", 589 "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern",
590 "DiagCrossPattern" }; 590 "DiagCrossPattern" };
591 591
592 *this <<"[ style: "; 592 *this <<"[ style: ";
593 *this <<s_brushStyles[ b.style() ]; 593 *this <<s_brushStyles[ b.style() ];
594 *this <<" color: "; 594 *this <<" color: ";
595 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes) 595 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes)
596 if ( b.color().isValid() ) 596 if ( b.color().isValid() )
597 *this <<b.color().name() ; 597 *this <<b.color().name() ;
598 else 598 else
599 *this <<"(invalid/default)"; 599 *this <<"(invalid/default)";
600 if ( b.pixmap() ) 600 if ( b.pixmap() )
601 *this <<" has a pixmap"; 601 *this <<" has a pixmap";
602 *this <<" ]"; 602 *this <<" ]";
603 return *this; 603 return *this;
604} 604}
605 605
606 606
607 607
608QString odBacktrace( int levels ) 608QString odBacktrace( int levels )
609{ 609{
610 QString s; 610 QString s;
611#ifndef OPIE_NO_BACKTRACE 611#ifndef OPIE_NO_BACKTRACE
612 void* trace[256]; 612 void* trace[256];
613 int n = backtrace(trace, 256); 613 int n = backtrace(trace, 256);
614 char** strings = backtrace_symbols (trace, n); 614 char** strings = backtrace_symbols (trace, n);
615 615
616 if ( levels != -1 ) 616 if ( levels != -1 )
617 n = QMIN( n, levels ); 617 n = QMIN( n, levels );
618 s = "[\n"; 618 s = "[\n";
619 619
620 for (int i = 0; i < n; ++i) 620 for (int i = 0; i < n; ++i)
621 s += QString::number(i) + 621 s += QString::number(i) +
622 QString::fromLatin1(": ") + 622 QString::fromLatin1(": ") +
623 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n"); 623 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n");
624 s += "]\n"; 624 s += "]\n";
625 free (strings); 625 free (strings);
626#endif 626#endif
627 return s; 627 return s;
628} 628}
629 629
630void odClearDebugConfig() 630void odClearDebugConfig()
631{ 631{
632 /* 632 /*
633 delete oDebug_data->config; 633 delete oDebug_data->config;
634 oDebug_data->config = 0; 634 oDebug_data->config = 0;
635 */ 635 */
636} 636}
637 637
638 638
639#ifdef OPIE_NO_DEBUG 639#ifdef OPIE_NO_DEBUG
640#define odDebug ondDebug 640#define odDebug ondDebug
641#define odBacktrace ondBacktrace 641#define odBacktrace ondBacktrace
642#endif 642#endif
643 643
644} 644}
645} 645}
diff --git a/libopie2/opiecore/odebug.h b/libopie2/opiecore/odebug.h
index 3851a41..21a6c26 100644
--- a/libopie2/opiecore/odebug.h
+++ b/libopie2/opiecore/odebug.h
@@ -1,484 +1,491 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) 3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
4 Inspired by the KDE debug classes, which are 4 Inspired by the KDE debug classes, which are
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
6 (C) 2002 Holger Freyther (freyther@kde.org) 6 (C) 2002 Holger Freyther (freyther@kde.org)
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31*/ 31*/
32 32
33#ifndef ODEBUG_H 33#ifndef ODEBUG_H
34#define ODEBUG_H 34#define ODEBUG_H
35 35
36#include <qstring.h> 36#include <qstring.h>
37 37
38class QWidget; 38class QWidget;
39class QDateTime; 39class QDateTime;
40class QDate; 40class QDate;
41class QTime; 41class QTime;
42class QPoint; 42class QPoint;
43class QSize; 43class QSize;
44class QRect; 44class QRect;
45class QRegion; 45class QRegion;
46class QStringList; 46class QStringList;
47class QColor; 47class QColor;
48class QBrush; 48class QBrush;
49 49
50namespace Opie { 50namespace Opie {
51namespace Core { 51namespace Core {
52 52
53class odbgstream; 53class odbgstream;
54class ondbgstream; 54class ondbgstream;
55 55
56#ifdef __GNUC__ 56#ifdef __GNUC__
57#define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] " 57#define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] "
58#else 58#else
59#define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] " 59#define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
60#endif 60#endif
61 61
62#define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] " 62#define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
63 63
64#define owarn Opie::Core::odWarning() 64#define owarn Opie::Core::odWarning()
65#define oerr Opie::Core::odError() 65#define oerr Opie::Core::odError()
66#define odebug Opie::Core::odDebug() 66#define odebug Opie::Core::odDebug()
67#define ofatal Opie::Core::odFatal() 67#define ofatal Opie::Core::odFatal()
68#define oendl "\n" 68#define oendl "\n"
69 69
70const int ODEBUG_IGNORE = -1;
71const int ODEBUG_FILE = 0;
72const int ODEBUG_MSGBOX = 1;
73const int ODEBUG_STDERR = 2;
74const int ODEBUG_SYSLOG = 3;
75const int ODEBUG_SOCKET = 4;
76
70class odbgstreamprivate; 77class odbgstreamprivate;
71/** 78/**
72 * odbgstream is a text stream that allows you to print debug messages. 79 * odbgstream is a text stream that allows you to print debug messages.
73 * Using the overloaded "<<" operator you can send messages. Usually 80 * Using the overloaded "<<" operator you can send messages. Usually
74 * you do not create the odbgstream yourself, but use @ref odDebug() (odebug) 81 * you do not create the odbgstream yourself, but use @ref odDebug() (odebug)
75 * @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one. 82 * @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one.
76 * 83 *
77 * Example: 84 * Example:
78 * <pre> 85 * <pre>
79 * int i = 5; 86 * int i = 5;
80 * odebug << "The value of i is " << i << oendl; 87 * odebug << "The value of i is " << i << oendl;
81 * </pre> 88 * </pre>
82 * @see odbgstream 89 * @see odbgstream
83 */ 90 */
84 91
85/*====================================================================================== 92/*======================================================================================
86 * odbgstream 93 * odbgstream
87 *======================================================================================*/ 94 *======================================================================================*/
88 95
89class odbgstream 96class odbgstream
90{ 97{
91 public: 98 public:
92 /** 99 /**
93 * @internal 100 * @internal
94 */ 101 */
95 odbgstream(unsigned int _area, unsigned int _level, bool _print = true); 102 odbgstream(unsigned int _area, unsigned int _level, bool _print = true);
96 odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true); 103 odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true);
97 odbgstream(odbgstream &str); 104 odbgstream(odbgstream &str);
98 odbgstream(const odbgstream &str); 105 odbgstream(const odbgstream &str);
99 virtual ~odbgstream(); 106 virtual ~odbgstream();
100 107
101 /** 108 /**
102 * Prints the given value. 109 * Prints the given value.
103 * @param i the boolean to print (as "true" or "false") 110 * @param i the boolean to print (as "true" or "false")
104 * @return this stream 111 * @return this stream
105 */ 112 */
106 odbgstream &operator<<(bool i); 113 odbgstream &operator<<(bool i);
107 /** 114 /**
108 * Prints the given value. 115 * Prints the given value.
109 * @param i the short to print 116 * @param i the short to print
110 * @return this stream 117 * @return this stream
111 */ 118 */
112 odbgstream &operator<<(short i); 119 odbgstream &operator<<(short i);
113 /** 120 /**
114 * Prints the given value. 121 * Prints the given value.
115 * @param i the unsigned short to print 122 * @param i the unsigned short to print
116 * @return this stream 123 * @return this stream
117 */ 124 */
118 odbgstream &operator<<(unsigned short i); 125 odbgstream &operator<<(unsigned short i);
119 /** 126 /**
120 * Prints the given value. 127 * Prints the given value.
121 * @param i the char to print 128 * @param i the char to print
122 * @return this stream 129 * @return this stream
123 */ 130 */
124 odbgstream &operator<<(char i); 131 odbgstream &operator<<(char i);
125 /** 132 /**
126 * Prints the given value. 133 * Prints the given value.
127 * @param i the unsigned char to print 134 * @param i the unsigned char to print
128 * @return this stream 135 * @return this stream
129 */ 136 */
130 odbgstream &operator<<(unsigned char i); 137 odbgstream &operator<<(unsigned char i);
131 /** 138 /**
132 * Prints the given value. 139 * Prints the given value.
133 * @param i the int to print 140 * @param i the int to print
134 * @return this stream 141 * @return this stream
135 */ 142 */
136 odbgstream &operator<<(int i); 143 odbgstream &operator<<(int i);
137 /** 144 /**
138 * Prints the given value. 145 * Prints the given value.
139 * @param i the unsigned int to print 146 * @param i the unsigned int to print
140 * @return this stream 147 * @return this stream
141 */ 148 */
142 odbgstream &operator<<(unsigned int i); 149 odbgstream &operator<<(unsigned int i);
143 /** 150 /**
144 * Prints the given value. 151 * Prints the given value.
145 * @param i the long to print 152 * @param i the long to print
146 * @return this stream 153 * @return this stream
147 */ 154 */
148 odbgstream &operator<<(long i); 155 odbgstream &operator<<(long i);
149 /** 156 /**
150 * Prints the given value. 157 * Prints the given value.
151 * @param i the unsigned long to print 158 * @param i the unsigned long to print
152 * @return this stream 159 * @return this stream
153 */ 160 */
154 odbgstream &operator<<(unsigned long i); 161 odbgstream &operator<<(unsigned long i);
155 /** 162 /**
156 * Flushes the output. 163 * Flushes the output.
157 */ 164 */
158 virtual void flush(); 165 virtual void flush();
159 /** 166 /**
160 * Prints the given value. 167 * Prints the given value.
161 * @param string the string to print 168 * @param string the string to print
162 * @return this stream 169 * @return this stream
163 */ 170 */
164 odbgstream &operator<<(const QString& string); 171 odbgstream &operator<<(const QString& string);
165 /** 172 /**
166 * Prints the given value. 173 * Prints the given value.
167 * @param string the string to print 174 * @param string the string to print
168 * @return this stream 175 * @return this stream
169 */ 176 */
170 odbgstream &operator<<(const char *string); 177 odbgstream &operator<<(const char *string);
171 /** 178 /**
172 * Prints the given value. 179 * Prints the given value.
173 * @param string the string to print 180 * @param string the string to print
174 * @return this stream 181 * @return this stream
175 */ 182 */
176 odbgstream &operator<<(const QCString& string); 183 odbgstream &operator<<(const QCString& string);
177 /** 184 /**
178 * Prints the given value. 185 * Prints the given value.
179 * @param p a pointer to print (in number form) 186 * @param p a pointer to print (in number form)
180 * @return this stream 187 * @return this stream
181 */ 188 */
182 odbgstream& operator<<(const void * p); 189 odbgstream& operator<<(const void * p);
183 /** 190 /**
184 * Prints the given value. 191 * Prints the given value.
185 * @param d the double to print 192 * @param d the double to print
186 * @return this stream 193 * @return this stream
187 */ 194 */
188 odbgstream& operator<<(double d); 195 odbgstream& operator<<(double d);
189 /** 196 /**
190 * Prints the string @p format which can contain 197 * Prints the string @p format which can contain
191 * printf-style formatted values. 198 * printf-style formatted values.
192 * @param format the printf-style format 199 * @param format the printf-style format
193 * @return this stream 200 * @return this stream
194 */ 201 */
195 odbgstream &form(const char *format, ...); 202 odbgstream &form(const char *format, ...);
196 /** Operator to print out basic information about a QWidget. 203 /** Operator to print out basic information about a QWidget.
197 * Output of class names only works if the class is moc'ified. 204 * Output of class names only works if the class is moc'ified.
198 * @param widget the widget to print 205 * @param widget the widget to print
199 * @return this stream 206 * @return this stream
200 */ 207 */
201 odbgstream& operator<< (QWidget* widget); 208 odbgstream& operator<< (QWidget* widget);
202 209
203 /** 210 /**
204 * Prints the given value. 211 * Prints the given value.
205 * @param dateTime the datetime to print 212 * @param dateTime the datetime to print
206 * @return this stream 213 * @return this stream
207 */ 214 */
208 odbgstream& operator<< ( const QDateTime& dateTime ); 215 odbgstream& operator<< ( const QDateTime& dateTime );
209 216
210 /** 217 /**
211 * Prints the given value. 218 * Prints the given value.
212 * @param date the date to print 219 * @param date the date to print
213 * @return this stream 220 * @return this stream
214 */ 221 */
215 odbgstream& operator<< ( const QDate& date ); 222 odbgstream& operator<< ( const QDate& date );
216 223
217 /** 224 /**
218 * Prints the given value. 225 * Prints the given value.
219 * @param time the time to print 226 * @param time the time to print
220 * @return this stream 227 * @return this stream
221 */ 228 */
222 odbgstream& operator<< ( const QTime& time ); 229 odbgstream& operator<< ( const QTime& time );
223 230
224 /** 231 /**
225 * Prints the given value. 232 * Prints the given value.
226 * @param point the point to print 233 * @param point the point to print
227 * @return this stream 234 * @return this stream
228 */ 235 */
229 odbgstream& operator<< ( const QPoint& point ); 236 odbgstream& operator<< ( const QPoint& point );
230 237
231 /** 238 /**
232 * Prints the given value. 239 * Prints the given value.
233 * @param size the QSize to print 240 * @param size the QSize to print
234 * @return this stream 241 * @return this stream
235 */ 242 */
236 odbgstream& operator<< ( const QSize& size ); 243 odbgstream& operator<< ( const QSize& size );
237 244
238 /** 245 /**
239 * Prints the given value. 246 * Prints the given value.
240 * @param rect the QRect to print 247 * @param rect the QRect to print
241 * @return this stream 248 * @return this stream
242 */ 249 */
243 odbgstream& operator<< ( const QRect& rect); 250 odbgstream& operator<< ( const QRect& rect);
244 251
245 /** 252 /**
246 * Prints the given value. 253 * Prints the given value.
247 * @param region the QRegion to print 254 * @param region the QRegion to print
248 * @return this stream 255 * @return this stream
249 */ 256 */
250 odbgstream& operator<< ( const QRegion& region); 257 odbgstream& operator<< ( const QRegion& region);
251 258
252 /** 259 /**
253 * Prints the given value. 260 * Prints the given value.
254 * @param list the stringlist to print 261 * @param list the stringlist to print
255 * @return this stream 262 * @return this stream
256 */ 263 */
257 odbgstream& operator<< ( const QStringList& list); 264 odbgstream& operator<< ( const QStringList& list);
258 265
259 /** 266 /**
260 * Prints the given value. 267 * Prints the given value.
261 * @param color the color to print 268 * @param color the color to print
262 * @return this stream 269 * @return this stream
263 */ 270 */
264 odbgstream& operator<< ( const QColor& color); 271 odbgstream& operator<< ( const QColor& color);
265 272
266 /** 273 /**
267 * Prints the given value. 274 * Prints the given value.
268 * @param brush the brush to print 275 * @param brush the brush to print
269 * @return this stream 276 * @return this stream
270 */ 277 */
271 odbgstream& operator<< ( const QBrush& brush ); 278 odbgstream& operator<< ( const QBrush& brush );
272 279
273 private: 280 private:
274 QString output; 281 QString output;
275 unsigned int area, level; 282 unsigned int area, level;
276 bool print; 283 bool print;
277 odbgstreamprivate* d; 284 odbgstreamprivate* d;
278}; 285};
279 286
280/** 287/**
281 * Prints an "\n". 288 * Prints an "\n".
282 * @param s the debug stream to write to 289 * @param s the debug stream to write to
283 * @return the debug stream (@p s) 290 * @return the debug stream (@p s)
284 */ 291 */
285inline odbgstream& endl( odbgstream &s) { s << "\n"; return s; } 292inline odbgstream& endl( odbgstream &s) { s << "\n"; return s; }
286/** 293/**
287 * Flushes the stream. 294 * Flushes the stream.
288 * @param s the debug stream to write to 295 * @param s the debug stream to write to
289 * @return the debug stream (@p s) 296 * @return the debug stream (@p s)
290 */ 297 */
291inline odbgstream& flush( odbgstream &s) { s.flush(); return s; } 298inline odbgstream& flush( odbgstream &s) { s.flush(); return s; }
292 299
293odbgstream &perror( odbgstream &s); 300odbgstream &perror( odbgstream &s);
294 301
295/** 302/**
296 * ondbgstream is a dummy variant of @ref odbgstream. All functions do 303 * ondbgstream is a dummy variant of @ref odbgstream. All functions do
297 * nothing. 304 * nothing.
298 * @see ondDebug() 305 * @see ondDebug()
299 */ 306 */
300class ondbgstream { 307class ondbgstream {
301 public: 308 public:
302 /// Empty constructor. 309 /// Empty constructor.
303 ondbgstream() {} 310 ondbgstream() {}
304 ~ondbgstream() {} 311 ~ondbgstream() {}
305 /** 312 /**
306 * Does nothing. 313 * Does nothing.
307 * @return this stream 314 * @return this stream
308 */ 315 */
309 ondbgstream &operator<<(short int ) { return *this; } 316 ondbgstream &operator<<(short int ) { return *this; }
310 /** 317 /**
311 * Does nothing. 318 * Does nothing.
312 * @return this stream 319 * @return this stream
313 */ 320 */
314 ondbgstream &operator<<(unsigned short int ) { return *this; } 321 ondbgstream &operator<<(unsigned short int ) { return *this; }
315 /** 322 /**
316 * Does nothing. 323 * Does nothing.
317 * @return this stream 324 * @return this stream
318 */ 325 */
319 ondbgstream &operator<<(char ) { return *this; } 326 ondbgstream &operator<<(char ) { return *this; }
320 /** 327 /**
321 * Does nothing. 328 * Does nothing.
322 * @return this stream 329 * @return this stream
323 */ 330 */
324 ondbgstream &operator<<(unsigned char ) { return *this; } 331 ondbgstream &operator<<(unsigned char ) { return *this; }
325 /** 332 /**
326 * Does nothing. 333 * Does nothing.
327 * @return this stream 334 * @return this stream
328 */ 335 */
329 ondbgstream &operator<<(int ) { return *this; } 336 ondbgstream &operator<<(int ) { return *this; }
330 /** 337 /**
331 * Does nothing. 338 * Does nothing.
332 * @return this stream 339 * @return this stream
333 */ 340 */
334 ondbgstream &operator<<(unsigned int ) { return *this; } 341 ondbgstream &operator<<(unsigned int ) { return *this; }
335 /** 342 /**
336 * Does nothing. 343 * Does nothing.
337 */ 344 */
338 void flush() {} 345 void flush() {}
339 /** 346 /**
340 * Does nothing. 347 * Does nothing.
341 * @return this stream 348 * @return this stream
342 */ 349 */
343 ondbgstream &operator<<(const QString& ) { return *this; } 350 ondbgstream &operator<<(const QString& ) { return *this; }
344 /** 351 /**
345 * Does nothing. 352 * Does nothing.
346 * @return this stream 353 * @return this stream
347 */ 354 */
348 ondbgstream &operator<<(const QCString& ) { return *this; } 355 ondbgstream &operator<<(const QCString& ) { return *this; }
349 /** 356 /**
350 * Does nothing. 357 * Does nothing.
351 * @return this stream 358 * @return this stream
352 */ 359 */
353 ondbgstream &operator<<(const char *) { return *this; } 360 ondbgstream &operator<<(const char *) { return *this; }
354 /** 361 /**
355 * Does nothing. 362 * Does nothing.
356 * @return this stream 363 * @return this stream
357 */ 364 */
358 ondbgstream& operator<<(const void *) { return *this; } 365 ondbgstream& operator<<(const void *) { return *this; }
359 /** 366 /**
360 * Does nothing. 367 * Does nothing.
361 * @return this stream 368 * @return this stream
362 */ 369 */
363 ondbgstream& operator<<(void *) { return *this; } 370 ondbgstream& operator<<(void *) { return *this; }
364 /** 371 /**
365 * Does nothing. 372 * Does nothing.
366 * @return this stream 373 * @return this stream
367 */ 374 */
368 ondbgstream& operator<<(double) { return *this; } 375 ondbgstream& operator<<(double) { return *this; }
369 /** 376 /**
370 * Does nothing. 377 * Does nothing.
371 * @return this stream 378 * @return this stream
372 */ 379 */
373 ondbgstream& operator<<(long) { return *this; } 380 ondbgstream& operator<<(long) { return *this; }
374 /** 381 /**
375 * Does nothing. 382 * Does nothing.
376 * @return this stream 383 * @return this stream
377 */ 384 */
378 ondbgstream& operator<<(unsigned long) { return *this; } 385 ondbgstream& operator<<(unsigned long) { return *this; }
379 /** 386 /**
380 * Does nothing. 387 * Does nothing.
381 * @return this stream 388 * @return this stream
382 */ 389 */
383 ondbgstream& operator << (QWidget*) { return *this; } 390 ondbgstream& operator << (QWidget*) { return *this; }
384 /** 391 /**
385 * Does nothing. 392 * Does nothing.
386 * @return this stream 393 * @return this stream
387 */ 394 */
388 ondbgstream &form(const char *, ...) { return *this; } 395 ondbgstream &form(const char *, ...) { return *this; }
389 396
390 ondbgstream& operator<<( const QDateTime& ) { return *this; } 397 ondbgstream& operator<<( const QDateTime& ) { return *this; }
391 ondbgstream& operator<<( const QDate& ) { return *this; } 398 ondbgstream& operator<<( const QDate& ) { return *this; }
392 ondbgstream& operator<<( const QTime& ) { return *this; } 399 ondbgstream& operator<<( const QTime& ) { return *this; }
393 ondbgstream& operator<<( const QPoint & ) { return *this; } 400 ondbgstream& operator<<( const QPoint & ) { return *this; }
394 ondbgstream& operator<<( const QSize & ) { return *this; } 401 ondbgstream& operator<<( const QSize & ) { return *this; }
395 ondbgstream& operator<<( const QRect & ) { return *this; } 402 ondbgstream& operator<<( const QRect & ) { return *this; }
396 ondbgstream& operator<<( const QRegion & ) { return *this; } 403 ondbgstream& operator<<( const QRegion & ) { return *this; }
397 ondbgstream& operator<<( const QStringList & ) { return *this; } 404 ondbgstream& operator<<( const QStringList & ) { return *this; }
398 ondbgstream& operator<<( const QColor & ) { return *this; } 405 ondbgstream& operator<<( const QColor & ) { return *this; }
399 ondbgstream& operator<<( const QBrush & ) { return *this; } 406 ondbgstream& operator<<( const QBrush & ) { return *this; }
400 407
401private: 408private:
402 class Private; 409 class Private;
403 Private *d; 410 Private *d;
404}; 411};
405 412
406/*====================================================================================== 413/*======================================================================================
407 * related functions 414 * related functions
408 *======================================================================================*/ 415 *======================================================================================*/
409 416
410/** 417/**
411 * Does nothing. 418 * Does nothing.
412 * @param a stream 419 * @param a stream
413 * @return the given @p s 420 * @return the given @p s
414 */ 421 */
415inline ondbgstream& endl( ondbgstream & s) { return s; } 422inline ondbgstream& endl( ondbgstream & s) { return s; }
416/** 423/**
417 * Does nothing. 424 * Does nothing.
418 * @param a stream 425 * @param a stream
419 * @return the given @p s 426 * @return the given @p s
420 */ 427 */
421inline ondbgstream& flush( ondbgstream & s) { return s; } 428inline ondbgstream& flush( ondbgstream & s) { return s; }
422inline ondbgstream& perror( ondbgstream & s) { return s; } 429inline ondbgstream& perror( ondbgstream & s) { return s; }
423 430
424/** 431/**
425 * Returns a debug stream. You can use it to print debug 432 * Returns a debug stream. You can use it to print debug
426 * information. 433 * information.
427 * @param area an id to identify the output, 0 for default 434 * @param area an id to identify the output, 0 for default
428 */ 435 */
429odbgstream odDebug(int area = 0); 436odbgstream odDebug(int area = 0);
430odbgstream odDebug(bool cond, int area = 0); 437odbgstream odDebug(bool cond, int area = 0);
431/** 438/**
432 * Returns a backtrace. 439 * Returns a backtrace.
433 * @param levels the number of levels (-1 for unlimited) of the backtrace 440 * @param levels the number of levels (-1 for unlimited) of the backtrace
434 * @return a backtrace 441 * @return a backtrace
435 */ 442 */
436QString odBacktrace(int levels = -1); 443QString odBacktrace(int levels = -1);
437/** 444/**
438 * Returns a dummy debug stream. The stream does not print anything. 445 * Returns a dummy debug stream. The stream does not print anything.
439 * @param area an id to identify the output, 0 for default 446 * @param area an id to identify the output, 0 for default
440 * @see odDebug() 447 * @see odDebug()
441 */ 448 */
442inline ondbgstream ondDebug(int = 0) { return ondbgstream(); } 449inline ondbgstream ondDebug(int = 0) { return ondbgstream(); }
443inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); } 450inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); }
444inline QString ondBacktrace() { return QString::null; } 451inline QString ondBacktrace() { return QString::null; }
445inline QString ondBacktrace(int) { return QString::null; } 452inline QString ondBacktrace(int) { return QString::null; }
446 453
447/** 454/**
448 * Returns a warning stream. You can use it to print warning 455 * Returns a warning stream. You can use it to print warning
449 * information. 456 * information.
450 * @param area an id to identify the output, 0 for default 457 * @param area an id to identify the output, 0 for default
451 */ 458 */
452odbgstream odWarning(int area = 0); 459odbgstream odWarning(int area = 0);
453odbgstream odWarning(bool cond, int area = 0); 460odbgstream odWarning(bool cond, int area = 0);
454/** 461/**
455 * Returns an error stream. You can use it to print error 462 * Returns an error stream. You can use it to print error
456 * information. 463 * information.
457 * @param area an id to identify the output, 0 for default 464 * @param area an id to identify the output, 0 for default
458 */ 465 */
459odbgstream odError(int area = 0); 466odbgstream odError(int area = 0);
460odbgstream odError(bool cond, int area = 0); 467odbgstream odError(bool cond, int area = 0);
461/** 468/**
462 * Returns a fatal error stream. You can use it to print fatal error 469 * Returns a fatal error stream. You can use it to print fatal error
463 * information. 470 * information.
464 * @param area an id to identify the output, 0 for default 471 * @param area an id to identify the output, 0 for default
465 */ 472 */
466odbgstream odFatal(int area = 0); 473odbgstream odFatal(int area = 0);
467odbgstream odFatal(bool cond, int area = 0); 474odbgstream odFatal(bool cond, int area = 0);
468 475
469/** 476/**
470 * Deletes the odebugrc cache and therefore forces KDebug to reread the 477 * Deletes the odebugrc cache and therefore forces KDebug to reread the
471 * config file 478 * config file
472 */ 479 */
473void odClearDebugConfig(); 480void odClearDebugConfig();
474 481
475#ifdef OPIE_NO_DEBUG 482#ifdef OPIE_NO_DEBUG
476#define odDebug ondDebug 483#define odDebug ondDebug
477#define odBacktrace ondBacktrace 484#define odBacktrace ondBacktrace
478#endif 485#endif
479 486
480} 487}
481} 488}
482 489
483#endif 490#endif
484 491