Possible to track program progress before crash using QFile or maybe QSettings?
-
Hi I'd like to have my program record its progress using either QFile or QSettings (or something better if it exists...). So if the program crashes progress is recorded and its easy to see where the crash occurred. Do QFile and QSettings guarantee completion of their corresponding operations before subsequent instructions are performed? Is there another way or better way of doing things?
-
@Crag_Hack Why use QFile for that? QSettings isn't designed for something like this at all. It is used to read/write settings, not for logging. You can simply use qDebug/qWarning to log some information. Then you can forward the output to a file when needed:
my_app.exe > some.log
If you really need a logging solution take a look at Qt Logging Framework: http://doc.qt.io/qt-5/qmessagelogger.html
-
Thanks jsulm. Hmmm... are either of those solutions good for non-local debugging? Like a customer's computer is crashing and need to figure out why. Will redirecting qDebug output work for a gui program as well? How about catching a bug that's not easily reproducible?
-
@Crag_Hack Redirecting output of a GUI app works in the same way as for a console app. Your requirements sound like you need a logging framework. Take a look at what Qt provides or any other logging framework for C++. For debugging crashes core dumps are helpful.