Use the MUTEX_LOCK macro in log_write().