QMessageLogContext fields (for example: file, function, string) are empty or null

I have 2 Debian 7.8 64/32 bit machines. I am creating a simple program. In main.cpp:

void action(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    static QFile logFile("logfile.log");
    static QTextStream ts(&logFile);
    if(logFile.open(QFile::ReadWrite | QFile::Append))
    {
      ts << context.file << ":" << context.line << ":"
         << context.function << ": " << msg << endl;
      logFile.close();
    }
}

int main(int argc, char* argv[])
{
    QCoreApplication app(argc, argv);
    qInstallMessageHandler(action);
    qDebug() << "this is some log";
    return app.exec();
}

In "logfile.log" I should see:

main.cpp:30:int main(int, char**): this is some log 

but on Debian 7.8 64-bit Qt 5.4.1 GCC 4.6.1 64 bit I just see:

:0:: this is some log 

I also tested on Debian 7.8 the 32-bit Qt 5.3.1 GCC 4.6.1 32-bit. It works well. Is this a Qt 5.4.1 (64 bit) error? Or am I missing something?
Can you help me?

+4
source share
1 answer

, . Qt . , QT_MESSAGELOGCONTEXT, .

+6

All Articles