Add lock variable to fix botlogs_capture.txt IO exception when multiple threads access this file