Add logging

Good point. What about other similar places in this file?