Add basic logging

Trying to find why the daemon crashes periodically, so added basic
logging, and put the main loop inside a logging try/except/raise
block