Add log.write() and log.writeln() for simple logging, closes #52.

Also refactor the logger.