Add mutex protection for logging/printing