0

I am developing an application in Qt, for debugging purpose I am writing lot of message to console using qDebug(), and my question is does the debug message cause performance of the application. Should I remove this while deploying application?

Haris
  • 13,645
  • 12
  • 90
  • 121
  • Possible duplicate of [Why does qDebug work in Release builds?](http://stackoverflow.com/questions/13494499/why-does-qdebug-work-in-release-builds) – demonplus Nov 30 '15 at 06:30

2 Answers2

2

Of course it will have some impact.It is better to remove the debug logging in release mode, it can be done by macro QT_NO_DEBUG_OUTPUT

Balu
  • 2,247
  • 1
  • 18
  • 23
2

In Qt 5 we have qInstallMessageHandler global function with which we can manipulate the actual log output by providing own callback function that decides whether or not to output the log message at runtime. There is same function in Qt 4 called qInstallMsgHandler.

Installs a Qt message handler which has been defined previously. Returns a pointer to the previous message handler.

The message handler is a function that prints out debug messages, warnings, critical and fatal error messages. The Qt library (debug mode) contains hundreds of warning messages that are printed when internal errors (usually invalid function arguments) occur. Qt built in release mode also contains such warnings unless QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT have been set during compilation. If you implement your own message handler, you get total control of these messages.

In some applications release production versions allow only qtWarningMsg and higher by default.

And yes, logging may affect the performance of the application. There several techniques for reducing the negative impact. And the most important one is to isolate the logging output (production app versions use mostly files and send them over the Internet) on a separate thread that serves file/other operations.

Alexander V
  • 8,351
  • 4
  • 38
  • 47