File indexing completed on 2025-01-12 03:40:51

0001 /* This file is part of the dbusmenu-qt library
0002    SPDX-FileCopyrightText: 2009 Canonical
0003    Author: Aurelien Gateau <aurelien.gateau@canonical.com>
0004 
0005    SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 #ifndef DEBUG_P_H
0008 #define DEBUG_P_H
0009 
0010 #include <QDebug>
0011 
0012 #define _DMBLUE "\033[34m"
0013 #define _DMRED "\033[31m"
0014 #define _DMRESET "\033[0m"
0015 #define _DMTRACE(level, color) (level().nospace() << color << __PRETTY_FUNCTION__ << _DMRESET ":").space()
0016 
0017 // Simple macros to get KDebug like support
0018 #define DMDEBUG _DMTRACE(qDebug, _DMBLUE)
0019 #define DMWARNING _DMTRACE(qWarning, _DMRED)
0020 
0021 // Log a variable name and value
0022 #define DMVAR(var) DMDEBUG << #var ":" << var
0023 
0024 #define DMRETURN_IF_FAIL(cond)                                                                                                                                 \
0025     if (!(cond)) {                                                                                                                                             \
0026         DMWARNING << "Condition failed: " #cond;                                                                                                               \
0027         return;                                                                                                                                                \
0028     }
0029 
0030 #define DMRETURN_VALUE_IF_FAIL(cond, value)                                                                                                                    \
0031     if (!(cond)) {                                                                                                                                             \
0032         DMWARNING << "Condition failed: " #cond;                                                                                                               \
0033         return (value);                                                                                                                                        \
0034     }
0035 
0036 #endif /* DEBUG_P_H */