1 /* 2 * %kadu copyright begin% 3 * Copyright 2010, 2011 Piotr Galiszewski (piotr.galiszewski@kadu.im) 4 * Copyright 2008, 2009 Michał Podsiadlik (michal@kadu.net) 5 * Copyright 2011, 2013 Bartosz Brachaczek (b.brachaczek@gmail.com) 6 * Copyright 2007 Marcin Ślusarz (joi@kadu.net) 7 * Copyright 2008, 2009, 2010, 2011, 2013, 2014 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com) 8 * %kadu copyright end% 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License as 12 * published by the Free Software Foundation; either version 2 of 13 * the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. 22 */ 23 24 #ifndef DEBUG_H 25 #define DEBUG_H 26 27 #include <QtCore/QDateTime> 28 29 #include "exports.h" 30 31 /* pierwsze 8 bitow zarezerwowane jest dla libgadu */ 32 33 /* start funkcji */ 34 #define KDEBUG_FUNCTION_START (1<<8) 35 /* koniec funkcji */ 36 #define KDEBUG_FUNCTION_END (1<<9) 37 38 /* zwykle inforamcje */ 39 #define KDEBUG_INFO (1<<10) 40 /* niegrozne ostrzezenie */ 41 #define KDEBUG_WARNING (1<<11) 42 /* powazny blad, ale sytuacja jest do obejscia */ 43 #define KDEBUG_ERROR (1<<12) 44 /* blad fatalny, mozliwe ze program sie wywroci */ 45 #define KDEBUG_PANIC (1<<13) 46 47 /* duzo danych do wypisania */ 48 #define KDEBUG_DUMP (1<<14) 49 /* informacja dotyczaca obslugi sieci */ 50 #define KDEBUG_NETWORK (1<<15) 51 52 #define KDEBUG_VISUAL (1<<16) 53 54 /* 2^31-1 - wszystkie komunikaty */ 55 #define KDEBUG_ALL 2147483647 56 57 /* 58 <<< kdebug >>> 59 Wy�wietla komunikat debuguj�cy na konsoli. 60 Sk�adnia jak w printf. 61 */ 62 #ifdef DEBUG_OUTPUT_ENABLED 63 #ifdef _MSC_VER 64 #define __PRETTY_FUNCTION__ __FUNCTION__ 65 #define kdebug(format, ...) \ 66 _kdebug_with_mask(KDEBUG_ALL, __FILE__, __LINE__, format, __VA_ARGS__) 67 #define kdebugm(mask, format, ...) \ 68 _kdebug_with_mask(mask, __FILE__, __LINE__, format, __VA_ARGS__) 69 #define kdebugmf(mask, format, ...) \ 70 _kdebug_with_mask(mask, __FILE__, __LINE__, "%s: " format, __PRETTY_FUNCTION__, __VA_ARGS__) 71 #else 72 #define kdebug(format, args...) \ 73 _kdebug_with_mask(KDEBUG_ALL, __FILE__, __LINE__, format, ##args) 74 #define kdebugm(mask, format, args...) \ 75 _kdebug_with_mask(mask, __FILE__, __LINE__, format, ##args) 76 #define kdebugmf(mask, format, args...) \ 77 _kdebug_with_mask(mask, __FILE__, __LINE__, "%s: " format, __PRETTY_FUNCTION__, ##args) 78 #endif // _MSC_VER 79 #else 80 #define kdebug(format, ...) 81 #define kdebugm(mask, format, ...) 82 #define kdebugmf(mask, format, ...) 83 #endif 84 85 /* 86 <<< kdebugf >>> 87 Wy�wietla komunikat debuguj�cy zawieraj�cy 88 nazw� aktualnie wykonywanej funkcji. 89 Z za�o�enia makro to powinno by� wywo�ane 90 w pierwszej linii ka�dej funkcji. Dzi�ki 91 temu mo�na b�dzie w przysz�o�ci �ledzi� 92 dzia�anie programu. 93 */ 94 #define kdebugf() \ 95 kdebugm(KDEBUG_FUNCTION_START, "%s\n", __PRETTY_FUNCTION__) 96 97 #define kdebugf2() \ 98 kdebugm(KDEBUG_FUNCTION_END, "%s end\n", __PRETTY_FUNCTION__) 99 100 /* 101 Funkcja pomocnicza. Nie u�ywa�. 102 */ 103 #ifdef DEBUG_OUTPUT_ENABLED 104 KADUAPI void _kdebug_with_mask(int mask, const char *file, const int line, const char *format, ...) 105 #ifndef _MSC_VER 106 __attribute__((format (printf, 4, 5))) 107 #endif 108 ; 109 #endif 110 extern KADUAPI int debug_mask; 111 112 namespace Debug 113 { 114 void ktDebugStart(const QString &message, QTime &time); 115 void ktDebugCheckPoint(const QString &message, QTime &time); 116 } 117 118 #endif // DEBUG_H 119