Revision: 8345
Author: [email protected]
Date: Wed Jun 30 12:29:28 2010
Log: Update the codelab to trigger exceptions and make the section on triggering server and shared logging more clear. Also a few changes to ensure that disabling logging works correctly in the codelab, and a static function that can be used (even in
development mode) to see if logging is enabled.

Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=8345

Modified:
 /trunk/user/src/com/google/gwt/logging/Logging.gwt.xml
/trunk/user/src/com/google/gwt/logging/client/DevelopmentModeLogHandler.java
 /trunk/user/src/com/google/gwt/logging/client/LogConfiguration.java

=======================================
--- /trunk/user/src/com/google/gwt/logging/Logging.gwt.xml Mon Jun 28 12:35:42 2010 +++ /trunk/user/src/com/google/gwt/logging/Logging.gwt.xml Wed Jun 30 12:29:28 2010
@@ -63,40 +63,70 @@
<define-property name="gwt.logging.consoleHandler" values="ENABLED, DISABLED" />
   <replace-with class="com.google.gwt.logging.client.NullLogHandler">
<when-type-is class="com.google.gwt.logging.client.ConsoleLogHandler" />
-    <when-property-is name="gwt.logging.consoleHandler" value="DISABLED" />
+    <any>
+      <when-property-is name="gwt.logging.enabled" value="FALSE" />
+ <when-property-is name="gwt.logging.consoleHandler" value="DISABLED" />
+    </any>
   </replace-with>
<define-property name="gwt.logging.developmentModeHandler" values="ENABLED, DISABLED" />
   <replace-with class="com.google.gwt.logging.client.NullLogHandler">
<when-type-is class="com.google.gwt.logging.client.DevelopmentModeLogHandler" /> - <when-property-is name="gwt.logging.developmentModeHandler" value="DISABLED" />
+    <any>
+      <when-property-is name="gwt.logging.enabled" value="FALSE" />
+ <when-property-is name="gwt.logging.developmentModeHandler" value="DISABLED" />
+    </any>
   </replace-with>
<define-property name="gwt.logging.firebugHandler" values="ENABLED, DISABLED" />
   <replace-with class="com.google.gwt.logging.client.NullLogHandler">
<when-type-is class="com.google.gwt.logging.client.FirebugLogHandler" />
-    <when-property-is name="gwt.logging.firebugHandler" value="DISABLED" />
+    <any>
+      <when-property-is name="gwt.logging.enabled" value="FALSE" />
+ <when-property-is name="gwt.logging.firebugHandler" value="DISABLED" />
+    </any>
   </replace-with>
<define-property name="gwt.logging.systemHandler" values="ENABLED, DISABLED" />
   <replace-with class="com.google.gwt.logging.client.NullLogHandler">
     <when-type-is class="com.google.gwt.logging.client.SystemLogHandler" />
-    <when-property-is name="gwt.logging.systemHandler" value="DISABLED" />
+    <any>
+      <when-property-is name="gwt.logging.enabled" value="FALSE" />
+ <when-property-is name="gwt.logging.systemHandler" value="DISABLED" />
+    </any>
   </replace-with>
<define-property name="gwt.logging.simpleRemoteHandler" values="ENABLED, DISABLED" />
   <replace-with class="com.google.gwt.logging.client.NullLogHandler">
<when-type-is class="com.google.gwt.logging.client.SimpleRemoteLogHandler" /> - <when-property-is name="gwt.logging.simpleRemoteHandler" value="DISABLED" />
+    <any>
+      <when-property-is name="gwt.logging.enabled" value="FALSE" />
+ <when-property-is name="gwt.logging.simpleRemoteHandler" value="DISABLED" />
+    </any>
   </replace-with>
+ <define-property name="gwt.logging.hasWidgetsHandler" values="ENABLED, DISABLED" />
+  <replace-with class="com.google.gwt.logging.client.NullLogHandler">
+ <when-type-is class="com.google.gwt.logging.client.HasWidgetsLogHandler" />
+    <any>
+      <when-property-is name="gwt.logging.enabled" value="FALSE" />
+ <when-property-is name="gwt.logging.hasWidgetsHandler" value="DISABLED" />
+    </any>
+  </replace-with>
+
+
<define-property name="gwt.logging.popupHandler" values="ENABLED, DISABLED" />
   <replace-with class="com.google.gwt.logging.client.NullLoggingPopup">
     <when-type-is class="com.google.gwt.logging.client.LoggingPopup" />
-    <when-property-is name="gwt.logging.popupHandler" value="DISABLED" />
+    <any>
+      <when-property-is name="gwt.logging.enabled" value="FALSE" />
+      <when-property-is name="gwt.logging.popupHandler" value="DISABLED" />
+    </any>
   </replace-with>
-
+
+
   <!-- Default values for all properties -->
   <set-property name="gwt.logging.enabled" value="TRUE"/>
   <set-property name="gwt.logging.logLevel" value="INFO"/>
   <set-property name="gwt.logging.consoleHandler" value="ENABLED" />
<set-property name="gwt.logging.developmentModeHandler" value="ENABLED" />
   <set-property name="gwt.logging.firebugHandler" value="ENABLED" />
+  <set-property name="gwt.logging.hasWidgetsHandler" value="ENABLED" />
   <set-property name="gwt.logging.popupHandler" value="ENABLED" />
   <set-property name="gwt.logging.systemHandler" value="ENABLED" />
   <set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
=======================================
--- /trunk/user/src/com/google/gwt/logging/client/DevelopmentModeLogHandler.java Tue Jun 15 15:09:25 2010 +++ /trunk/user/src/com/google/gwt/logging/client/DevelopmentModeLogHandler.java Wed Jun 30 12:29:28 2010
@@ -48,10 +48,8 @@
     if (!isSupported() || !isLoggable(record)) {
       return;
     }
-
-    // TODO(unnurg): pass in the throwable here since GWT.log can handle it
     String msg = getFormatter().format(record);
-    GWT.log(msg);
+    GWT.log(msg, record.getThrown());
   }

   private boolean isSupported() {
=======================================
--- /trunk/user/src/com/google/gwt/logging/client/LogConfiguration.java Mon Jun 28 12:35:42 2010 +++ /trunk/user/src/com/google/gwt/logging/client/LogConfiguration.java Wed Jun 30 12:29:28 2010
@@ -29,9 +29,10 @@
* Configures client side logging using the query params and gwt.xml settings.
  */
 public class LogConfiguration implements EntryPoint {
-
+
   private interface LogConfigurationImpl {
     void configureClientSideLogging();
+    boolean loggingIsEnabled();
   }

   /**
@@ -40,6 +41,10 @@
   private static class LogConfigurationImplNull
   implements LogConfigurationImpl {
     public void configureClientSideLogging() { }
+
+    public boolean loggingIsEnabled() {
+      return false;
+    }
   }

   /**
@@ -54,12 +59,16 @@
       setDefaultHandlers(root);
     }

+    public boolean loggingIsEnabled() {
+      return true;
+    }
+
     private void addHandlerIfNotNull(Logger l, Handler h) {
       if (!(h instanceof NullLogHandler)) {
         l.addHandler(h);
       }
     }
-
+
     private Level parseLevel(String s) {
       if (s == null) {
         return null;
@@ -85,7 +94,7 @@
       }
       return null;
     }
-
+
     private void setDefaultHandlers(Logger l) {
// Add the default handlers. If users want some of these disabled, they // will specify that in the gwt.xml file, which will replace the handler
@@ -105,7 +114,7 @@
         addHandlerIfNotNull(l, new HasWidgetsLogHandler(loggingWidget));
       }
     }
-
+
     private void setLevels(Logger l) {
       // try to pull the log level from the query param
       Level paramLevel = parseLevel(Location.getParameter("logLevel"));
@@ -121,9 +130,12 @@

   private static LogConfigurationImpl impl =
     GWT.create(LogConfigurationImplNull.class);
+
+  public static boolean loggingIsEnabled() {
+    return impl.loggingIsEnabled();
+  }

   public void onModuleLoad() {
     impl.configureClientSideLogging();
   }
-
-}
+}

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to