From aea6cbfa9d96f3f76bbc3b81362c54c9322b3fcb Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 31 Jan 2013 18:23:59 +0100 Subject: Remove global log sink. Applications may not want to use the same log sink for all builds. The logging facility is also decoupled from the command-line client in other ways: - The LogWriter modifiers for output channel and text color are gone, since this type of decision should not be made by low-level code. Instead, the "highlight" string can be forwarded to the log sink. - The console logger now lives in app/shared, as it must never be used by library code. Change-Id: I8863a554c9b74577320ef23f6f934a74e0f0cbb0 Reviewed-by: Joerg Bornemann --- tests/auto/buildgraph/buildgraph.pro | 5 +++-- tests/auto/buildgraph/tst_buildgraph.cpp | 3 ++- tests/auto/language/language.pro | 5 +++-- tests/auto/language/tst_language.cpp | 5 +++-- tests/auto/language/tst_language.h | 3 +-- tests/auto/tools/tools.pro | 5 +++-- tests/auto/tools/tst_tools.cpp | 19 +++++++++++++------ 7 files changed, 28 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/auto/buildgraph/buildgraph.pro b/tests/auto/buildgraph/buildgraph.pro index 31255e088..2e9dc3bdf 100644 --- a/tests/auto/buildgraph/buildgraph.pro +++ b/tests/auto/buildgraph/buildgraph.pro @@ -7,10 +7,11 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\" QT = core testlib CONFIG += depend_includepath testcase -include(../../../src/lib/use.pri) - HEADERS += \ tst_buildgraph.h SOURCES += \ tst_buildgraph.cpp + +include(../../../src/lib/use.pri) +include(../../../src/app/shared/logging/logging.pri) diff --git a/tests/auto/buildgraph/tst_buildgraph.cpp b/tests/auto/buildgraph/tst_buildgraph.cpp index b9c2e7354..1d49dd779 100644 --- a/tests/auto/buildgraph/tst_buildgraph.cpp +++ b/tests/auto/buildgraph/tst_buildgraph.cpp @@ -28,6 +28,7 @@ ****************************************************************************/ #include "tst_buildgraph.h" +#include #include #include #include @@ -52,7 +53,7 @@ void TestBuildGraph::cleanupTestCase() static bool cycleDetected(const BuildProductConstPtr &product) { try { - CycleDetector().visitProduct(product); + CycleDetector(ConsoleLogger::instance()).visitProduct(product); return false; } catch (const Error &) { return true; diff --git a/tests/auto/language/language.pro b/tests/auto/language/language.pro index 235e48d52..2e4b599d8 100644 --- a/tests/auto/language/language.pro +++ b/tests/auto/language/language.pro @@ -7,8 +7,6 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\" QT = core testlib CONFIG += depend_includepath testcase -include(../../../src/lib/use.pri) - HEADERS += \ tst_language.h @@ -18,3 +16,6 @@ SOURCES += \ OTHER_FILES += \ $$PWD/testdata/* \ testdata/outerInGroup.qbs + +include(../../../src/lib/use.pri) +include(../../../src/app/shared/logging/logging.pri) diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index e1ff68167..c737b1ccb 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -29,6 +29,7 @@ #include "tst_language.h" +#include #include #include #include @@ -74,8 +75,8 @@ void TestLanguage::initTestCase() { //Logger::instance().setLogSink(new ConsolePrintLogSink); //Logger::instance().setLevel(LoggerTrace); - ScriptEngine *engine = new ScriptEngine(this); - loader = new Loader(engine, m_settings.data()); + ScriptEngine *engine = new ScriptEngine(ConsoleLogger::instance(), this); + loader = new Loader(engine, m_settings.data(), ConsoleLogger::instance()); loader->setSearchPaths(QStringList() << QLatin1String(SRCDIR "../../../share/qbs") << QLatin1String(SRCDIR "testdata")); diff --git a/tests/auto/language/tst_language.h b/tests/auto/language/tst_language.h index 02112c74e..831eebaf6 100644 --- a/tests/auto/language/tst_language.h +++ b/tests/auto/language/tst_language.h @@ -33,12 +33,11 @@ #include #include #include -#include -#include #include #include using namespace qbs; +using namespace Internal; class TestLanguage : public QObject { diff --git a/tests/auto/tools/tools.pro b/tests/auto/tools/tools.pro index 86ba74340..43719a2f0 100644 --- a/tests/auto/tools/tools.pro +++ b/tests/auto/tools/tools.pro @@ -7,8 +7,9 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\" QT = core testlib CONFIG += depend_includepath testcase +SOURCES += tst_tools.cpp ../../../src/app/qbs/qbstool.cpp + include(../../../src/lib/use.pri) include(../../../qbs_version.pri) include(../../../src/app/qbs/parser/parser.pri) - -SOURCES += tst_tools.cpp ../../../src/app/qbs/qbstool.cpp +include(../../../src/app/shared/logging/logging.pri) diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp index 658754d01..3bd21f990 100644 --- a/tests/auto/tools/tst_tools.cpp +++ b/tests/auto/tools/tst_tools.cpp @@ -28,8 +28,8 @@ ****************************************************************************/ #include +#include #include -#include #include #include #include @@ -41,12 +41,19 @@ #include using namespace qbs; +using namespace Internal; static SettingsPtr settings = qbsSettings(); class TestTools : public QObject { Q_OBJECT +public: + TestTools() + { + ConsoleLogger::instance().logSink()->setEnabled(false); + } + private slots: void testValidCommandLine() { @@ -62,7 +69,7 @@ private slots: CommandLineParser parser; QVERIFY(parser.parseCommandLine(args, settings.data())); - QCOMPARE(Logger::instance().level(), LoggerTrace); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerTrace); QCOMPARE(parser.command(), BuildCommandType); QCOMPARE(parser.products(), QStringList() << "blubb"); QCOMPARE(parser.buildOptions().changedFiles.count(), 2); @@ -70,18 +77,18 @@ private slots: QVERIFY(parser.force()); QVERIFY(parser.parseCommandLine(QStringList() << "-vvvqqq" << fileArgs, settings.data())); - QCOMPARE(Logger::instance().level(), Logger::defaultLevel()); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), defaultLogLevel()); QVERIFY(!parser.force()); QVERIFY(parser.parseCommandLine(QStringList() << "-vvqqq" << fileArgs, settings.data())); - QCOMPARE(Logger::instance().level(), LoggerWarning); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerWarning); QVERIFY(parser.parseCommandLine(QStringList() << "-vvvqq" << fileArgs, settings.data())); - QCOMPARE(Logger::instance().level(), LoggerDebug); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerDebug); QVERIFY(parser.parseCommandLine(QStringList() << "--log-level" << "trace" << fileArgs, settings.data())); - QCOMPARE(Logger::instance().level(), LoggerTrace); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerTrace); } void testInvalidCommandLine() -- cgit v1.2.1