[jboss-svn-commits] JBoss Common SVN: r3334 - jboss-logmanager/trunk/src/main/java/org/jboss/logmanager.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 7 22:20:30 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-07-07 22:20:30 -0400 (Tue, 07 Jul 2009)
New Revision: 3334

Modified:
   jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ExtHandler.java
   jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Logger.java
Log:
Add Logger.setLevelByName(), ExtHandler.setHandlers() convenience methods

Modified: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ExtHandler.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ExtHandler.java	2009-07-05 18:38:02 UTC (rev 3333)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/ExtHandler.java	2009-07-08 02:20:30 UTC (rev 3334)
@@ -109,8 +109,9 @@
     }
 
     /**
-     * A convenience method to atomically get and clear all handlers.
+     * A convenience method to atomically get and clear all sub-handlers.
      *
+     * @return the old sub-handler array
      * @throws SecurityException if a security manager exists and if the caller does not have {@code LoggingPermission(control)}
      */
     public Handler[] clearHandlers() throws SecurityException {
@@ -121,6 +122,23 @@
     }
 
     /**
+     * A convenience method to atomically get and replace the sub-handler array.
+     *
+     * @param newHandlers the new sub-handlers
+     * @return the old sub-handler array
+     * @throws SecurityException if a security manager exists and if the caller does not have {@code LoggingPermission(control)}
+     */
+    public Handler[] setHandlers(final Handler[] newHandlers) throws SecurityException {
+        if (newHandlers.length == 0) {
+            return clearHandlers();
+        } else {
+            checkAccess();
+            final Handler[] handlers = handlersUpdater.getAndSet(this, newHandlers);
+            return handlers.length > 0 ? handlers.clone() : handlers;
+        }
+    }
+
+    /**
      * Determine if this handler will auto-flush.
      *
      * @return {@code true} if auto-flush is enabled

Modified: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Logger.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Logger.java	2009-07-05 18:38:02 UTC (rev 3333)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Logger.java	2009-07-08 02:20:30 UTC (rev 3334)
@@ -165,6 +165,17 @@
     }
 
     /**
+     * Set the log level by name.  Uses the parent logging context's name registry; otherwise behaves
+     * identically to {@link #setLevel(Level)}.
+     *
+     * @param newLevelName the name of the level to set
+     * @throws SecurityException if a security manager exists and if the caller does not have LoggingPermission("control")
+     */
+    public void setLevelName(String newLevelName) throws SecurityException {
+        setLevel(loggerNode.getContext().getLevelForName(newLevelName));
+    }
+
+    /**
      * Update the effective level if it is inherited from a parent.  Must only be called while the logmanager's level
      * change lock is held.
      *




More information about the jboss-svn-commits mailing list