libqutim  0.3.1.0
debug.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** qutIM - instant messenger
00004 **
00005 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
00006 **
00007 *****************************************************************************
00008 **
00009 ** $QUTIM_BEGIN_LICENSE$
00010 ** This program is free software: you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation, either version 3 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 ** See the GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program.  If not, see http://www.gnu.org/licenses/.
00022 ** $QUTIM_END_LICENSE$
00023 **
00024 ****************************************************************************/
00025 
00026 #ifndef DEBUG_H
00027 #define DEBUG_H
00028 
00029 // Include QDebug, because we want to redefine some symbols
00030 #include <QDebug>
00031 #include "libqutim_global.h"
00032 
00033 namespace qutim_sdk_0_3
00034 {
00035     enum DebugLevel
00036     {
00037         DebugInfo = 0,
00038         DebugVerbose,
00039         DebugVeryVerbose
00040     };
00041 
00042     LIBQUTIM_EXPORT QDebug debug_helper(quint64, DebugLevel, QtMsgType);
00043     LIBQUTIM_EXPORT void debugAddPluginId(quint64, const QMetaObject *meta);
00044     LIBQUTIM_EXPORT void debugClearConfig();
00045 
00046 #ifndef QUTIM_PLUGIN_ID
00047     inline QDebug debug(DebugLevel level = DebugInfo)
00048     { return debug_helper(0, level, QtDebugMsg); }
00049     inline QDebug warning(DebugLevel level = DebugInfo)
00050     { return debug_helper(0, level, QtWarningMsg); }
00051     inline QDebug critical(DebugLevel level = DebugInfo)
00052     { return debug_helper(0, level, QtCriticalMsg); }
00053     inline QDebug fatal(DebugLevel level = DebugInfo)
00054     { return debug_helper(0, level, QtFatalMsg); }
00055 #else
00056 # define QUTIM_DEBUG_ID_CONVERT_HELPER(A) 0x ## A ## ULL
00057 # define QUTIM_DEBUG_ID_CONVERT(A) QUTIM_DEBUG_ID_CONVERT_HELPER(A)
00058     inline quint64 qutim_plugin_id()
00059     { return QUTIM_DEBUG_ID_CONVERT(QUTIM_PLUGIN_ID); }
00060     inline QDebug debug(DebugLevel level = DebugInfo)
00061     { return debug_helper(qutim_plugin_id(), level, QtDebugMsg); }
00062     inline QDebug warning(DebugLevel level = DebugInfo)
00063     { return debug_helper(qutim_plugin_id(), level, QtWarningMsg); }
00064     inline QDebug critical(DebugLevel level = DebugInfo)
00065     { return debug_helper(qutim_plugin_id(), level, QtCriticalMsg); }
00066     inline QDebug fatal(DebugLevel level = DebugInfo)
00067     { return debug_helper(qutim_plugin_id(), level, QtFatalMsg); }
00068 # undef QUTIM_DEBUG_ID_CONVERT_HELPER
00069 # undef QUTIM_DEBUG_ID_CONVERT
00070 #endif
00071 }
00072 #endif // DEBUG_H
00073