add thread-boundary lock for logging when USE_LOCAL_LOCK flag is set