Improve logging

All modules need to be covered by more extensive logging, for debug and info. This also needs to be extended into tests (e.g. see the caplog fixture for pytest), so that debugging becomes easier.

Edited by David Runge