Add some logging.

Also moved logging module into its own file.