1/****************************************************************************
2**
3** Copyright (C) 2008 Ralf Habacker. All rights reserved.
4**
5** This file is part of the KDE installer for windows
6**
7** This library is free software; you can redistribute it and/or
8** modify it under the terms of the GNU Library General Public
9** License version 2 as published by the Free Software Foundation.
10**
11** This library is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14** Library General Public License for more details.
15**
16** You should have received a copy of the GNU Library General Public License
17** along with this library; see the file COPYING.LIB. If not, write to
18** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19** Boston, MA 02110-1301, USA.
20**
21****************************************************************************/
22
23#ifndef DEBUG_H
24#define DEBUG_H
25
26#include <QtDebug>
27
28// own debug functions
29QDebug _qDebug(const char *file, int line);
30QDebug _qInfo(const char *file, int line);
31QDebug _qWarning(const char *file, int line);
32QDebug _qCritical(const char *file, int line);
33QDebug _qFatal(const char *file, int line);
34
35#if 0
36// wrapper for original q... calls
37#define qDebug() _qDebug(__FILE__,__LINE__)
38#define qInfo() _qInfo(__FILE__,__LINE__)
39#define qWarning() _qWarning(__FILE__,__LINE__)
40#define qCritical() _qCritical(__FILE__,__LINE__)
41#define qFatal() _qFatal(__FILE__,__LINE__)
42#endif
43
44/// return stdout stream
45QTextStream &qOut();
46/// return stderr stream
47QTextStream &qError();
48
49
50/// set message handler
51void setMessageHandler(const QString &baseName="kdewin-installer");
52
53/// close message handler
54void closeMessageHandler();
55
56/// return log file name
57QString logFileName();
58
59/// return log file path and name as url
60QString logFileNameAsURL();
61
62/// return log data
63QByteArray *log();
64
65/**
66macros for creating qDebug class support
67
68QDebug operator<<(QDebug out, const XmlPart &c)
69{
70 QDEBUG_CLASS_START(out,XmlPart,c)
71 QDEBUG_CLASS_MEMBER(name)
72 QDEBUG_CLASS_LIST(XmlFiles,fileList)
73 QDEBUG_CLASS_END()
74}
75*/
76
77#ifndef NO_QDEBUG_CLASS_PRINT
78extern char *qDebug_indentBuf;
79extern int qDebug_indention;
80
81inline char *qDebug_indent()
82{
83 return qDebug_indentBuf+strlen(qDebug_indentBuf)-(qDebug_indention-1)*2;
84}
85
86inline char *qDebug_indentIncrease()
87{
88 qDebug_indention++;
89 return qDebug_indent();
90}
91
92inline char *qDebug_indentdecrease()
93{
94 qDebug_indention--;
95 return qDebug_indent();
96}
97#define QDEBUG_CLASS_START(out,_class, object) QDebug &_out =out; const _class &_c = object; _out << qDebug_indentIncrease() << #_class << " ("
98#define QDEBUG_CLASS_MEMBER(member) << #member << ":" << _c.member
99#define QDEBUG_CLASS_LIST(_class,member) ; _out << #member << ":\n"; foreach(_class *m, _c.member) _out << *m;
100#define QDEBUG_CLASS_END() ; _out << qDebug_indentdecrease() << " )\n"; return _out;
101#else
102#define QDEBUG_CLASS_START(out,_class, object) return out;
103#define QDEBUG_CLASS_MEMBER(member)
104#define QDEBUG_CLASS_LIST(_class,member)
105#define QDEBUG_CLASS_END()
106#endif
107
108#endif
109