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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 29 17:44:06 EDT 2010


Author: david.lloyd at jboss.com
Date: 2010-07-29 17:44:06 -0400 (Thu, 29 Jul 2010)
New Revision: 4813

Modified:
   jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LogContext.java
Log:
Provide a way to get an attachment without creating the corresponding logger

Modified: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LogContext.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LogContext.java	2010-07-29 21:41:19 UTC (rev 4812)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LogContext.java	2010-07-29 21:44:06 UTC (rev 4813)
@@ -123,6 +123,20 @@
     }
 
     /**
+     * Get a logger attachment for a logger name, if it exists.
+     *
+     * @param loggerName the logger name
+     * @param key the attachment key
+     * @param <V> the attachment value type
+     * @return the attachment or {@code null} if the logger or the attachment does not exist
+     */
+    public <V> V getAttachment(String loggerName, Logger.AttachmentKey<V> key) {
+        final LoggerNode node = rootLogger.getIfExists(loggerName);
+        if (node == null) return null;
+        return node.getAttachment(key);
+    }
+
+    /**
      * Get the {@code LoggingMXBean} associated with this log context.
      *
      * @return the {@code LoggingMXBean} instance



More information about the jboss-svn-commits mailing list