locking around log output