Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Behaviour of qDebug and companions starting with Qt 5.2
Forum Updated to NodeBB v4.3 + New Features

Behaviour of qDebug and companions starting with Qt 5.2

Scheduled Pinned Locked Moved General and Desktop
qdebugqloggingrelease mode
1 Posts 1 Posters 793 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by koahnig
    #1

    qDebug and its companions are quite powerful methods for substitution of cout and cerr in applications.

    Two advatanges made it quite appealing when I have started to use probably around Qt 4.6 or even earlier.
    The first advantage is that you can finally use a macro define for switching all references off.
    The other is that the output may easily redirected at a central point of your application. The outpout may be split and duplicated what ever the programmer decides with respect to output seem possible.

    Therefore, I started to use qDebug already using it as some type of logging feature before it became an official part of Qt 5.2 with QLogging.

    Currently, I am using Qt5.3 and the functionality is still the same with my applications after adaption of the slight changes with the message output handler.

    However, one point bothers a bit. That is that the current implementation in Qt 5.3 reinterprets all qDebug statements through a macro in qlogging.h

    /*
    qDebug, qWarning, qCritical, qFatal are redefined to automatically include context information
    */
    #define qDebug QMessageLogger(_FILE_, _LINE_, Q_FUNC_INFO).debug
    #define qWarning QMessageLogger(_FILE_, _LINE_, Q_FUNC_INFO).warning
    #define qCritical QMessageLogger(_FILE_, _LINE_, Q_FUNC_INFO).critical
    #define qFatal QMessageLogger(_FILE_, _LINE_, Q_FUNC_INFO).fatal

    The issue is the _FILE_ and _LINE_ in those defines. They pepper the release exe with references to the source code files. In turn that is not what one really anticipates with a release build.

    Is there already a better way of handling anticipated?
    Or do we need to overwrite those defines individually in our code files?

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved