Refactor logging
Migrated from GitLab #20
Probably use standard logging module (perhaps with rotating functionality). Race conditions on the log file are probably a problem in the current setup.
Instead of logging module rotating, we could also use logrotate: http://serverfault.com/questions/55610/logrotate-and-open-files