[scripting] Add dedicated logging category

master
Martin Gräßlin 9 years ago
parent 09880d1267
commit bffbbce172

@ -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

@ -141,6 +141,7 @@ set( testScriptedEffectLoader_SRCS
../effectloader.cpp
../scripting/scriptedeffect.cpp
../scripting/scriptingutils.cpp
../scripting/scripting_logging.cpp
)
add_executable( testScriptedEffectLoader ${testScriptedEffectLoader_SRCS})

@ -36,6 +36,7 @@ Q_DECLARE_METATYPE(KWin::Effect*)
Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core")
namespace KWin
{
ScreenEdges *ScreenEdges::s_self = nullptr;

@ -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

@ -23,12 +23,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "scriptingutils.h"
#include "workspace_wrapper.h"
#include "../screenedge.h"
#include "scripting_logging.h"
// KDE
#include <KConfigGroup>
#include <kconfigloader.h>
#include <KPluginMetaData>
// Qt
#include <QDebug>
#include <QFile>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptValueIterator>
@ -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();
}
}
}

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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));

@ -0,0 +1,21 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2015 Martin Gräßlin <mgraesslin@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, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "scripting_logging.h"
Q_LOGGING_CATEGORY(KWIN_SCRIPTING, "kwin_scripting", QtCriticalMsg);

@ -0,0 +1,26 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2015 Martin Gräßlin <mgraesslin@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, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_SCRIPTING_LOGGING_H
#define KWIN_SCRIPTING_LOGGING_H
#include <QDebug>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(KWIN_SCRIPTING)
#endif

@ -24,11 +24,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "input.h"
#include "workspace.h"
#include "screenedge.h"
#include "scripting_logging.h"
#include <KGlobalAccel>
#include <KLocalizedString>
#include <QAction>
#include <QDebug>
#include <QtScript/QScriptEngine>
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);

Loading…
Cancel
Save