21.05.2017, 11:47, "René J.V. Bertin" <rjvber...@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@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest -- Regards, Konstantin _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest