1 /* 2 * This file is part of signon-ui 3 * 4 * Copyright (C) 2011 Canonical Ltd. 5 * 6 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> 7 * 8 * This program is free software: you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License version 3, as published 10 * by the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranties of 14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 15 * PURPOSE. See the GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License along 18 * with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #ifndef SIGNON_UI_DEBUG_H 21 #define SIGNON_UI_DEBUG_H 22 23 #include <QDebug> 24 25 /* 0 - fatal, 1 - critical(default), 2 - info/debug */ 26 extern int appLoggingLevel; 27 debugEnabled()28static inline bool debugEnabled() 29 { 30 return appLoggingLevel >= 2; 31 } 32 criticalsEnabled()33static inline bool criticalsEnabled() 34 { 35 return appLoggingLevel >= 1; 36 } 37 loggingLevel()38static inline int loggingLevel() 39 { 40 return appLoggingLevel; 41 } 42 43 void setLoggingLevel(int level); 44 45 #ifdef DEBUG_ENABLED 46 #define TRACE() \ 47 if (debugEnabled()) qDebug() << __FILE__ << __LINE__ << __func__ 48 #define BLAME() \ 49 if (criticalsEnabled()) qCritical() << __FILE__ << __LINE__ << __func__ 50 #else 51 #define TRACE() while (0) qDebug() 52 #define BLAME() while (0) qDebug() 53 #endif 54 55 #endif // SIGNON_UI_DEBUG_H 56 57