Add an option to compile out all logging calls below the SEVERE or WARNING
level. Note that this does not work for logger.log() calls - it only works for
logger.severe(), logger.info(), etc. style calls.  Since the java.util.logging API does not provide the ability to log exceptions with the logger.severe() style calls, you'll need to use the logger.log() calls to log exceptions and follow the directions below for how to get them to compile out.

If you need to compile out logger.log() calls (or any more complex logging code), you can do this:

if (LogConfiguration.loggingIsEnabled(Level.WARNING)) {
// This will all compile out if gwt.logging.enabled is set to SEVERE
String errMessage = "Hi";
logger.log(Level.WARNING, errMessage, exception);
}

Review by: cromwellian@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10753 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/tools/api-checker/config/gwt23_24userApi.conf b/tools/api-checker/config/gwt23_24userApi.conf
index 8432675..85bffeb 100644
--- a/tools/api-checker/config/gwt23_24userApi.conf
+++ b/tools/api-checker/config/gwt23_24userApi.conf
@@ -179,3 +179,32 @@
 
 # Adding timezone constructor argument to DateCell
 com.google.gwt.cell.client.DateCell::DateCell(Lcom/google/gwt/i18n/client/DateTimeFormat;Lcom/google/gwt/text/shared/SafeHtmlRenderer;) OVERLOADED_METHOD_CALL
+
+# Refactoring Level implementation
+com.google.gwt.logging.impl.LevelImplNull::all() MISSING
+com.google.gwt.logging.impl.LevelImplNull::config() MISSING
+com.google.gwt.logging.impl.LevelImplNull::fine() MISSING
+com.google.gwt.logging.impl.LevelImplNull::finer() MISSING
+com.google.gwt.logging.impl.LevelImplNull::finest() MISSING
+com.google.gwt.logging.impl.LevelImplNull::getName() MISSING
+com.google.gwt.logging.impl.LevelImplNull::info() MISSING
+com.google.gwt.logging.impl.LevelImplNull::intValue() MISSING
+com.google.gwt.logging.impl.LevelImplNull::off() MISSING
+com.google.gwt.logging.impl.LevelImplNull::setName(Ljava/lang/String;) MISSING
+com.google.gwt.logging.impl.LevelImplNull::setValue(I) MISSING
+com.google.gwt.logging.impl.LevelImplNull::severe() MISSING
+com.google.gwt.logging.impl.LevelImplNull::warning() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::all() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::config() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::fine() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::finer() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::finest() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::getName() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::info() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::intValue() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::off() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::setName(Ljava/lang/String;) MISSING
+com.google.gwt.logging.impl.LevelImplRegular::setValue(I) MISSING
+com.google.gwt.logging.impl.LevelImplRegular::severe() MISSING
+com.google.gwt.logging.impl.LevelImplRegular::warning() MISSING
+java.util.logging.Level::Level(Ljava/lang/String;I) MISSING
diff --git a/user/src/com/google/gwt/logging/LogImpl.gwt.xml b/user/src/com/google/gwt/logging/LogImpl.gwt.xml
index ddf32b1..7c45864 100644
--- a/user/src/com/google/gwt/logging/LogImpl.gwt.xml
+++ b/user/src/com/google/gwt/logging/LogImpl.gwt.xml
@@ -1,15 +1,36 @@
 <module>
   <source path="impl" />
   
-  <!-- Set up and handle the gwt.logging property -->
-  <define-property name="gwt.logging.enabled" values="TRUE, FALSE" />
+  <!-- Set up and handle the gwt.logging property
+   Setting this value to FALSE will compile out all logging.  Setting it to SEVERE
+   or WARNING means that the logging framework will not compile out, but the basic
+   logging calls like logger.info() and logger.fine() will compile out if it is below
+   the level that is set.  Note that something like logger.log(Level.INFO, "foo", e)
+   *will not* compile out at this point.  If you have something that is important to 
+   have compiled out, you should put it behind a 
+   LogConfiguration.isLoggingEnabled(Level.INFO) guard.
+   -->
+  <define-property name="gwt.logging.enabled" values="TRUE, FALSE, SEVERE, WARNING" />
+  <replace-with class="com.google.gwt.logging.impl.LevelImplRegular">
+    <when-type-is class="com.google.gwt.logging.impl.LevelImplNull"/>
+    <any>
+      <when-property-is name="gwt.logging.enabled" value="TRUE" />
+      <when-property-is name="gwt.logging.enabled" value="SEVERE" />
+      <when-property-is name="gwt.logging.enabled" value="WARNING" />
+    </any>
+  </replace-with>
+
   <replace-with class="com.google.gwt.logging.impl.LoggerImplRegular">
     <when-type-is class="com.google.gwt.logging.impl.LoggerImplNull"/>
     <when-property-is name="gwt.logging.enabled" value="TRUE" />
   </replace-with>
-  <replace-with class="com.google.gwt.logging.impl.LevelImplRegular">
-    <when-type-is class="com.google.gwt.logging.impl.LevelImplNull"/>
-    <when-property-is name="gwt.logging.enabled" value="TRUE" />
+  <replace-with class="com.google.gwt.logging.impl.LoggerImplSevere">
+    <when-type-is class="com.google.gwt.logging.impl.LoggerImplNull"/>
+    <when-property-is name="gwt.logging.enabled" value="SEVERE" />
+  </replace-with>
+  <replace-with class="com.google.gwt.logging.impl.LoggerImplWarning">
+    <when-type-is class="com.google.gwt.logging.impl.LoggerImplNull"/>
+    <when-property-is name="gwt.logging.enabled" value="WARNING" />
   </replace-with>
   
   <set-property name="gwt.logging.enabled" value="FALSE"/> 
diff --git a/user/src/com/google/gwt/logging/LoggingDisabled.gwt.xml b/user/src/com/google/gwt/logging/LoggingDisabled.gwt.xml
index da3cf00..e372a72 100644
--- a/user/src/com/google/gwt/logging/LoggingDisabled.gwt.xml
+++ b/user/src/com/google/gwt/logging/LoggingDisabled.gwt.xml
@@ -18,13 +18,20 @@
   <inherits name="com.google.gwt.logging.LogImpl"/>
   <source path="client" />
   <source path="shared" />
-  
+
   <replace-with class="com.google.gwt.logging.client.LogConfiguration.LogConfigurationImplRegular">
     <when-type-is class="com.google.gwt.logging.client.LogConfiguration.LogConfigurationImplNull"/>
     <when-property-is name="gwt.logging.enabled" value="TRUE" />
   </replace-with>
+  <replace-with class="com.google.gwt.logging.client.LogConfiguration.LogConfigurationImplSevere">
+    <when-type-is class="com.google.gwt.logging.client.LogConfiguration.LogConfigurationImplNull"/>
+    <when-property-is name="gwt.logging.enabled" value="SEVERE" />
+  </replace-with>
+  <replace-with class="com.google.gwt.logging.client.LogConfiguration.LogConfigurationImplWarning">
+    <when-type-is class="com.google.gwt.logging.client.LogConfiguration.LogConfigurationImplNull"/>
+    <when-property-is name="gwt.logging.enabled" value="WARNING" />
+  </replace-with>
 
-  
   <!-- Set up and handle the gwt.logging.logLevel property -->
   <define-property name="gwt.logging.logLevel" values="ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE" />
   <replace-with class="com.google.gwt.logging.client.DefaultLevel.All">
diff --git a/user/src/com/google/gwt/logging/client/LogConfiguration.java b/user/src/com/google/gwt/logging/client/LogConfiguration.java
index 3604eee..ef94ca4 100644
--- a/user/src/com/google/gwt/logging/client/LogConfiguration.java
+++ b/user/src/com/google/gwt/logging/client/LogConfiguration.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -30,13 +30,14 @@
  * Configures client side logging using the query params and gwt.xml settings.
  */
 public class LogConfiguration implements EntryPoint {
-    
+
   private interface LogConfigurationImpl {
     void configureClientSideLogging();
     boolean loggingIsEnabled();
+    boolean loggingIsEnabled(Level level);
   }
-  
-  /** 
+
+  /**
    * Implementation which does nothing and compiles out if logging is disabled.
    */
   private static class LogConfigurationImplNull
@@ -46,9 +47,13 @@
     public boolean loggingIsEnabled() {
       return false;
     }
+
+    public boolean loggingIsEnabled(Level level) {
+      return false;
+    }
   }
-  
-  /** 
+
+  /**
    * Implementation which is used when logging is enabled.
    */
   private static class LogConfigurationImplRegular
@@ -68,17 +73,24 @@
       setLevels(root);
       setDefaultHandlers(root);
     }
-  
+
     public boolean loggingIsEnabled() {
       return true;
     }
-   
+
+    /**
+     * Returns whether logging enabled for the passed in level.
+     */
+    public boolean loggingIsEnabled(Level level) {
+      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;
@@ -104,7 +116,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
@@ -137,17 +149,43 @@
       }
     }
   }
-  
+
+  /**
+   * Implementation which is used when logging.enabled is set to SEVERE.
+   */
+  private static class LogConfigurationImplSevere
+  extends LogConfigurationImplRegular {
+    @Override
+    public boolean loggingIsEnabled(Level level) {
+      return level.intValue() >= 1000;
+    }
+  }
+
+  /**
+   * Implementation which is used when logging.enabled is set to WARNING.
+   */
+  private static class LogConfigurationImplWarning
+  extends LogConfigurationImplRegular {
+    @Override
+    public boolean loggingIsEnabled(Level level) {
+      return level.intValue() >= 900;
+    }
+  }
+
   private static LogConfigurationImpl impl =
     GWT.create(LogConfigurationImplNull.class);
-  
+
   public static boolean loggingIsEnabled() {
     return impl.loggingIsEnabled();
   }
 
+  public static boolean loggingIsEnabled(Level level) {
+    return impl.loggingIsEnabled(level);
+  }
+
   public void onModuleLoad() {
     impl.configureClientSideLogging();
-    
+
     if (impl.loggingIsEnabled()) {
       if (GWT.getUncaughtExceptionHandler() == null) {
         final Logger log = Logger.getLogger(LogConfiguration.class.getName());
diff --git a/user/src/com/google/gwt/logging/impl/LevelImpl.java b/user/src/com/google/gwt/logging/impl/LevelImpl.java
index 3fc9eb9..e5c653f 100644
--- a/user/src/com/google/gwt/logging/impl/LevelImpl.java
+++ b/user/src/com/google/gwt/logging/impl/LevelImpl.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -24,19 +24,5 @@
  * LevelImplRegular to provide normal functionality when logging is enabled.
  */
 public interface LevelImpl {
-  Level all();
-  Level config();
-  Level fine();
-  Level finer();
-  Level finest();
-  String getName();
-  Level info();
-  int  intValue();
-  Level off();
   Level parse(String name);
-  void setName(String newName);
-  void setValue(int newValue);
-  Level severe();
-  String toString();
-  Level warning();
 }
diff --git a/user/src/com/google/gwt/logging/impl/LevelImplNull.java b/user/src/com/google/gwt/logging/impl/LevelImplNull.java
index 0cd3259..2d4952d 100644
--- a/user/src/com/google/gwt/logging/impl/LevelImplNull.java
+++ b/user/src/com/google/gwt/logging/impl/LevelImplNull.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -23,59 +23,7 @@
  * compile out when logging is disabled.
  */
 public class LevelImplNull implements LevelImpl {
-
-  public Level all() {
-    return null;
-  }
-
-  public Level config() {
-    return null;
-  }
-
-  public Level fine() {
-    return null;
-  }
-
-  public Level finer() {
-    return null;
-  }
-
-  public Level finest() {
-    return null;
-  }
-
-  public String getName() {
-    return null;
-  }
-
-  public Level info() {
-    return null;
-  }
-
-  public int intValue() {
-    return 0;
-  }
-
-  public Level off() {
-    return null;
-  }
-
   public Level parse(String name) {
     return null;
   }
-  
-  public void setName(String newName) {
-  }
-
-  public void setValue(int newValue) {
-  }
-
-  public Level severe() {
-    return null;
-  }
-
-  public Level warning() {
-    return null;
-  }
-
 }
diff --git a/user/src/com/google/gwt/logging/impl/LevelImplRegular.java b/user/src/com/google/gwt/logging/impl/LevelImplRegular.java
index ed6cb4a..8e5bf03 100644
--- a/user/src/com/google/gwt/logging/impl/LevelImplRegular.java
+++ b/user/src/com/google/gwt/logging/impl/LevelImplRegular.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -22,119 +22,26 @@
  * Implementation for the Level class when logging is enabled.
  */
 public class LevelImplRegular implements LevelImpl {
-  
-  /** 
-   * Since the Impl class is in a different package than the Level class, we
-   * need to work around the fact that the Impl class cannot access the
-   * protected Level constructor.
-   */
-  private static class LevelWithExposedConstructor extends Level {
-    public LevelWithExposedConstructor(String name, int value) {
-      super(name, value);
-    }
-  }
-
-  private static Level ALL = 
-    new LevelWithExposedConstructor("ALL", Integer.MIN_VALUE); 
-  private static Level CONFIG =
-    new LevelWithExposedConstructor("CONFIG", 700); 
-  private static Level FINE =
-    new LevelWithExposedConstructor("FINE", 500); 
-  private static Level FINER =
-    new LevelWithExposedConstructor("FINER", 400); 
-  private static Level FINEST =
-    new LevelWithExposedConstructor("FINEST", 300); 
-  private static Level INFO =
-    new LevelWithExposedConstructor("INFO", 800); 
-  private static Level OFF =
-    new LevelWithExposedConstructor("OFF", Integer.MAX_VALUE); 
-  private static Level SEVERE =
-    new LevelWithExposedConstructor("SEVERE", 1000);
-  private static Level WARNING =
-    new LevelWithExposedConstructor("WARNING", 900); 
-  
-  private String name;
-  private int value;
-
-  public LevelImplRegular() { }
-  
-  public Level all() {
-    return LevelImplRegular.ALL;
-  }
-  
-  public Level config() {
-    return LevelImplRegular.CONFIG;
-  }
-    
-  public Level fine() {
-    return LevelImplRegular.FINE;
-  }
-  
-  public Level finer() {
-    return LevelImplRegular.FINER;
-  }
-  
-  public Level finest() {
-    return LevelImplRegular.FINEST;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public Level info() {
-    return LevelImplRegular.INFO;
-  }
-
-  public int intValue() {
-    return value;
-  }
-
-  public Level off() {
-    return LevelImplRegular.OFF;
-  }
-  
   public Level parse(String name) {
-    if (name.equalsIgnoreCase(all().getName())) {
-      return all();
-    } else if (name.equalsIgnoreCase(config().getName())) {
-      return config();
-    } else if (name.equalsIgnoreCase(fine().getName())) {
-      return fine();
-    } else if (name.equalsIgnoreCase(finer().getName())) {
-      return finer();
-    } else if (name.equalsIgnoreCase(finest().getName())) {
-      return finest();
-    } else if (name.equalsIgnoreCase(info().getName())) {
-      return info();
-    } else if (name.equalsIgnoreCase(off().getName())) {
-      return off();
-    } else if (name.equalsIgnoreCase(severe().getName())) {
-      return severe();
-    } else if (name.equalsIgnoreCase(warning().getName())) {
-      return warning();
-    } 
+    if (name.equalsIgnoreCase("ALL")) {
+      return Level.ALL;
+    } else if (name.equalsIgnoreCase("CONFIG")) {
+      return Level.CONFIG;
+    } else if (name.equalsIgnoreCase("FINE")) {
+      return Level.FINE;
+    } else if (name.equalsIgnoreCase("FINER")) {
+      return Level.FINER;
+    } else if (name.equalsIgnoreCase("FINEST")) {
+      return Level.FINEST;
+    } else if (name.equalsIgnoreCase("INFO")) {
+      return Level.INFO;
+    } else if (name.equalsIgnoreCase("OFF")) {
+      return Level.OFF;
+    } else if (name.equalsIgnoreCase("SEVERE")) {
+      return Level.SEVERE;
+    } else if (name.equalsIgnoreCase("WARNING")) {
+      return Level.WARNING;
+    }
     return null;
   }
-
-  public void setName(String newName) {
-    name = newName;
-  }
-
-  public void setValue(int newValue) {
-    value = newValue;
-  }
-
-  public Level severe() {
-    return LevelImplRegular.SEVERE;
-  }
-
-  @Override
-  public String toString() {
-    return getName();
-  }
-
-  public Level warning() {
-    return LevelImplRegular.WARNING;
-  }
 }
diff --git a/user/src/com/google/gwt/logging/impl/LoggerImplRegular.java b/user/src/com/google/gwt/logging/impl/LoggerImplRegular.java
index 77bd938..b6e0ba6 100644
--- a/user/src/com/google/gwt/logging/impl/LoggerImplRegular.java
+++ b/user/src/com/google/gwt/logging/impl/LoggerImplRegular.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -33,46 +33,46 @@
   private String name;
   private Logger parent;  // Should never be null except in the RootLogger
   private boolean useParentHandlers;
-  
+
   public LoggerImplRegular() {
     this.useParentHandlers = true;
     handlers = new ArrayList<Handler>();
   }
-  
+
   public void addHandler(Handler handler) {
     handlers.add(handler);
   }
-  
+
   public void config(String msg) {
     log(Level.CONFIG, msg);
   }
-  
+
   public void fine(String msg) {
     log(Level.FINE, msg);
   }
 
   public void finer(String msg) {
     log(Level.FINER, msg);
-  } 
-   
+  }
+
   public void finest(String msg) {
     log(Level.FINEST, msg);
-  } 
-  
+  }
+
   public Handler[] getHandlers() {
     if (handlers.size() > 0) {
       return handlers.toArray(new Handler[handlers.size()]);
     }
     return null;
   }
-  
+
   public Level getLevel() {
     if (level != null) {
       return level;
     }
     return getParent().getLevel();
   }
-  
+
   public Logger getLoggerHelper(String name) {
     // Ideally, we'd just return LogManager.getLogManager.getOrAddLogger(name)
     // here, since the code is basically the same, except that code gets to call
@@ -88,31 +88,31 @@
     }
     return logger;
   }
-  
+
   public String getName() {
     return name;
-  } 
-  
+  }
+
   public Logger getParent() {
     return parent;
   }
-  
+
   public boolean getUseParentHandlers() {
     return useParentHandlers;
   }
-  
+
   public void info(String msg) {
     log(Level.INFO, msg);
   }
-  
+
   public boolean isLoggable(Level messageLevel) {
     return getLevel().intValue() <= messageLevel.intValue();
-  } 
-  
+  }
+
   public void log(Level level, String msg) {
     log(level, msg, null);
   }
-  
+
   public void log(Level level, String msg, Throwable thrown) {
     if (isLoggable(level)) {
       LogRecord record = new LogRecord(level, msg);
@@ -121,7 +121,7 @@
       log(record);
     }
   }
-  
+
   public void log(LogRecord record) {
     if (isLoggable(record.getLevel())) {
       for (Handler h : handlers) {
@@ -136,29 +136,29 @@
   public void removeHandler(Handler handler) {
     handlers.remove(handler);
   }
-  
+
   public void setLevel(Level newLevel) {
     level = newLevel;
   }
-  
+
   public void setName(String newName) {
     name = newName;
   }
-  
+
   public void setParent(Logger newParent) {
     if (newParent != null) {
       parent = newParent;
     }
   }
-  
+
   public void setUseParentHandlers(boolean newUseParentHandlers) {
     useParentHandlers = newUseParentHandlers;
   }
-  
+
   public void severe(String msg) {
     log(Level.SEVERE, msg);
   }
-  
+
   public void warning(String msg) {
     log(Level.WARNING, msg);
   }
diff --git a/user/src/com/google/gwt/logging/impl/LoggerImplSevere.java b/user/src/com/google/gwt/logging/impl/LoggerImplSevere.java
new file mode 100644
index 0000000..d085d91
--- /dev/null
+++ b/user/src/com/google/gwt/logging/impl/LoggerImplSevere.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.logging.impl;
+
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * Implementation for the Logger class when logging is enabled only at Severe and above.
+ */
+public class LoggerImplSevere extends LoggerImplRegular {
+  @Override
+  public void config(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void fine(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void finer(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void finest(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void info(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void log(Level level, String msg) {
+    if (level.intValue() >= 1000) {
+      super.log(level, msg);
+    }
+  }
+
+  @Override
+  public void log(Level level, String msg, Throwable thrown) {
+    if (level.intValue() >= 1000) {
+      super.log(level, msg, thrown);
+    }
+  }
+
+  @Override
+  public void log(LogRecord record) {
+    if (record.getLevel().intValue() >= 1000) {
+      super.log(record);
+    }
+  }
+
+  @Override
+  public void severe(String msg) {
+    super.severe(msg);
+  }
+
+  @Override
+  public void warning(String msg) {
+    // Do nothing
+  }
+}
diff --git a/user/src/com/google/gwt/logging/impl/LoggerImplWarning.java b/user/src/com/google/gwt/logging/impl/LoggerImplWarning.java
new file mode 100644
index 0000000..3dbca61
--- /dev/null
+++ b/user/src/com/google/gwt/logging/impl/LoggerImplWarning.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.logging.impl;
+
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * Implementation for the Logger class when logging is enabled only at Warning and above.
+ */
+public class LoggerImplWarning extends LoggerImplRegular {
+  @Override
+  public void config(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void fine(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void finer(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void finest(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void info(String msg) {
+    // Do nothing
+  }
+
+  @Override
+  public void log(Level level, String msg) {
+    if (level.intValue() >= Level.WARNING.intValue()) {
+      super.log(level, msg);
+    }
+  }
+
+  @Override
+  public void log(Level level, String msg, Throwable thrown) {
+    if (level.intValue() >= Level.WARNING.intValue()) {
+      super.log(level, msg, thrown);
+    }
+  }
+
+  @Override
+  public void log(LogRecord record) {
+    if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
+      super.log(record);
+    }
+  }
+
+  @Override
+  public void severe(String msg) {
+    super.severe(msg);
+  }
+
+  @Override
+  public void warning(String msg) {
+    super.warning(msg);
+  }
+}
diff --git a/user/super/com/google/gwt/emul/java/util/logging/Level.java b/user/super/com/google/gwt/emul/java/util/logging/Level.java
index 3555df5..ea0781e 100644
--- a/user/super/com/google/gwt/emul/java/util/logging/Level.java
+++ b/user/super/com/google/gwt/emul/java/util/logging/Level.java
@@ -29,43 +29,83 @@
  */
 public class Level implements Serializable {
   private static LevelImpl staticImpl = GWT.create(LevelImplNull.class); 
-  public static Level ALL = staticImpl.all();
-  public static Level CONFIG = staticImpl.config(); 
-  public static Level FINE = staticImpl.fine(); 
-  public static Level FINER = staticImpl.finer(); 
-  public static Level FINEST = staticImpl.finest(); 
-  public static Level INFO = staticImpl.info(); 
-  public static Level OFF = staticImpl.off(); 
-  public static Level SEVERE = staticImpl.severe(); 
-  public static Level WARNING = staticImpl.warning();
+  public static Level ALL = GWT.create(LevelAll.class);
+  public static Level CONFIG = GWT.create(LevelConfig.class); 
+  public static Level FINE = GWT.create(LevelFine.class); 
+  public static Level FINER = GWT.create(LevelFiner.class); 
+  public static Level FINEST = GWT.create(LevelFinest.class); 
+  public static Level INFO = GWT.create(LevelInfo.class); 
+  public static Level OFF = GWT.create(LevelOff.class); 
+  public static Level SEVERE = GWT.create(LevelSevere.class); 
+  public static Level WARNING = GWT.create(LevelWarning.class);
   
+  private static class LevelAll extends Level {
+    @Override public String getName() { return "ALL"; }
+    @Override public int intValue() { return Integer.MIN_VALUE; }
+  }
+
+  private static class LevelConfig extends Level {
+    @Override public String getName() { return "CONFIG"; }
+    @Override public int intValue() { return 700; }
+  }
+  
+  private static class LevelFine extends Level {
+    @Override public String getName() { return "FINE"; }
+    @Override public int intValue() { return 500; }
+  }
+
+  private static class LevelFiner extends Level {
+    @Override public String getName() { return "FINER"; }
+    @Override public int intValue() { return 400; }
+  }
+
+  private static class LevelFinest extends Level {
+    @Override public String getName() { return "FINEST"; }
+    @Override public int intValue() { return 300; }
+  }  
+  
+  private static class LevelInfo extends Level {
+    @Override public String getName() { return "INFO"; }
+    @Override public int intValue() { return 800; }
+  }
+  
+  private static class LevelOff extends Level {
+    @Override public String getName() { return "OFF"; }
+    @Override public int intValue() { return Integer.MAX_VALUE; }
+  }
+
+  private static class LevelNull extends Level {
+    @Override public String getName() { return null; }
+    @Override public int intValue() { return -1; }
+  }
+  
+  private static class LevelSevere extends Level {
+    @Override public String getName() { return "SEVERE"; }
+    @Override public int intValue() { return 1000; }
+  }
+
+  private static class LevelWarning extends Level {
+    @Override public String getName() { return "WARNING"; }
+    @Override public int intValue() { return 900; }
+  }
+
   public static Level parse(String name) {
     return staticImpl.parse(name);
   } 
-  
-  private transient LevelImpl impl;
 
-  protected Level(String name, int value) {
-    impl = GWT.create(LevelImplNull.class);
-    impl.setName(name);
-    impl.setValue(value);
-  }
+  protected Level() { }
   
-  protected Level() {
-    // For serialization
-  }
-
   public String getName() {
-    return impl.getName();
+    return "DUMMY";
   }
   
   public int intValue() {
-    return impl.intValue();
+    return -1;
   }
     
   @Override
   public String toString() {
-    return impl.toString();
+    return getName();
   }
   
   /* Not Implemented */
@@ -74,5 +114,4 @@
   // public String getLocalizedName() {}
   // public String getResourceBundleName() {} 
   // public int  hashCode() {}
-  
 }