Marble

MarbleDebug.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Patrick Spendrin <ps_ml@gmx.de>
4//
5
6#ifndef MARBLE_MARBLEDEBUG_H
7#define MARBLE_MARBLEDEBUG_H
8
9#include <QDebug>
10#include <QLoggingCategory>
11
12#include "marble_export.h"
13
14#ifndef LOGGING_IDENTIFIER
15#define LOGGING_IDENTIFIER MARBLE_DEFAULT
16#endif
17MARBLE_EXPORT Q_DECLARE_LOGGING_CATEGORY(LOGGING_IDENTIFIER)
18
19
20namespace Marble
21{
22
23/**
24 * A class which handles Marble debugging messages and settings.
25 *
26 * Use of this class is deprecated. The preferred way to generate
27 * debugging output within Marble is to use Qt categorised logging,
28 * which allows control over the debugging output either via the
29 * Qt configuration files and environment variables or the Plasma
30 * @c kdebugsettings utility.
31
32 * The @c mDebug() macro below logs debug messages under the category
33 * named by @c LOGGING_CATEGORY or, if this is not specified, a
34 * default. In order to use a different logging category for a part
35 * of the Marble source tree, define the logging category for ECM in
36 * the @c CMakeLists.txt file for that part of the tree and then specify
37 * the category to be used by the code, for example:
38 *
39 * @code
40 * ecm_qt_export_logging_category(
41 * IDENTIFIER "MARBLE_SPECIAL"
42 * CATEGORY_NAME "marble_special"
43 * EXPORT marble
44 * DESCRIPTION "Marble (special category)")
45 * add_definitions("-DLOGGING_IDENTIFIER=MARBLE_SPECIAL")
46 * @endcode
47 *
48 * and then messages can be output by using @c qCDebug(MARBLE_SPECIAL)
49 * if @c mDebug() is not being used.
50 *
51 * The logging identifier and category name must also be defined in
52 * the @c MarbleDebug.cpp source file using @c Q_LOGGING_CATEGORY,
53 * otherwise there will be undefined symbols which may not be resolved
54 * until run time.
55 *
56 * ECM will collect together all of the logging definitions and install
57 * the categories file to be use by @c kdebugsettings.
58 *
59 * @see QLoggingCategory
60 */
61class MARBLE_EXPORT MarbleDebug
62{
63public:
64 /**
65 * @brief isEnabled returns whether debug information output is generated
66 */
67 static bool isEnabled();
68
69 /**
70 * @brief setEnabled Toggle debug information output generation
71 * @param enabled Set to true to enable debug output, false to disable
72 */
73 static void setEnabled(bool enabled);
74
75private:
76 static bool m_enabled;
77};
78
79/**
80 * A replacement for qDebug() in Marble library code.
81 *
82 * @note This cannot be a function (not even inline), because @c qCDebug()
83 * is itself defined as a macro which captures the source location where
84 * it is called.
85 * @deprecated Use @c qCDebug() with a logging category
86 */
87#define mDebug() qCDebug(LOGGING_IDENTIFIER)
88
89} // namespace Marble
90
91#endif
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.