API to replace all calls to exit() with a user-supplied fatal-error handler. Also, add unit tests for logging. svn:r1462