Fix race condition that allowed multiple threads to write to the log concurrently.