diff --git a/CMakeLists.txt b/CMakeLists.txt
index 450a1d4fa3..200d3423b7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -400,6 +400,7 @@ set(kwin_KDEINIT_SRCS
scripting/scripting_model.cpp
scripting/dbuscall.cpp
scripting/screenedgeitem.cpp
+ scripting/scripting_logging.cpp
decorations/decoratedclient.cpp
decorations/decorationbridge.cpp
decorations/decorationpalette.cpp
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 2af68ad87d..ea638ebdde 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -141,6 +141,7 @@ set( testScriptedEffectLoader_SRCS
../effectloader.cpp
../scripting/scriptedeffect.cpp
../scripting/scriptingutils.cpp
+ ../scripting/scripting_logging.cpp
)
add_executable( testScriptedEffectLoader ${testScriptedEffectLoader_SRCS})
diff --git a/autotests/test_scripted_effectloader.cpp b/autotests/test_scripted_effectloader.cpp
index 532c085dcb..37d18cc9bd 100644
--- a/autotests/test_scripted_effectloader.cpp
+++ b/autotests/test_scripted_effectloader.cpp
@@ -36,6 +36,7 @@ Q_DECLARE_METATYPE(KWin::Effect*)
Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core")
+
namespace KWin
{
ScreenEdges *ScreenEdges::s_self = nullptr;
diff --git a/data/org_kde_kwin.categories b/data/org_kde_kwin.categories
index 107d59cbde..3e88e37dec 100644
--- a/data/org_kde_kwin.categories
+++ b/data/org_kde_kwin.categories
@@ -11,4 +11,5 @@ kwin_wayland_x11windowed KWin Wayland (X11 backend)
kwin_libinput KWin Libinput Integration
kwin_tabbox KWin Window Switcher
kwin_decorations KWin Decorations
+kwin_scripting KWin Scripting
aurorae KWin Aurorae Window Decoration Engine
diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp
index c4f2be90f7..0c4abc92c0 100644
--- a/scripting/scriptedeffect.cpp
+++ b/scripting/scriptedeffect.cpp
@@ -23,12 +23,12 @@ along with this program. If not, see .
#include "scriptingutils.h"
#include "workspace_wrapper.h"
#include "../screenedge.h"
+#include "scripting_logging.h"
// KDE
#include
#include
#include
// Qt
-#include
#include
#include
#include
@@ -49,7 +49,7 @@ QScriptValue kwinEffectScriptPrint(QScriptContext *context, QScriptEngine *engin
}
result.append(context->argument(i).toString());
}
- qDebug() << script->scriptFile() << ":" << result;
+ qCDebug(KWIN_SCRIPTING) << script->scriptFile() << ":" << result;
return engine->undefinedValue();
}
@@ -377,7 +377,7 @@ void fpx2FromScriptValue(const QScriptValue &value, KWin::FPx2 &fpx2)
QScriptValue value1 = value.property(QStringLiteral("value1"));
QScriptValue value2 = value.property(QStringLiteral("value2"));
if (!value1.isValid() || !value2.isValid() || !value1.isNumber() || !value2.isNumber()) {
- qDebug() << "Cannot cast scripted FPx2 to C++";
+ qCDebug(KWIN_SCRIPTING) << "Cannot cast scripted FPx2 to C++";
fpx2 = FPx2();
return;
}
@@ -390,13 +390,13 @@ ScriptedEffect *ScriptedEffect::create(const KPluginMetaData &effect)
const QString name = effect.pluginId();
const QString scriptName = effect.value(QStringLiteral("X-Plasma-MainScript"));
if (scriptName.isEmpty()) {
- qDebug() << "X-Plasma-MainScript not set";
+ qCDebug(KWIN_SCRIPTING) << "X-Plasma-MainScript not set";
return nullptr;
}
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QStringLiteral(KWIN_NAME) + QStringLiteral("/effects/") + name + QStringLiteral("/contents/") + scriptName);
if (scriptFile.isNull()) {
- qDebug() << "Could not locate the effect script";
+ qCDebug(KWIN_SCRIPTING) << "Could not locate the effect script";
return nullptr;
}
return ScriptedEffect::create(name, scriptFile, effect.value(QStringLiteral("X-KDE-Ordering")).toInt());
@@ -431,7 +431,7 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
{
QFile scriptFile(pathToScript);
if (!scriptFile.open(QIODevice::ReadOnly)) {
- qDebug() << "Could not open script file: " << pathToScript;
+ qCDebug(KWIN_SCRIPTING) << "Could not open script file: " << pathToScript;
return false;
}
m_effectName = effectName;
@@ -508,13 +508,13 @@ void ScriptedEffect::animationEnded(KWin::EffectWindow *w, Attribute a, uint met
void ScriptedEffect::signalHandlerException(const QScriptValue &value)
{
if (value.isError()) {
- qDebug() << "KWin Effect script encountered an error at [Line " << m_engine->uncaughtExceptionLineNumber() << "]";
- qDebug() << "Message: " << value.toString();
+ qCDebug(KWIN_SCRIPTING) << "KWin Effect script encountered an error at [Line " << m_engine->uncaughtExceptionLineNumber() << "]";
+ qCDebug(KWIN_SCRIPTING) << "Message: " << value.toString();
QScriptValueIterator iter(value);
while (iter.hasNext()) {
iter.next();
- qDebug() << " " << iter.name() << ": " << iter.value().toString();
+ qCDebug(KWIN_SCRIPTING) << " " << iter.name() << ": " << iter.value().toString();
}
}
}
diff --git a/scripting/scripting.cpp b/scripting/scripting.cpp
index a32ba49378..8e32968be3 100644
--- a/scripting/scripting.cpp
+++ b/scripting/scripting.cpp
@@ -27,6 +27,7 @@ along with this program. If not, see .
#include "workspace_wrapper.h"
#include "screenedgeitem.h"
#include "scripting_model.h"
+#include "scripting_logging.h"
#include "../client.h"
#include "../thumbnailitem.h"
#include "../options.h"
@@ -81,7 +82,7 @@ QScriptValue kwinScriptReadConfig(QScriptContext *context, QScriptEngine *engine
return engine->undefinedValue();
}
if (context->argumentCount() < 1 || context->argumentCount() > 2) {
- qDebug() << "Incorrect number of arguments";
+ qCDebug(KWIN_SCRIPTING) << "Incorrect number of arguments";
return engine->undefinedValue();
}
const QString key = context->argument(0).toString();
@@ -238,7 +239,7 @@ void KWin::AbstractScript::stop()
void KWin::AbstractScript::printMessage(const QString &message)
{
- qDebug() << scriptFile().fileName() << ":" << message;
+ qCDebug(KWIN_SCRIPTING) << scriptFile().fileName() << ":" << message;
emit print(message);
}
@@ -310,7 +311,7 @@ int KWin::AbstractScript::registerCallback(QScriptValue value)
void KWin::AbstractScript::slotPendingDBusCall(QDBusPendingCallWatcher* watcher)
{
if (watcher->isError()) {
- qDebug() << "Received D-Bus message is error";
+ qCDebug(KWIN_SCRIPTING) << "Received D-Bus message is error";
watcher->deleteLater();
return;
}
@@ -497,14 +498,14 @@ void KWin::Script::sigException(const QScriptValue& exception)
{
QScriptValue ret = exception;
if (ret.isError()) {
- qDebug() << "defaultscript encountered an error at [Line " << m_engine->uncaughtExceptionLineNumber() << "]";
- qDebug() << "Message: " << ret.toString();
- qDebug() << "-----------------";
+ qCDebug(KWIN_SCRIPTING) << "defaultscript encountered an error at [Line " << m_engine->uncaughtExceptionLineNumber() << "]";
+ qCDebug(KWIN_SCRIPTING) << "Message: " << ret.toString();
+ qCDebug(KWIN_SCRIPTING) << "-----------------";
QScriptValueIterator iter(ret);
while (iter.hasNext()) {
iter.next();
- qDebug() << " " << iter.name() << ": " << iter.value().toString();
+ qCDebug(KWIN_SCRIPTING) << " " << iter.name() << ": " << iter.value().toString();
}
}
emit printError(exception.toString());
@@ -553,7 +554,7 @@ void KWin::DeclarativeScript::run()
void KWin::DeclarativeScript::createComponent()
{
if (m_component->isError()) {
- qDebug() << "Component failed to load: " << m_component->errors();
+ qCDebug(KWIN_SCRIPTING) << "Component failed to load: " << m_component->errors();
} else {
if (QObject *object = m_component->create(m_context)) {
object->setParent(this);
@@ -685,7 +686,7 @@ LoadScriptList KWin::Scripting::queryScriptsToLoad()
const QString scriptName = service.value(QStringLiteral("X-Plasma-MainScript"));
const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, scriptFolder + pluginName + QStringLiteral("/contents/") + scriptName);
if (file.isNull()) {
- qDebug() << "Could not find script file for " << pluginName;
+ qCDebug(KWIN_SCRIPTING) << "Could not find script file for " << pluginName;
continue;
}
scriptsToLoad << qMakePair(javaScript, qMakePair(file, pluginName));
diff --git a/scripting/scripting_logging.cpp b/scripting/scripting_logging.cpp
new file mode 100644
index 0000000000..b084f606fa
--- /dev/null
+++ b/scripting/scripting_logging.cpp
@@ -0,0 +1,21 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2015 Martin Gräßlin
+
+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, see .
+*********************************************************************/
+#include "scripting_logging.h"
+Q_LOGGING_CATEGORY(KWIN_SCRIPTING, "kwin_scripting", QtCriticalMsg);
diff --git a/scripting/scripting_logging.h b/scripting/scripting_logging.h
new file mode 100644
index 0000000000..349af623a0
--- /dev/null
+++ b/scripting/scripting_logging.h
@@ -0,0 +1,26 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2015 Martin Gräßlin
+
+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, see .
+*********************************************************************/
+#ifndef KWIN_SCRIPTING_LOGGING_H
+#define KWIN_SCRIPTING_LOGGING_H
+#include
+#include
+Q_DECLARE_LOGGING_CATEGORY(KWIN_SCRIPTING)
+
+#endif
diff --git a/scripting/scriptingutils.h b/scripting/scriptingutils.h
index 4d0d3f93c0..d1e74cd4af 100644
--- a/scripting/scriptingutils.h
+++ b/scripting/scriptingutils.h
@@ -24,11 +24,11 @@ along with this program. If not, see .
#include "input.h"
#include "workspace.h"
#include "screenedge.h"
+#include "scripting_logging.h"
#include
#include
#include
-#include
#include
namespace KWin
@@ -110,7 +110,7 @@ QScriptValue globalShortcut(QScriptContext *context, QScriptEngine *engine)
return engine->undefinedValue();
}
if (context->argumentCount() != 4) {
- qDebug() << "Incorrect number of arguments! Expected: title, text, keySequence, callback";
+ qCDebug(KWIN_SCRIPTING) << "Incorrect number of arguments! Expected: title, text, keySequence, callback";
return engine->undefinedValue();
}
QAction* a = new QAction(script);