KDevelop/Debugging

From KDE Community Wiki
Revision as of 16:46, 25 November 2017 by Frinring (talk | contribs) (Created page with "== Debug logging == KDevelop makes use of the categorized logging system from Qt Core (see [http://doc.qt.io/qt-5/qloggingcategory.html#details API documentation of QLoggingC...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Debug logging

KDevelop makes use of the categorized logging system from Qt Core (see API documentation of QLoggingCategory for details).

Definition of logging categories

KDevelop codebase applies the CMake macro ecm_qt_declare_logging_category from Extra CMake Modules to generate the code for defining the categories. Each KDevPlatform library, each plugin and the app all have their own category and for that do in their respective top-level CMakeLists.txt file call the macro with their specific data.

Files in the library, plugin or app module then include that generated header and use the identifier for specifying the category. And in the runtime the user uses the category name to control the logging level.

Example by the KDevPlatform library Sublime:

ecm_qt_declare_logging_category(sublime_LIB_SRCS
    HEADER debug.h
    IDENTIFIER SUBLIME
    CATEGORY_NAME "kdevplatform.sublime"
)
#include <debug.h>

qCDebug(SUBLIME) << "Hello world!";
export QT_LOGGING_RULES="kdevplatform.sublime.debug=true"

Configure logging levels with kdebugsettings

Since version 5.2 KDevelop (and most plugins from the separate repos) installs files which enables to use the UI tool kdebugsettings for controlling the level of logging. kdebugsettings itself is a graphical tool for editing the user's global "qtlogging.ini" configuration file (cmp. details linked above).

Start "kdebugsettings" (needs to be from the commandline, no registration yet to the workspace app menus) and best filter by the string "kdev" to see all the categories of the KDevPlatform modules, the plugins and the app itself.