move logging to io.{cpp,h}

Moves the logging code into its own file where it is clearer what is going on.