aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-10-04 15:02:00 +0200
committerEike Ziller <eike.ziller@qt.io>2018-10-05 06:47:25 +0000
commit6e7b88b34cc57120851699782e014f190dabc038 (patch)
tree9ebb873241588b1c65c3a408476f8c1fb84abf3a
parent0f1d1387b60174670180e2578f977098c3cc472a (diff)
Use logging category for debug messages
Change-Id: I895188f12b3f23c6385069de312946720de50bbe Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--plugins/pythonextensions/pythonextensionsplugin.cpp18
-rw-r--r--plugins/pythonextensions/pyutil.cpp19
-rw-r--r--plugins/pythonextensions/pyutil.h5
3 files changed, 24 insertions, 18 deletions
diff --git a/plugins/pythonextensions/pythonextensionsplugin.cpp b/plugins/pythonextensions/pythonextensionsplugin.cpp
index 59b32a1..77024ca 100644
--- a/plugins/pythonextensions/pythonextensionsplugin.cpp
+++ b/plugins/pythonextensions/pythonextensionsplugin.cpp
@@ -189,7 +189,7 @@ void PythonExtensionsPlugin::initializePythonBindings()
PyUtil::addToSysPath(pythonPackagePath().toStdString());
// Initialize the Python context and register global Qt Creator variable
if (!PyUtil::bindCoreModules()) {
- qWarning() << "Python bindings could not be initialized";
+ qCDebug(pyLog) << "Python bindings could not be initialized";
Core::MessageManager::write(Constants::MESSAGE_MANAGER_PREFIX + tr("Python bindings could not be initialized"));
return;
}
@@ -214,7 +214,7 @@ void PythonExtensionsPlugin::initializeOptionalBindings()
QLibrary bindingLib(path + Constants::PY_BINDING_LIB + name);
QFunctionPointer bind = bindingLib.resolve("bind");
if (bind) {
- qDebug() << "Initializing optional bindings for plugin" << name;
+ qCDebug(pyLog) << "Initializing bindings for plugin" << name;
bind();
break;
}
@@ -237,7 +237,7 @@ void PythonExtensionsPlugin::installRequirements()
&& !QFileInfo::exists(extension_requirements + ".installed")) {
if (!PyUtil::pipInstallRequirements(extension_requirements.toStdString(),
pythonPackagePath().toStdString())) {
- qWarning() << "Failed to install requirements for extension" << extension.name;
+ qCDebug(pyLog) << "Failed to install requirements for extension" << extension.name;
Core::MessageManager::write(Constants::MESSAGE_MANAGER_PREFIX
+ tr("Failed to install requirements for extension ")
+ extension.name);
@@ -251,32 +251,32 @@ void PythonExtensionsPlugin::initializePythonExtensions()
// Search python directory in plugin paths
QDir extension_dir = extensionDir();
if (!extension_dir.exists()) {
- qWarning() << "Python extension directory not found";
+ qCDebug(pyLog) << "Python extension directory not found";
Core::MessageManager::write(Constants::MESSAGE_MANAGER_PREFIX + tr("Python extension directory not found"));
return;
}
- qDebug() << "Found Python extension directory at location" << extension_dir.absolutePath();
+ qCDebug(pyLog) << "Found Python extension directory at location" << extension_dir.absolutePath();
QVector<Extension> &extension_list = extensionListRef();
- qDebug() << "Number of Python extensions found:" << extension_list.size();
+ qCDebug(pyLog) << "Number of Python extensions found:" << extension_list.size();
int loadedCount = 0;
// Run the extension initialization code
for (Extension &extension : extension_list) {
- qDebug() << "Trying to initialize extension" << extension.name;
+ qCDebug(pyLog) << "Trying to initialize extension" << extension.name;
if (PyUtil::runScript("import " + extension.name.toStdString())) {
extension.loaded = true;
++loadedCount;
} else {
- qWarning() << "Failed to initialize extension" << extension.name;
+ qCDebug(pyLog) << "Failed to initialize extension" << extension.name;
Core::MessageManager::write(Constants::MESSAGE_MANAGER_PREFIX
+ tr("Failed to initialize extension ") + extension.name);
}
}
- qDebug() << "Number of Python extensions loaded:" << loadedCount;
+ qCDebug(pyLog) << "Number of Python extensions loaded:" << loadedCount;
}
} // namespace Internal
diff --git a/plugins/pythonextensions/pyutil.cpp b/plugins/pythonextensions/pyutil.cpp
index b992e36..fd0d2cd 100644
--- a/plugins/pythonextensions/pyutil.cpp
+++ b/plugins/pythonextensions/pyutil.cpp
@@ -25,13 +25,14 @@
#include "pyutil.h"
+Q_LOGGING_CATEGORY(pyLog, "qtc.pythonextensions")
+
#ifdef Q_OS_UNIX
# include <dlfcn.h> // dlopen
#endif
#include <QtCore/QByteArray>
#include <QtCore/QCoreApplication>
-#include <QtCore/QDebug>
#include <QtCore/QStringList>
#include <QtCore/QTemporaryFile>
#include <QtCore/QDir>
@@ -121,7 +122,7 @@ State init()
} else {
if (pyErrorOccurred)
PyErr_Print();
- qWarning("Failed to initialize the QtCreator module.");
+ qCDebug(pyLog) << "Failed to initialize the QtCreator module.";
}
// The Python interpreter eats SIGINT, which is not what we want.
@@ -129,7 +130,7 @@ State init()
// See https://mail.python.org/pipermail/cplusplus-sig/2012-December/016858.html
if (!runSimpleString("import signal\n"
"signal.signal(signal.SIGINT, signal.SIG_DFL)")) {
- qWarning("Failed to prevent SIGINT capture.");
+ qCDebug(pyLog) << "Failed to prevent SIGINT capture.";
}
return state;
@@ -144,7 +145,7 @@ bool createModule(const std::string &moduleName)
if (!module) {
if (PyErr_Occurred())
PyErr_Print();
- qWarning() << __FUNCTION__ << "Failed to create module";
+ qCDebug(pyLog) << "Failed to create module" << QString::fromStdString(moduleName);
return false;
}
@@ -161,7 +162,7 @@ bool bindObject(const QString &moduleName, const QString &name, int index, void
PyObject *po = Shiboken::Conversions::pointerToPython(reinterpret_cast<SbkObjectType *>(typeObject), o);
if (!po) {
- qWarning() << __FUNCTION__ << "Failed to create wrapper for" << o;
+ qCDebug(pyLog) << "Failed to create wrapper for" << moduleName << name << index;
return false;
}
Py_INCREF(po);
@@ -184,14 +185,14 @@ bool bindPyObject(const QString &moduleName, const QString &name, void *obj)
if (!module) {
if (PyErr_Occurred())
PyErr_Print();
- qWarning() << __FUNCTION__ << "Failed to locate module" << moduleName;
+ qCDebug(pyLog) << "Failed to locate module" << moduleName;
return false;
}
if (PyModule_AddObject(module, name.toLocal8Bit().constData(), (PyObject *)obj) < 0) {
if (PyErr_Occurred())
PyErr_Print();
- qWarning() << __FUNCTION__ << "Failed to add object" << name << "to" << moduleName;
+ qCDebug(pyLog) << "Failed to add object" << name << "to" << moduleName;
return false;
}
@@ -204,14 +205,14 @@ bool bindSubPyObject(const QString &moduleName, const QString &name, void *obj)
if (!moduleDict) {
if (PyErr_Occurred())
PyErr_Print();
- qWarning("Could not obtain module dict");
+ qCDebug(pyLog) << "Could not obtain module dict";
return false;
}
PyObject *moduleItem = PyDict_GetItemString(moduleDict, name.toLocal8Bit().constData());
if (!moduleDict) {
if (PyErr_Occurred())
PyErr_Print();
- qWarning() << "Could not obtain module item" << name;
+ qCDebug(pyLog) << "Could not obtain module item" << name;
return false;
}
return bindPyObject(moduleName, name, (void *)moduleItem);
diff --git a/plugins/pythonextensions/pyutil.h b/plugins/pythonextensions/pyutil.h
index ca58f6e..360a686 100644
--- a/plugins/pythonextensions/pyutil.h
+++ b/plugins/pythonextensions/pyutil.h
@@ -27,11 +27,16 @@
#define PYUTIL_H
#include "pythonextensions_global.h"
+
+#include <QLoggingCategory>
+
#include <string>
class QObject;
class QString;
+Q_DECLARE_LOGGING_CATEGORY(pyLog)
+
namespace PyUtil {
// Note: If modifying the bindings, check these types still align