1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

msghandler: Output log context only when not null

This commit is contained in:
David Rosca 2015-08-18 10:05:16 +02:00
parent f35f17fa96
commit 6a16cff13e

View File

@ -105,16 +105,23 @@ void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString
if (msg.startsWith(QL1S("QSslSocket: cannot resolve SSLv2_"))) if (msg.startsWith(QL1S("QSslSocket: cannot resolve SSLv2_")))
return; return;
QByteArray localMsg = msg.toLocal8Bit(); const QByteArray localMsg = msg.toLocal8Bit();
switch (type) { switch (type) {
case QtDebugMsg: case QtDebugMsg:
case QtWarningMsg: case QtWarningMsg:
case QtCriticalMsg: case QtCriticalMsg:
std::cerr << localMsg.constData() << " (" << context.file << ":" << context.line << ", " << context.function << ")" << std::endl; std::cerr << localMsg.constData();
if (context.file && context.line && context.function)
std::cerr << " (" << context.file << ":" << context.line << ", " << context.function << ")";
std::cerr << std::endl;
break; break;
case QtFatalMsg: case QtFatalMsg:
std::cerr << "Fatal: " << localMsg.constData() << " (" << context.file << ":" << context.line << ", " << context.function << ")" << std::endl; std::cerr << "Fatal: " << localMsg.constData() << std::endl;
if (context.file && context.line && context.function)
std::cerr << " (" << context.file << ":" << context.line << ", " << context.function << ")";
std::cerr << std::endl;
abort(); abort();
default: default: