Log exceptions from the main loop