Use a mutex to serialize logging