properly shut down logs on uncaught exceptions
new version
fixed reverse logic