Add logging

Should help with #150 and similar issues.