00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (c) 2009 Dan Leinir Turthra Jensen <admin@leinir.dk> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 // Adapted from code by wysota - http://blog.wysota.eu.org/index.php/2009/11/17/little-debugging-helper/ 00021 00022 #ifndef GLUON_CORE_DEBUGHELPER_H 00023 #define GLUON_CORE_DEBUGHELPER_H 00024 00025 #include "gluon_core_export.h" 00026 00027 #include <QtCore/QString> 00028 00029 //#ifndef QT_NO_DEBUG 00030 # define DEBUG_FUNC_NAME GluonCore::DbgHelper dbgHelper(Q_FUNC_INFO); 00031 # define DEBUG_BLOCK GluonCore::DbgHelper dbgHelper; 00032 # define DEBUG_TEXT(X) dbgHelper.addText(X); 00033 # define DEBUG_TEXT2(X, Y) dbgHelper.addText(QString(X).arg(Y)); 00034 //#else 00035 //# define DEBUG_FUNC_NAME 00036 //# define DEBUG_BLOCK 00037 //# define DEBUG_TEXT(X) 00038 //#endif 00039 00040 #define NO_COLOR 1 00041 00042 namespace GluonCore 00043 { 00044 class GLUON_CORE_EXPORT DbgHelper 00045 { 00046 public: 00047 DbgHelper(); 00048 DbgHelper( const QString& t ); 00049 ~DbgHelper(); 00050 00051 void addText( const QString& t ); 00052 private: 00053 QString txt; 00054 static int indent; 00055 static int colorIndex; 00056 int myColor; 00057 bool noFunctionName; 00058 }; 00059 } 00060 00061 #endif // GLUON_CORE_DEBUGHELPER_H