• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kdebug.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
00003                   2000-2002 Stephan Kulow (coolo@kde.org)
00004                   2002 Holger Freyther (freyther@kde.org)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef _KDEBUG_H_
00023 #define _KDEBUG_H_
00024 
00025 #include <kdecore_export.h>
00026 
00027 #include <QtCore/QDebug>
00028 
00039 #if !defined(KDE_NO_DEBUG_OUTPUT)
00040 # if defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_DEBUG_STREAM)
00041 #  define KDE_NO_DEBUG_OUTPUT
00042 # endif
00043 #endif
00044 
00045 #if !defined(KDE_NO_WARNING_OUTPUT)
00046 # if defined(QT_NO_WARNING_OUTPUT)
00047 #  define KDE_NO_WARNING_OUTPUT
00048 # endif
00049 #endif
00050 
00051 
00057 #define k_funcinfo ""
00058 
00066 #define k_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
00067 
00072 KDECORE_EXPORT QDebug kDebugStream(QtMsgType level, int area, const char *file = 0,
00073                                    int line = -1, const char *funcinfo = 0);
00074 
00079 KDECORE_EXPORT QDebug kDebugDevNull();
00080 
00085 KDECORE_EXPORT QString kRealBacktrace(int);
00086 
00087 
00097 #if !defined(KDE_NO_DEBUG_OUTPUT)
00098 inline QString kBacktrace(int levels=-1) { return kRealBacktrace(levels); }
00099 #else
00100 static inline QString kBacktrace(int=-1) { return QString(); }
00101 #endif
00102 
00108 KDECORE_EXPORT void kClearDebugConfig();
00109 
00110 #ifndef KDE_DEFAULT_DEBUG_AREA
00111 # define KDE_DEFAULT_DEBUG_AREA 0
00112 #endif
00113 
00135 #if !defined(KDE_NO_DEBUG_OUTPUT)
00136 
00142 static inline QDebug kDebug(int area = KDE_DEFAULT_DEBUG_AREA)
00143 { return kDebugStream(QtDebugMsg, area); }
00144 static inline QDebug kDebug(bool cond, int area = KDE_DEFAULT_DEBUG_AREA)
00145 { return cond ? kDebug(area) : kDebugDevNull(); }
00146 
00147 #else  // KDE_NO_DEBUG_OUTPUT
00148 static inline QDebug kDebug(int = KDE_DEFAULT_DEBUG_AREA) { return kDebugDevNull(); }
00149 static inline QDebug kDebug(bool, int = KDE_DEFAULT_DEBUG_AREA) { return kDebugDevNull(); }
00150 #endif
00151 
00152 #if !defined(KDE_NO_WARNING_OUTPUT)
00153 
00159 static inline QDebug kWarning(int area = KDE_DEFAULT_DEBUG_AREA)
00160 { return kDebugStream(QtWarningMsg, area); }
00161 static inline QDebug kWarning(bool cond, int area = KDE_DEFAULT_DEBUG_AREA)
00162 { return cond ? kWarning(area) : kDebugDevNull(); }
00163 
00164 #else  // KDE_NO_WARNING_OUTPUT
00165 static inline QDebug kWarning(int = KDE_DEFAULT_DEBUG_AREA) { return kDebugDevNull(); }
00166 static inline QDebug kWarning(bool, int = KDE_DEFAULT_DEBUG_AREA) { return kDebugDevNull(); }
00167 #endif
00168 
00175 static inline QDebug kError(int area = KDE_DEFAULT_DEBUG_AREA)
00176 { return kDebugStream(QtCriticalMsg, area); }
00177 static inline QDebug kError(bool cond, int area = KDE_DEFAULT_DEBUG_AREA)
00178 { return cond ? kError(area) : kDebugDevNull(); }
00179 
00186 static inline QDebug kFatal(int area = KDE_DEFAULT_DEBUG_AREA)
00187 { return kDebugStream(QtFatalMsg, area); }
00188 static inline QDebug kFatal(bool cond, int area = KDE_DEFAULT_DEBUG_AREA)
00189 { return cond ? kFatal(area) : kDebugDevNull(); }
00190 
00191 struct KDebugTag { }; 
00192 typedef QDebug (*KDebugStreamFunction)(QDebug, KDebugTag); 
00193 inline QDebug operator<<(QDebug s, KDebugStreamFunction f)
00194 { return (*f)(s, KDebugTag()); }
00195 
00203 KDECORE_EXPORT QDebug perror(QDebug, KDebugTag);
00204 
00205 // operators for KDE types
00206 class KUrl;
00207 class KDateTime;
00208 class QObject;
00209 KDECORE_EXPORT QDebug operator<<(QDebug s, const KUrl &url);
00210 KDECORE_EXPORT QDebug operator<<(QDebug s, const KDateTime &time);
00211 
00212 #if 1 || defined(KDE3_SUPPORT)
00213 class KDE_DEPRECATED kndbgstream { };
00214 typedef QDebug kdbgstream;
00215 
00216 static inline KDE_DEPRECATED QDebug kdDebug(int area = KDE_DEFAULT_DEBUG_AREA) { return kDebug(area); }
00217 static inline KDE_DEPRECATED QDebug kdWarning(int area = KDE_DEFAULT_DEBUG_AREA) { return kWarning(area); }
00218 static inline KDE_DEPRECATED QDebug kdError(int area = KDE_DEFAULT_DEBUG_AREA) { return kError(area); }
00219 static inline KDE_DEPRECATED QDebug kdFatal(int area = KDE_DEFAULT_DEBUG_AREA) { return kFatal(area); }
00220 inline KDE_DEPRECATED QString kdBacktrace(int levels=-1) { return kBacktrace( levels ); }
00221 
00222 static inline KDE_DEPRECATED QDebug kndDebug() { return kDebugDevNull(); }
00223 #endif
00224 
00229 class KDebug                    //krazy= ?
00230 {
00231     const char *file;
00232     const char *funcinfo;
00233     int line;
00234     QtMsgType level;
00235 public:
00236     explicit inline KDebug(QtMsgType type, const char *f = 0, int l = -1, const char *info = 0)
00237         : file(f), funcinfo(info), line(l), level(type)
00238         { }
00239     inline QDebug operator()(int area = KDE_DEFAULT_DEBUG_AREA)
00240         { return kDebugStream(level, area, file, line, funcinfo); }
00241     inline QDebug operator()(bool cond, int area = KDE_DEFAULT_DEBUG_AREA)
00242         { if (cond) return operator()(area); return kDebugDevNull(); }
00243 };
00244 
00245 #if !defined(KDE_NO_DEBUG_OUTPUT)
00246 # define kDebug        KDebug(QtDebugMsg, __FILE__, __LINE__, Q_FUNC_INFO)
00247 #else
00248 # define kDebug        if (1); else kDebug
00249 #endif
00250 #if !defined(KDE_NO_WARNING_OUTPUT)
00251 # define kWarning      KDebug(QtWarningMsg, __FILE__, __LINE__, Q_FUNC_INFO)
00252 #else
00253 # define kWarning      if (1); else kWarning
00254 #endif
00255 
00258 #endif
00259 

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal