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. Preserve 'line' and 'file' macro expansion when in release mode
Forum Updated to NodeBB v4.3 + New Features

Preserve 'line' and 'file' macro expansion when in release mode

Scheduled Pinned Locked Moved Solved General and Desktop
debug
4 Posts 3 Posters 1.4k Views 2 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.
  • divergerD Offline
    divergerD Offline
    diverger
    wrote on last edited by diverger
    #1

    I installed my own message handler to use qDebug(), qInfo(), etc as "logging" tool. The second argument passed to the handler store the message context, such as file, function, line, thread pid, etc. They work well under debug mode, and the line and file information printed as expected. But when compiled in release mode, all line and file information are gone (the 'file' and 'line' in QMessageLogContext is 0). It seems the macro QT_NO_DEBUG prevents these infos. But I don't want to remove QT_NO_DEBUG, because I need this macro to prevent other debug macros expansion, such as Q_ASSERT(), Q_ASSERT_X(). I just need the "file", "line" or the "function" information in QMessageLogContext. Any method to achieve this?

    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Maybe QLoggingCategory coud be of interest.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mpergand
        wrote on last edited by mpergand
        #3

        Add this to your .pro

        CONFIG(release,debug|release)
        {   # active log context pour Application::ErrorMessageLog() en mode release
            DEFINES += QT_MESSAGELOGCONTEXT
        }
        

        Maybe you need to clear/rebuild your project.

        before:
        28-03-2018 15:32:53.285 [MultiDocsDemo from ???] error !
        now:
        28-03-2018 15:36:53.940 [MultiDocsDemo from openNewWindow() in Application.cpp line 1434] error !

        divergerD 1 Reply Last reply
        4
        • M mpergand

          Add this to your .pro

          CONFIG(release,debug|release)
          {   # active log context pour Application::ErrorMessageLog() en mode release
              DEFINES += QT_MESSAGELOGCONTEXT
          }
          

          Maybe you need to clear/rebuild your project.

          before:
          28-03-2018 15:32:53.285 [MultiDocsDemo from ???] error !
          now:
          28-03-2018 15:36:53.940 [MultiDocsDemo from openNewWindow() in Application.cpp line 1434] error !

          divergerD Offline
          divergerD Offline
          diverger
          wrote on last edited by
          #4

          @mpergand Yes, this is just what I want. Thanks.

          1 Reply Last reply
          1

          • Login

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