log utils, ugly but useful.