Make the logging framework provide a default uncaught exception
handler.  Note that this only effects production code. Dev mode
already installs a default uncaught exception handler.

http://gwt-code-reviews.appspot.com/1223802

Review by: unnurg@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9511 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/logging/client/LogConfiguration.java b/user/src/com/google/gwt/logging/client/LogConfiguration.java
index 55dfbc6..3604eee 100644
--- a/user/src/com/google/gwt/logging/client/LogConfiguration.java
+++ b/user/src/com/google/gwt/logging/client/LogConfiguration.java
@@ -18,6 +18,7 @@
 
 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
 import com.google.gwt.user.client.Window.Location;
 import com.google.gwt.user.client.ui.HasWidgets;
 
@@ -146,5 +147,16 @@
 
   public void onModuleLoad() {
     impl.configureClientSideLogging();
+    
+    if (impl.loggingIsEnabled()) {
+      if (GWT.getUncaughtExceptionHandler() == null) {
+        final Logger log = Logger.getLogger(LogConfiguration.class.getName());
+        GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+          public void onUncaughtException(Throwable e) {
+            log.log(Level.SEVERE, e.getMessage(), e);
+          }
+        });
+      }
+    }
   }
 }