Added a function that flushes all logfiles synchronously.