util: function to log exceptions' tracebacks.

Also log the different IOErrors causing early exit.