summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/init.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-07-18 11:48:56 +0200
committerKai Koehne <kai.koehne@digia.com>2014-07-18 13:25:16 +0200
commit203d53d7228ac67691d761ed482c6185fa6fa580 (patch)
tree69724f55f2021a06fe4ee8e6ec012458fe47fc4d /src/libs/installer/init.cpp
parent5ca8f4d7a4171a1dae355899fb4fa457d34489b1 (diff)
Simplify logging
Let VerboseWriter solely handle logging to the destination file. qt_message_handler takes the role of logging to cout. This allows us to get rid of the twisted stream logic in utils.cpp, and furthermore let us get rid of the buggy debugstream. Change-Id: I5cf2e41b126a90025825a0d93f95b41d783ef22a Task-number: QTIFW-524 Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com> Reviewed-by: Niels Weber <niels.weber@digia.com>
Diffstat (limited to 'src/libs/installer/init.cpp')
-rw-r--r--src/libs/installer/init.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/libs/installer/init.cpp b/src/libs/installer/init.cpp
index 478d77ae8..036a595e1 100644
--- a/src/libs/installer/init.cpp
+++ b/src/libs/installer/init.cpp
@@ -143,29 +143,29 @@ static void initResources()
}
#endif
-static QByteArray trimAndPrepend(QtMsgType type, const QByteArray &msg)
+static QString trimAndPrepend(QtMsgType type, const QString &msg)
{
- QByteArray ba(msg);
+ QString ba(msg);
// last character is a space from qDebug
- if (ba.endsWith(' '))
+ if (ba.endsWith(QLatin1Char(' ')))
ba.chop(1);
// remove quotes if the whole message is surrounded with them
- if (ba.startsWith('"') && ba.endsWith('"'))
+ if (ba.startsWith(QLatin1Char('"')) && ba.endsWith(QLatin1Char('"')))
ba = ba.mid(1, ba.length() - 2);
// prepend the message type, skip QtDebugMsg
switch (type) {
case QtWarningMsg:
- ba.prepend("Warning: ");
+ ba.prepend(QStringLiteral("Warning: "));
break;
case QtCriticalMsg:
- ba.prepend("Critical: ");
+ ba.prepend(QStringLiteral("Critical: "));
break;
case QtFatalMsg:
- ba.prepend("Fatal: ");
+ ba.prepend(QStringLiteral("Fatal: "));
break;
default:
@@ -179,19 +179,18 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
// suppress warning from QPA minimal plugin
if (msg.contains(QLatin1String("This plugin does not support propagateSizeHints")))
return;
- QByteArray ba = trimAndPrepend(type, msg.toLocal8Bit());
+ QString ba = trimAndPrepend(type, msg);
if (type != QtDebugMsg) {
ba += QString(QStringLiteral(" (%1:%2, %3)")).arg(
QString::fromLatin1(context.file)).arg(context.line).arg(
- QString::fromLatin1(context.function)).toLocal8Bit();
+ QString::fromLatin1(context.function));
}
- if (!VerboseWriter::instance())
- return;
+ if (VerboseWriter *log = VerboseWriter::instance())
+ log->appendLine(ba);
- verbose() << ba.constData() << std::endl;
- if (!isVerbose() && type != QtDebugMsg)
- std::cout << ba.constData() << std::endl << std::endl;
+ if (type != QtDebugMsg || isVerbose())
+ std::cout << qPrintable(ba) << std::endl;
if (type == QtFatalMsg) {
QtMessageHandler oldMsgHandler = qInstallMessageHandler(0);