Add the print mutex around logging to prevent interleaved lines