1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2015-2016 Canonical Ltd.
5  *
6  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  */
22 
23 #ifndef LIBSIGNON_DEBUG_H
24 #define LIBSIGNON_DEBUG_H
25 
26 #include <QDebug>
27 
28 #ifdef TRACE
29     #undef TRACE
30 #endif
31 
32 #ifdef BLAME
33     #undef BLAME
34 #endif
35 
36 #ifdef DEBUG_ENABLED
37 extern int libsignon_logging_level;
debugEnabled()38 static inline bool debugEnabled() {
39         return libsignon_logging_level >= 2;
40 }
41 
criticalsEnabled()42 static inline bool criticalsEnabled() {
43         return libsignon_logging_level >= 1;
44 }
45 #define TRACE() \
46         if (debugEnabled()) qDebug()
47 #define BLAME() \
48         if (criticalsEnabled()) qCritical()
49 
50 #else // DEBUG_ENABLED
51     #define TRACE() while (0) qDebug()
52     #define BLAME() while (0) qDebug()
53 #endif
54 
55 namespace SignOn {
56 
57 void setLoggingLevel(int level);
58 void initDebug();
59 
60 }
61 
62 #endif // LIBSIGNON_DEBUG_H
63