[Interest] using QTemporaryFile for post-mortem debug logfiles?
Konstantin Tokarev
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>:
> Hello,
>
> 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);
> qlogFile->close();
>
> 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
>
> Thanks,
> R.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
--
Regards,
Konstantin
More information about the Interest
mailing list