Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Disable output in release mode

Disable output in release mode

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 3 Posters 2.9k Views
  • 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.
  • M Offline
    M Offline
    m.abed
    wrote on last edited by
    #1

    Hello
    I need to disable console output logs in release mode,
    console.log()

    how i can achieve that
    i tried this , but not worked
    DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT

    K 1 Reply Last reply
    0
    • M m.abed

      Hello
      I need to disable console output logs in release mode,
      console.log()

      how i can achieve that
      i tried this , but not worked
      DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT

      K Offline
      K Offline
      koahnig
      wrote on last edited by koahnig
      #2

      @m.abed

      Are you sure that the output you are still seeing is from qDebug and it different flavors?

      also cout and cerr is shown on the console.

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        m.abed
        wrote on last edited by m.abed
        #3

        Yes , i can see output of console.log and qDebug() in release mode
        i tested on Android and Desktop
        @koahnig

        1 Reply Last reply
        0
        • M Offline
          M Offline
          m.abed
          wrote on last edited by
          #4

          Here the solution for my problem

          https://stackoverflow.com/questions/28540571/how-to-enable-and-disable-qdebug-messages?noredirect=1#comment76861982_28540571

          #include <qapplication.h>
          #include <stdio.h>
          #include <stdlib.h>
          
          void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
          {
              QByteArray localMsg = msg.toLocal8Bit();
              switch (type) {
              case QtDebugMsg:
                  fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  break;
              case QtInfoMsg:
                  fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  break;
              case QtWarningMsg:
                  fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  break;
              case QtCriticalMsg:
                  fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  break;
              case QtFatalMsg:
                  fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  abort();
              }
          }
          
          int main(int argc, char **argv)
          {
              qInstallMessageHandler(myMessageOutput);
              QApplication app(argc, argv);
              ...
              return app.exec();
          }
          

          Thanks Guys

          1 Reply Last reply
          1
          • Pradeep P NP Offline
            Pradeep P NP Offline
            Pradeep P N
            wrote on last edited by
            #5

            @m-abed
            qInstallMessageHandler() is use full for saving the logs to a file, if you don't want to save it to the file than you can use QT_LOGGING_RULES.

            Pradeep Nimbalkar.
            Upvote the answer(s) that helped you to solve the issue...
            Keep code clean.

            1 Reply Last reply
            2

            • Login

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