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 namespace Marble
20{
21 /**
22 * A class which handles Marble debugging messages and settings.
23 *
24 * Use of this class is deprecated. The preferred way to generate
25 * debugging output within Marble is to use Qt categorised logging,
26 * which allows control over the debugging output either via the
27 * Qt configuration files and environment variables or the Plasma
28 * @c kdebugsettings utility.
29
30 * The @c mDebug() macro below logs debug messages under the category
31 * named by @c LOGGING_CATEGORY or, if this is not specified, a
32 * default. In order to use a different logging category for a part
33 * of the Marble source tree, define the logging category for ECM in
34 * the @c CMakeLists.txt file for that part of the tree and then specify
35 * the category to be used by the code, for example:
36 *
37 * @code
38 * ecm_qt_export_logging_category(
39 * IDENTIFIER "MARBLE_SPECIAL"
40 * CATEGORY_NAME "marble_special"
41 * EXPORT marble
42 * DESCRIPTION "Marble (special category)")
43 * add_definitions("-DLOGGING_IDENTIFIER=MARBLE_SPECIAL")
44 * @endcode
45 *
46 * and then messages can be output by using @c qCDebug(MARBLE_SPECIAL)
47 * if @c mDebug() is not being used.
48 *
49 * The logging identifier and category name must also be defined in
50 * the @c MarbleDebug.cpp source file using @c Q_LOGGING_CATEGORY,
51 * otherwise there will be undefined symbols which may not be resolved
52 * until run time.
53 *
54 * ECM will collect together all of the logging definitions and install
55 * the categories file to be use by @c kdebugsettings.
56 *
57 * @see QLoggingCategory
58 */
59 class MARBLE_EXPORT MarbleDebug
60 {
61 public:
62 /**
63 * @brief isEnabled returns whether debug information output is generated
64 */
65 static bool isEnabled();
66
67 /**
68 * @brief setEnabled Toggle debug information output generation
69 * @param enabled Set to true to enable debug output, false to disable
70 */
71 static void setEnabled(bool enabled);
72
73 private:
74 static bool m_enabled;
75 };
76
77/**
78 * A replacement for qDebug() in Marble library code.
79 *
80 * @note This cannot be a function (not even inline), because @c qCDebug()
81 * is itself defined as a macro which captures the source location where
82 * it is called.
83 * @deprecated Use @c qCDebug() with a logging category
84 */
85#define mDebug() qCDebug(LOGGING_IDENTIFIER)
86
87} // namespace Marble
88
89#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 Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.