Hi,

I’ve been using qInstallMsgHandler earlier with Harmattan to get debug prints 
from c++ and qml to a file. Now that I’m trying to do the same with Sailfish 
and Qt5 using qInstallMessageHandler, I get only c++ prints to file, qml prints 
are shown in console or qtcreator. Debug printer is installed as first line in 
the main:

 Q_DECL_EXPORT int main(int argc, char * argv[])
{
        qInstallMessageHandler(DebugPrinter);
…

and the debug printer itself is like this:

 void DebugPrinter(QtMsgType type, const QMessageLogContext &context, const 
QString &msg)
{
    QString txt;
    switch (type) {
    case QtDebugMsg:
            txt = QString("Debug: %1").arg(msg);
            break;
    case QtWarningMsg:
            txt = QString("Warning: %1").arg(msg);
    break;
    case QtCriticalMsg:
            txt = QString("Critical: %1").arg(msg);
    break;
    case QtFatalMsg:
            txt = QString("Fatal: %1").arg(msg);
            abort();
    }

    QDir homePath = QDir::homePath();
    QString dbFilePath = homePath.absolutePath();
    dbFilePath.append( "/" + DEBUGLOG );
    QFile outFile( dbFilePath );
    outFile.open(QIODevice::WriteOnly | QIODevice::Append);
    QTextStream ts(&outFile);
    ts << txt << endl;
}

So what am I doing wrong here?


— 
Tero
_______________________________________________
SailfishOS.org Devel mailing list

Reply via email to