| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSENSORLOG_P_H |
| 5 | #define QSENSORLOG_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/private/qglobal_p.h> |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | #ifdef ENABLE_RUNTIME_SENSORLOG |
| 23 | |
| 24 | static bool logEnabled() |
| 25 | { |
| 26 | static int state = -1; |
| 27 | |
| 28 | if (state == -1) { |
| 29 | QByteArray sensorlog = qgetenv(varName: "SENSORLOG" ); |
| 30 | if (sensorlog == "1" ) |
| 31 | state = 1; |
| 32 | else |
| 33 | state = 0; |
| 34 | } |
| 35 | |
| 36 | return state; |
| 37 | } |
| 38 | |
| 39 | #define SENSORLOG() if (!logEnabled()); else qDebug() |
| 40 | |
| 41 | #else |
| 42 | |
| 43 | // Do nothing (compiles to almost nothing) |
| 44 | #define SENSORLOG() if (1); else qDebug() |
| 45 | |
| 46 | #endif |
| 47 | |
| 48 | QT_END_NAMESPACE |
| 49 | |
| 50 | #endif |
| 51 | |
| 52 | |