#include <QtCore/qurl.h>
#include <QtCore/qfile.h>
#include <QtCore/qcoreapplication.h>
+#include <QtCore/qloggingcategory.h>
QT_BEGIN_NAMESPACE
result.append(jsStack(v4));
}
+ static QLoggingCategory loggingCategory("qml");
QV4::StackFrame frame = v4->currentStackFrame();
const QByteArray baSource = frame.source.toUtf8();
const QByteArray baFunction = frame.function.toUtf8();
- QMessageLogger logger(baSource.constData(), frame.line, baFunction.constData());
+ QMessageLogger logger(baSource.constData(), frame.line, baFunction.constData(), loggingCategory.categoryName());
+
switch (logType) {
case Log:
- logger.debug("%s", qPrintable(result));
+ if (loggingCategory.isDebugEnabled())
+ logger.debug("%s", result.toUtf8().constData());
break;
case Warn:
- logger.warning("%s", qPrintable(result));
+ if (loggingCategory.isWarningEnabled())
+ logger.warning("%s", result.toUtf8().constData());
break;
case Error:
- logger.critical("%s", qPrintable(result));
+ if (loggingCategory.isCriticalEnabled())
+ logger.critical("%s", result.toUtf8().constData());
break;
default:
break;
m_eventLoop.quit();
continue;
}
- } else if (line.startsWith("qml:")) {
- // ### Can't enable quiet mode because that also suppresses application output
- continue; //We don't use these, but they aren't output from the app either
} else {
// set to true if there is output not coming from the debugger
outputFromAppItself = true;
QCOMPARE(testProcess->exitCode(), 0);
QByteArray test_stdout = testProcess->readAllStandardOutput();
QByteArray test_stderr = testProcess->readAllStandardError();
- QByteArray test_stderr_target("Start: testData\nEnd\n");
+ QByteArray test_stderr_target("qml: Start: testData\nqml: End\n");
#ifdef Q_OS_WIN
test_stderr_target.replace('\n', QByteArray("\r\n"));
#endif
#include <QDebug>
#include <QQmlEngine>
#include <QQmlComponent>
+#include <QLoggingCategory>
#include "../../shared/util.h"
class tst_qqmlconsole : public QQmlDataTest
{
QUrl testUrl = testFileUrl("logging.qml");
+ QLoggingCategory loggingCategory("qml");
+ QVERIFY(loggingCategory.isDebugEnabled());
+ QVERIFY(loggingCategory.isWarningEnabled());
+ QVERIFY(loggingCategory.isCriticalEnabled());
+
QTest::ignoreMessage(QtDebugMsg, "console.debug");
QTest::ignoreMessage(QtDebugMsg, "console.log");
QTest::ignoreMessage(QtDebugMsg, "console.info");