move logging stuff to log.py and a few test experiments

Also fix errors going to stdout