Clean way to overwrite stdout and stderr, used to refactor migration views.