Now logging works

Also reindented all the code :-(
Logging works!