mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdecore: simplify and unexport KDebug internals
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b45b5344b2
commit
6d54fcbe94
2 changed files with 33 additions and 89 deletions
|
@ -45,11 +45,8 @@ static int s_kde_debug_methodname = -1;
|
|||
static int s_kde_debug_timestamp = -1;
|
||||
static int s_kde_debug_color = -1;
|
||||
|
||||
static QByteArray kDebugHeader(const QByteArray &areaname, const char* const file, const int line, const char* const funcinfo)
|
||||
static QByteArray kDebugHeader(const QByteArray &areaname, const char* const funcinfo)
|
||||
{
|
||||
Q_UNUSED(file);
|
||||
Q_UNUSED(line);
|
||||
|
||||
if (s_kde_debug_methodname == -1) {
|
||||
s_kde_debug_methodname = !qgetenv("KDE_DEBUG_METHODNAME").isEmpty();
|
||||
}
|
||||
|
@ -486,7 +483,21 @@ QString kBacktrace(int levels)
|
|||
#endif // HAVE_BACKTRACE
|
||||
}
|
||||
|
||||
QDebug kDebugStream(QtMsgType level, int area, const char *file, int line, const char *funcinfo)
|
||||
void kClearDebugConfig()
|
||||
{
|
||||
QMutexLocker locker(globalKDebugMutex);
|
||||
|
||||
globalKDebugDevices->destroyDevices();
|
||||
|
||||
globalKDebugConfig->reparseConfiguration();
|
||||
globalKDebugConfig->cacheAreas();
|
||||
|
||||
s_kde_debug_methodname = -1;
|
||||
s_kde_debug_timestamp = -1;
|
||||
s_kde_debug_color = -1;
|
||||
}
|
||||
|
||||
QDebug KDebug(const QtMsgType type, const char* const funcinfo, const int area)
|
||||
{
|
||||
QMutexLocker locker(globalKDebugMutex);
|
||||
|
||||
|
@ -499,7 +510,7 @@ QDebug kDebugStream(QtMsgType level, int area, const char *file, int line, const
|
|||
QString areafilename;
|
||||
// TODO: abort when? can't show message box and abort immediately
|
||||
bool areaabort = true;
|
||||
switch (level) {
|
||||
switch (type) {
|
||||
case QtDebugMsg: {
|
||||
areaoutput = kdebugareacache.infooutput;
|
||||
areafilename = kdebugareacache.infofilename;
|
||||
|
@ -532,8 +543,8 @@ QDebug kDebugStream(QtMsgType level, int area, const char *file, int line, const
|
|||
globalKDebugDevices->insert(areakey, qiodevice);
|
||||
}
|
||||
KDebugFileDevice* kdebugdevice = qobject_cast<KDebugFileDevice*>(qiodevice);
|
||||
kdebugdevice->setLevel(level);
|
||||
kdebugdevice->setHeader(kDebugHeader(globalKDebugConfig->areaName(area), file, line, funcinfo));
|
||||
kdebugdevice->setLevel(type);
|
||||
kdebugdevice->setHeader(kDebugHeader(globalKDebugConfig->areaName(area), funcinfo));
|
||||
kdebugdevice->setFilepath(areafilename);
|
||||
return QDebug(kdebugdevice);
|
||||
}
|
||||
|
@ -544,8 +555,8 @@ QDebug kDebugStream(QtMsgType level, int area, const char *file, int line, const
|
|||
globalKDebugDevices->insert(areakey, qiodevice);
|
||||
}
|
||||
KDebugMessageBoxDevice* kdebugdevice = qobject_cast<KDebugMessageBoxDevice*>(qiodevice);
|
||||
kdebugdevice->setLevel(level);
|
||||
kdebugdevice->setHeader(kDebugHeader(globalKDebugConfig->areaName(area), file, line, funcinfo));
|
||||
kdebugdevice->setLevel(type);
|
||||
kdebugdevice->setHeader(kDebugHeader(globalKDebugConfig->areaName(area), funcinfo));
|
||||
return QDebug(kdebugdevice);
|
||||
}
|
||||
case KDebugConfig::TypeShell: {
|
||||
|
@ -555,8 +566,8 @@ QDebug kDebugStream(QtMsgType level, int area, const char *file, int line, const
|
|||
globalKDebugDevices->insert(areakey, qiodevice);
|
||||
}
|
||||
KDebugShellDevice* kdebugdevice = qobject_cast<KDebugShellDevice*>(qiodevice);
|
||||
kdebugdevice->setLevel(level);
|
||||
kdebugdevice->setHeader(kDebugHeader(globalKDebugConfig->areaName(area), file, line, funcinfo));
|
||||
kdebugdevice->setLevel(type);
|
||||
kdebugdevice->setHeader(kDebugHeader(globalKDebugConfig->areaName(area), funcinfo));
|
||||
return QDebug(kdebugdevice);
|
||||
}
|
||||
case KDebugConfig::TypeSyslog: {
|
||||
|
@ -566,8 +577,8 @@ QDebug kDebugStream(QtMsgType level, int area, const char *file, int line, const
|
|||
globalKDebugDevices->insert(areakey, qiodevice);
|
||||
}
|
||||
KDebugSyslogDevice* kdebugdevice = qobject_cast<KDebugSyslogDevice*>(qiodevice);
|
||||
kdebugdevice->setLevel(level);
|
||||
kdebugdevice->setHeader(kDebugHeader(globalKDebugConfig->areaName(area), file, line, funcinfo));
|
||||
kdebugdevice->setLevel(type);
|
||||
kdebugdevice->setHeader(kDebugHeader(globalKDebugConfig->areaName(area), funcinfo));
|
||||
return QDebug(kdebugdevice);
|
||||
}
|
||||
case KDebugConfig::TypeOff:
|
||||
|
@ -578,20 +589,6 @@ QDebug kDebugStream(QtMsgType level, int area, const char *file, int line, const
|
|||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
void kClearDebugConfig()
|
||||
{
|
||||
QMutexLocker locker(globalKDebugMutex);
|
||||
|
||||
globalKDebugDevices->destroyDevices();
|
||||
|
||||
globalKDebugConfig->reparseConfiguration();
|
||||
globalKDebugConfig->cacheAreas();
|
||||
|
||||
s_kde_debug_methodname = -1;
|
||||
s_kde_debug_timestamp = -1;
|
||||
s_kde_debug_color = -1;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug s, const KDateTime &time)
|
||||
{
|
||||
if ( time.isDateOnly() )
|
||||
|
|
|
@ -35,13 +35,6 @@
|
|||
* output and when it is TTY
|
||||
*/
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Returns a debug stream that may or may not output anything.
|
||||
*/
|
||||
KDECORE_EXPORT QDebug kDebugStream(QtMsgType level, int area, const char *file = 0,
|
||||
int line = -1, const char *funcinfo = 0);
|
||||
|
||||
/**
|
||||
* \relates KGlobal
|
||||
* Returns a backtrace.
|
||||
|
@ -89,37 +82,11 @@ KDECORE_EXPORT void kClearDebugConfig();
|
|||
* \relates KGlobal
|
||||
* Returns a debug stream. You can use it to print debug
|
||||
* information.
|
||||
* @param area an id to identify the output, KDE_DEFAULT_DEBUG_AREA for default
|
||||
* @param type type of message
|
||||
* @param funcinfo caller of KDebug
|
||||
* @param area an id to identify the output
|
||||
*/
|
||||
static inline QDebug kDebug(int area = KDE_DEFAULT_DEBUG_AREA)
|
||||
{ return kDebugStream(QtDebugMsg, area); }
|
||||
|
||||
/**
|
||||
* \relates KGlobal
|
||||
* Returns a warning stream. You can use it to print warning
|
||||
* information.
|
||||
* @param area an id to identify the output, KDE_DEFAULT_DEBUG_AREA for default
|
||||
*/
|
||||
static inline QDebug kWarning(int area = KDE_DEFAULT_DEBUG_AREA)
|
||||
{ return kDebugStream(QtWarningMsg, area); }
|
||||
|
||||
/**
|
||||
* \relates KGlobal
|
||||
* Returns an error stream. You can use it to print error
|
||||
* information.
|
||||
* @param area an id to identify the output, KDE_DEFAULT_DEBUG_AREA for default
|
||||
*/
|
||||
static inline QDebug kError(int area = KDE_DEFAULT_DEBUG_AREA)
|
||||
{ return kDebugStream(QtCriticalMsg, area); }
|
||||
|
||||
/**
|
||||
* \relates KGlobal
|
||||
* Returns a fatal error stream. You can use it to print fatal error
|
||||
* information.
|
||||
* @param area an id to identify the output, KDE_DEFAULT_DEBUG_AREA for default
|
||||
*/
|
||||
static inline QDebug kFatal(int area = KDE_DEFAULT_DEBUG_AREA)
|
||||
{ return kDebugStream(QtFatalMsg, area); }
|
||||
KDECORE_EXPORT QDebug KDebug(const QtMsgType type, const char* const funcinfo, const int area = KDE_DEFAULT_DEBUG_AREA);
|
||||
|
||||
// operators for KDE types
|
||||
class KUrl;
|
||||
|
@ -127,30 +94,10 @@ class KDateTime;
|
|||
KDECORE_EXPORT QDebug operator<<(QDebug s, const KUrl &url);
|
||||
KDECORE_EXPORT QDebug operator<<(QDebug s, const KDateTime &time);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* A class for using operator()
|
||||
*/
|
||||
class KDebug
|
||||
{
|
||||
const char* const file;
|
||||
const char* const funcinfo;
|
||||
const int line;
|
||||
const QtMsgType level;
|
||||
public:
|
||||
explicit inline KDebug(QtMsgType type, const char* const f = 0, int l = -1, const char* const info = 0)
|
||||
: file(f), funcinfo(info), line(l), level(type)
|
||||
{
|
||||
}
|
||||
|
||||
inline QDebug operator()(int area = KDE_DEFAULT_DEBUG_AREA)
|
||||
{ return kDebugStream(level, area, file, line, funcinfo); }
|
||||
};
|
||||
|
||||
#define kDebug KDebug(QtDebugMsg, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define kWarning KDebug(QtWarningMsg, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define kError KDebug(QtCriticalMsg, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define kFatal KDebug(QtFatalMsg, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define kDebug(...) KDebug(QtDebugMsg, Q_FUNC_INFO, ##__VA_ARGS__)
|
||||
#define kWarning(...) KDebug(QtWarningMsg, Q_FUNC_INFO, ##__VA_ARGS__)
|
||||
#define kError(...) KDebug(QtCriticalMsg, Q_FUNC_INFO, ##__VA_ARGS__)
|
||||
#define kFatal(...) KDebug(QtFatalMsg, Q_FUNC_INFO, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Convenience macro, use this to remind yourself to finish the implementation of a function
|
||||
|
|
Loading…
Add table
Reference in a new issue