Commit 256c5f4c authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Default to disabled debug log on Q_LOGGING_CATEGORY calls

This removes the need to call QLoggingCategory::setFilterRules()
in the program code to default to disabled debug type log
without any other settings.
The latter has disadvantages, as it shadows any settings done
in qtlogging.ini config files by the user
(e.g. via kdebugsettings), thus enabling runtime control only
via QT_LOGGING_CONF/QT_LOGGING_RULES, which is not that
comfortable with lots of categories.

Also use ECMQtDeclareLoggingCategory for less manual code

While there can be some inconsistency with the default disabled
log categories by ECMQtDeclareLoggingCategory, which
switched to QtInfoMsg for ECM 5.26 (when KF5 5.26 has Qt 5.5
as min dep, which is the Qt version QtInfoMsg was added),
current KDevPlatform code has Qt 5.4 as minimum version and
thus also does not use qCInfo, so KDevPlatform behaviour should
be the same across used Qt versions.
parent f9eee849
......@@ -9,7 +9,7 @@ set( KDEVELOP_VERSION "${KDEVELOP_VERSION_MAJOR}.${KDEVELOP_VERSION_MINOR}.${KDE
project(KDevelop)
# we need some parts of the ECM CMake helpers
find_package (ECM 0.0.9 REQUIRED NO_MODULE)
find_package (ECM 5.14.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${KDevelop_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH})
include(KDECompilerSettings NO_POLICY_SCOPE) # needs to be first, as set policies influence following macros
......@@ -21,6 +21,7 @@ include(ECMAddTests)
include(ECMMarkNonGuiExecutable)
include(ECMGenerateHeaders)
include(ECMPackageConfigHelpers)
include(ECMQtDeclareLoggingCategory)
include(CTest)
include(GenerateExportHeader)
......
......@@ -8,6 +8,30 @@ set_package_properties(Cppcheck PROPERTIES
TYPE RUNTIME
)
set(kdevcppcheck_core_SRCS
parser.cpp
job.cpp
parameters.cpp
utils.cpp
)
ecm_qt_declare_logging_category(kdevcppcheck_core_SRCS
HEADER debug.h
IDENTIFIER KDEV_CPPCHECK
CATEGORY_NAME "kdevelop.analyzers.cppcheck"
)
kconfig_add_kcfg_files(kdevcppcheck_core_SRCS
config/globalsettings.kcfgc
config/projectsettings.kcfgc
)
add_library(kdevcppcheck_core STATIC
${kdevcppcheck_core_SRCS}
)
target_link_libraries(kdevcppcheck_core
KDev::Language
KDev::Project
KDev::Shell
)
set(kdevcppcheck_SRCS
plugin.cpp
problemmodel.cpp
......@@ -22,24 +46,6 @@ ki18n_wrap_ui(kdevcppcheck_SRCS
qt5_add_resources(kdevcppcheck_SRCS
kdevcppcheck.qrc
)
kconfig_add_kcfg_files(kdevcppcheck_CONFIG_SRCS
config/globalsettings.kcfgc
config/projectsettings.kcfgc
)
add_library(kdevcppcheck_core STATIC
debug.cpp
parser.cpp
job.cpp
parameters.cpp
utils.cpp
${kdevcppcheck_CONFIG_SRCS}
)
target_link_libraries(kdevcppcheck_core
KDev::Language
KDev::Project
KDev::Shell
)
kdevplatform_add_plugin(kdevcppcheck
JSON kdevcppcheck.json
SOURCES ${kdevcppcheck_SRCS}
......
/*************************************************************************************
* Copyright (C) 2014 by Kevin Funk <kfunk@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "debug.h"
Q_LOGGING_CATEGORY(KDEV_CPPCHECK, "kdevelop.analyzers.cppcheck")
/*************************************************************************************
* Copyright (C) 2014 by Kevin Funk <kfunk@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef CPPCHECK_DEBUG_H
#define CPPCHECK_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(KDEV_CPPCHECK)
#endif
......@@ -16,7 +16,6 @@ set_package_properties(heaptrack_gui PROPERTIES
)
set(kdevheaptrack_SRCS
debug.cpp
job.cpp
plugin.cpp
utils.cpp
......@@ -24,6 +23,11 @@ set(kdevheaptrack_SRCS
config/globalconfigpage.cpp
)
ecm_qt_declare_logging_category(kdevheaptrack_SRCS
HEADER debug.h
IDENTIFIER KDEV_HEAPTRACK
CATEGORY_NAME "kdevelop.analyzers.heaptrack"
)
ki18n_wrap_ui(kdevheaptrack_SRCS
config/globalconfigpage.ui
)
......
/* This file is part of KDevelop
Copyright 2017 Anton Anikin <anton.anikin@htower.ru>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "debug.h"
Q_LOGGING_CATEGORY(KDEV_HEAPTRACK, "kdevelop.analyzers.heaptrack")
/* This file is part of KDevelop
Copyright 2017 Anton Anikin <anton.anikin@htower.ru>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#pragma once
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(KDEV_HEAPTRACK)
......@@ -21,6 +21,11 @@ if(KDEVELOP_SINGLE_APP)
set(kdevelop_SRCS ${kdevelop_SRCS} ${singleapp_SRCS})
endif()
ecm_qt_declare_logging_category(kdevelop_SRCS
HEADER debug.h
IDENTIFIER APP
CATEGORY_NAME "kdevelop.app"
)
qt5_add_resources(kdevelop_SRCS kdevelop.qrc)
#TODO: remove CMAKE_CURRENT_SOURCE_DIR prefix when ECM is fixed
......
......@@ -47,10 +47,6 @@
#include <QTextStream>
#include <QDBusInterface>
#include <QDBusReply>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(APP)
Q_LOGGING_CATEGORY(APP, "kdevelop.app")
#include <shell/core.h>
#include <shell/mainwindow.h>
......@@ -65,6 +61,7 @@ Q_LOGGING_CATEGORY(APP, "kdevelop.app")
#include <interfaces/iproject.h>
#include <interfaces/launchconfigurationtype.h>
#include <util/path.h>
#include <debug.h>
#include "kdevideextension.h"
#if KDEVELOP_SINGLE_APP
......
......@@ -6,7 +6,6 @@ set(debuggercommon_SRCS
mi/micommand.cpp
mi/micommandqueue.cpp
dialogs/selectcoredialog.cpp
debuglog.cpp
# debug session & debugger
midebugger.cpp
midebugsession.cpp
......@@ -37,6 +36,12 @@ if(KF5SysGuard_FOUND)
)
endif()
ecm_qt_declare_logging_category(debuggercommon_SRCS
HEADER debuglog.h
IDENTIFIER DEBUGGERCOMMON
CATEGORY_NAME "kdevelop.debuggers.common"
)
ki18n_wrap_ui(debuggercommon_SRCS
dialogs/selectcoredialog.ui
widgets/debuggerconsoleview.ui
......
/*
* KDevelop debugger logging facilities
*
* Copyright 2016 Aetf <aetf@unlimitedcodeworks.xyz>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "debuglog.h"
Q_LOGGING_CATEGORY(DEBUGGERCOMMON, "kdevelop.debuggers.common")
Q_LOGGING_CATEGORY(DEBUGGERGDB, "kdevelop.debuggers.gdb")
Q_LOGGING_CATEGORY(DEBUGGERLLDB, "kdevelop.debuggers.lldb")
/*
* KDevelop debugger logging facilities
*
* Copyright 2016 Aetf <aetf@unlimitedcodeworks.xyz>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef KDEVELOP_DEBUG_LOG_H
#define KDEVELOP_DEBUG_LOG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(DEBUGGERCOMMON)
Q_DECLARE_LOGGING_CATEGORY(DEBUGGERGDB)
Q_DECLARE_LOGGING_CATEGORY(DEBUGGERLLDB)
#endif
......@@ -29,6 +29,11 @@ endif()
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-gdb-plugin.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-gdb-plugin.h )
ecm_qt_declare_logging_category(kdevgdb_SRCS
HEADER debuglog.h
IDENTIFIER DEBUGGERGDB
CATEGORY_NAME "kdevelop.debuggers.gdb"
)
set(kdevgdb_UI
debuggertracingdialog.ui
gdbconfigpage.ui
......
......@@ -181,9 +181,9 @@ void DebugSession::configInferior(ILaunchConfiguration *cfg, IExecutePlugin *iex
const EnvironmentProfileList environmentProfiles(KSharedConfig::openConfig());
QString envProfileName = iexec->environmentProfileName(cfg);
if (envProfileName.isEmpty()) {
qCWarning(DEBUGGERCOMMON) << i18n("No environment profile specified, looks like a broken "
"configuration, please check run configuration '%1'. "
"Using default environment profile.", cfg->name());
qCWarning(DEBUGGERGDB) << i18n("No environment profile specified, looks like a broken "
"configuration, please check run configuration '%1'. "
"Using default environment profile.", cfg->name());
envProfileName = environmentProfiles.defaultProfileName();
}
for (const auto &envvar : environmentProfiles.createEnvironment(envProfileName, {})) {
......
......@@ -13,6 +13,12 @@ set(kdevlldb_SRCS
lldblauncher.cpp
)
ecm_qt_declare_logging_category(kdevlldb_SRCS
HEADER debuglog.h
IDENTIFIER DEBUGGERLLDB
CATEGORY_NAME "kdevelop.debuggers.lldb"
)
set(kdevlldb_UI
widgets/lldbconfigpage.ui
)
......
......@@ -226,9 +226,9 @@ void DebugSession::configInferior(ILaunchConfiguration *cfg, IExecutePlugin *iex
const EnvironmentProfileList environmentProfiles(KSharedConfig::openConfig());
QString envProfileName = iexec->environmentProfileName(cfg);
if (envProfileName.isEmpty()) {
qCWarning(DEBUGGERCOMMON) << i18n("No environment profile specified, looks like a broken "
"configuration, please check run configuration '%1'. "
"Using default environment profile.", cfg->name());
qCWarning(DEBUGGERLLDB) << i18n("No environment profile specified, looks like a broken "
"configuration, please check run configuration '%1'. "
"Using default environment profile.", cfg->name());
envProfileName = environmentProfiles.defaultProfileName();
}
QStringList vars;
......@@ -262,12 +262,12 @@ void DebugSession::configInferior(ILaunchConfiguration *cfg, IExecutePlugin *iex
setDebuggerStateOn(s_dbgBusy);
raiseEvent(debugger_ready);
qCDebug(DEBUGGERGDB) << "Per inferior configuration done";
qCDebug(DEBUGGERLLDB) << "Per inferior configuration done";
}
bool DebugSession::execInferior(ILaunchConfiguration *cfg, IExecutePlugin *, const QString &)
{
qCDebug(DEBUGGERGDB) << "Executing inferior";
qCDebug(DEBUGGERLLDB) << "Executing inferior";
KConfigGroup grp = cfg->config();
......
add_definitions(-DTRANSLATION_DOMAIN=\"kdevqthelp\")
ecm_qt_declare_logging_category(kdevqthelp_LOG_SRCS
HEADER debug.h
IDENTIFIER QTHELP
CATEGORY_NAME "kdevelop.documentation.qthelp"
)
set(kdevqthelp_SRCS
qthelpplugin.cpp
qthelpproviderabstract.cpp
......@@ -7,8 +12,8 @@ set(kdevqthelp_SRCS
qthelpdocumentation.cpp
qthelpqtdoc.cpp
qthelp_config_shared.cpp
debug.cpp
qthelpconfig.cpp # Configuration module for QtHelp plugin
${kdevqthelp_LOG_SRCS}
)
ki18n_wrap_ui(kdevqthelp_SRCS
......
#include "debug.h"
Q_LOGGING_CATEGORY(QTHELP, "kdevelop.documentation.qthelp")
#ifndef KDEVELOP_QTHELP_DEBUG_H
#define KDEVELOP_QTHELP_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(QTHELP)
#endif
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
configure_file(testqthelpconfig.h.in testqthelpconfig.h)
set(test_qthelpplugin_SRCS
......@@ -8,8 +10,8 @@ set(test_qthelpplugin_SRCS
../qthelpdocumentation.cpp
../qthelpqtdoc.cpp
../qthelp_config_shared.cpp
../debug.cpp
../qthelpconfig.cpp
${kdevqthelp_LOG_SRCS}
)
ki18n_wrap_ui(test_qthelpplugin_SRCS
../qthelpconfig.ui
......
include_directories(lib)
ecm_qt_declare_logging_category(kdevastyle_LOG_SRCS
HEADER debug.h
IDENTIFIER KDEV_ASTYLE
CATEGORY_NAME "kdevelop.formatters.astyle"
)
set(kdevastyle_PART_SRCS
astyle_plugin.cpp
astyle_preferences.cpp
astyle_formatter.cpp
astyle_stringiterator.cpp
debug.cpp
${kdevastyle_LOG_SRCS}
)
set(astyle_preferences_UI
......
......@@ -60,7 +60,7 @@ void AStyleFormatter::setOption(const QString &key, const QVariant &value)
void AStyleFormatter::updateFormatter()
{
qCDebug(ASTYLE) << "Updating option with: " << ISourceFormatter::optionMapToString(m_options) << endl;
qCDebug(KDEV_ASTYLE) << "Updating option with: " << ISourceFormatter::optionMapToString(m_options) << endl;
// fill
int wsCount = m_options[QStringLiteral("FillCount")].toInt();
if(m_options[QStringLiteral("Fill")].toString() == QLatin1String("Tabs")) {
......@@ -309,7 +309,7 @@ bool AStyleFormatter::predefinedStyle( const QString & style )
QVariant AStyleFormatter::option(const QString &key)
{
if(!m_options.contains(key))
qCDebug(ASTYLE) << "Missing option name " << key << endl;
qCDebug(KDEV_ASTYLE) << "Missing option name " << key << endl;
return m_options[key];
}
......
#include "debug.h"
Q_LOGGING_CATEGORY(ASTYLE, "kdevelop.formatters.astyle")
#ifndef KDEVELOP_ASTYLE_DEBUG_H
#define KDEVELOP_ASTYLE_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(ASTYLE)
#endif
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
set(test_astyle_SRCS test_astyle.cpp
../astyle_formatter.cpp
../astyle_stringiterator.cpp
../debug.cpp
${kdevastyle_LOG_SRCS}
)
ecm_add_test(${test_astyle_SRCS}
......
......@@ -3,6 +3,11 @@ set(kdevcustomscript_PART_SRCS
customscript_plugin.cpp
)
ecm_qt_declare_logging_category(kdevcustomscript_PART_SRCS
HEADER debug.h
IDENTIFIER CUSTOMSCRIPT
CATEGORY_NAME "kdevelop.formatters.customscript"
)
kdevplatform_add_plugin(kdevcustomscript JSON kdevcustomscript.json SOURCES ${kdevcustomscript_PART_SRCS})
target_link_libraries(kdevcustomscript
KDev::Interfaces
......
......@@ -30,9 +30,6 @@
#include <interfaces/isourceformatter.h>
#include <memory>
#include <QDir>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(CUSTOMSCRIPT)
Q_LOGGING_CATEGORY(CUSTOMSCRIPT, "kdevelop.formatters.customscript")
#include <util/formattinghelpers.h>
#include <interfaces/iprojectcontroller.h>
......@@ -44,6 +41,7 @@ Q_LOGGING_CATEGORY(CUSTOMSCRIPT, "kdevelop.formatters.customscript")
#include <interfaces/ilanguagecontroller.h>
#include <language/interfaces/ilanguagesupport.h>
#include <util/path.h>
#include <debug.h>
using namespace KDevelop;
......
......@@ -5,6 +5,11 @@ set(kdevexecuteplasmoid_PART_SRCS
plasmoidexecutionconfig.cpp
plasmoidexecutionjob.cpp
)
ecm_qt_declare_logging_category(kdevexecuteplasmoid_PART_SRCS
HEADER debug.h
IDENTIFIER EXECUTEPLASMOID
CATEGORY_NAME "kdevelop.launchers.executeplasmoid"
)
ki18n_wrap_ui(kdevexecuteplasmoid_PART_SRCS
plasmoidexecutionconfig.ui
)
......
#ifndef KDEVELOP_EXECUTEPLASMOID_DEBUG_H
#define KDEVELOP_EXECUTEPLASMOID_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(EXECUTEPLASMOID)
#endif
......@@ -32,7 +32,6 @@
using namespace KDevelop;
Q_LOGGING_CATEGORY(EXECUTEPLASMOID, "kdevelop.kdeintegration.executeplasmoid")
K_PLUGIN_FACTORY_WITH_JSON(KDevExecutePlasmoidFactory,"kdevexecuteplasmoid.json", registerPlugin<ExecutePlasmoidPlugin>(); )
ExecutePlasmoidPlugin::ExecutePlasmoidPlugin(QObject *parent, const QVariantList&)
......
......@@ -21,8 +21,6 @@
#include "unsavedfile.h"
#include <QDebug>
#include <clang-c/Index.h>
#include <algorithm>
......
......@@ -27,7 +27,12 @@
#include <language/editor/documentcursor.h>
#include <language/editor/documentrange.h>
Q_LOGGING_CATEGORY(KDEV_CLANG, "kdevelop.plugins.clang")
#if QT_VERSION >= 0x050500
const QtMsgType defaultMsgType = QtInfoMsg;
#else
const QtMsgType defaultMsgType = QtWarningMsg;
#endif
Q_LOGGING_CATEGORY(KDEV_CLANG, "kdevelop.languages.clang", defaultMsgType)
using namespace KDevelop;
......
add_definitions(-DTRANSLATION_DOMAIN=\"kdevcustomdefinesandincludes\")
ecm_qt_declare_logging_category(kdevdefinesandincludesmanager_LOG_SRCS
HEADER debug.h
IDENTIFIER DEFINESANDINCLUDES
CATEGORY_NAME "kdevelop.definesandincludes"
)
add_subdirectory(tests)
add_subdirectory(compilerprovider)
add_subdirectory(noprojectincludesanddefines)
set( kdevdefinesandincludesmanager_SRCS
definesandincludesmanager.cpp
debugarea.cpp
kcm_widget/projectpathsmodel.cpp
kcm_widget/definesmodel.cpp
kcm_widget/includesmodel.cpp
......