added lock to synchronize logging messages