Alexander,

You have brought up yet another of the limitless reasons QML and JavaScript shouldn't be used for any production system.

Pull down this zip file.

http://www.logikalsolutions.com/wordpress/wp-content/uploads/2016/07/SerialKeypad.zip

(It's discussed in the "Raspberry Qt" post series on logikalblog.com)

Take the LogikalLogger class. It's a singleton. Add it to your application. I typically "expose" it by creating a Backend class which is then registered with QML and instantiated by main.cpp.

Forget the console.log() abomination ever existed. Always use backEnd.logDebug() or logCrit(), etc. (Critical typically also includes a call to the wrench screen to hide the screen before ending the application. Critical means one cannot safely continue without adverse outcome to human life.)

If you always use your logDebug() wrapper (or expose LogikalLogger directly and pass the various syslog values) no Debug level messages will ever be recorded or displayed when the application is not compiled with debug. For some clients I have even modified versions of this to include a set/get methods for "minimum log level" so it could be controlled from the command line at startup. This allowed them to weed out INFO and under messages but still keep warning on up.

Of course, the best solution is to never consider QML or JavaScript for anything because they are unfit for production use.

On 4/25/2019 3:59 AM, Alexander Ivash wrote:
I understand that this topic was raised a lot of times and that this
is not QML-way. But, what options do I have in case of requirements to
eliminate all the logging for release builds?

Is there any hidden magic in qmake, like 'QMAKE_SUBSTITUTES' but more
flexible to substitute all the 'console.debug....' with '//
console.debug' right before adding qml into resources?

p.s. Yea, I'm aware of selectors, but would like to avoid having both
component-with-logging.qml and component-with-no-logging.qml

--
Roland Hughes, President
Logikal Solutions
(630)-205-1593  (cell)
http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to