add debug flag, to only output to stdout if set to true