qt

qDebug not showing __FILE__,__LINE__


According to qlogging.h

#define qDebug QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO).debug

but when I use like this, file,line,function name not show.

qDebug()<< "abc"; // only show abc;
qDebug()<< "";    // show nothing;

I search for a while, it seems no one had my problem like above.

I use ubuntu14.04,g++ version 4.8.2, qt5.3 build from git.


Solution

  • If you dig in Qt history you can find out that the __FILE__ and __FUNCTION__ are logged only in debug builds since 1 Oct 2014. The git commit hash is d78fb442d750b33afe2e41f31588ec94cf4023ad. The commit message states:

    Logging: Disable tracking of debug source info for release builds

    Tracking the file, line, function means the information has to be stored in the binaries, enlarging the size. It also might be a surprise to some commercial customers that their internal file & function names are 'leaked'. Therefore we enable it for debug builds only.