[Interest] using QTemporaryFile for post-mortem debug logfiles?

René J.V. Bertin rjvbertin at gmail.com
Sun May 21 10:47:23 CEST 2017


Is it possible to use QTemporaryFile to create logfiles or messages generated by qDebug() and family, and keep them only when the user wants to OR when the application crashes?

Currently, they're all being kept because qlogFile->setAutoRemove(false). I tried to prune at least the empty ones before exitting by doing (in the application dtor):

if (qlogFile->size() ==0) qlogFile->setAutoRemove(true);

but that doesn't work, as if the auto-remove property cannot be changed after opening the temp. file.

Can I presume safely that leaving the auto-remove property to true means that the logfiles will only be removed on a clean exit, or is there another "best practice" approach to accomplish this sort of thing?


More information about the Interest mailing list