[Interest] using QTemporaryFile for post-mortem debug logfiles?
annulen at yandex.ru
Sun May 21 11:15:48 CEST 2017
21.05.2017, 11:47, "René J.V. Bertin" <rjvbertin at gmail.com>:
> 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?
Don't use QTemporaryFile. Use regular files with consistent naming, e.g. log-$date, remove logs older than some date at the start of your program
> Interest mailing list
> Interest at qt-project.org
More information about the Interest