[jboss-svn-commits] JBoss Common SVN: r3110 - in jboss-logmanager/trunk: src/main/java/org/jboss/logmanager and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Apr 13 19:24:25 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-04-13 19:24:25 -0400 (Mon, 13 Apr 2009)
New Revision: 3110

Added:
   jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggerPluginImpl.java
   jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/MDCProviderImpl.java
   jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/NDCProviderImpl.java
Modified:
   jboss-logmanager/trunk/pom.xml
Log:
Add direct support for jboss common-logging-spi

Modified: jboss-logmanager/trunk/pom.xml
===================================================================
--- jboss-logmanager/trunk/pom.xml	2009-04-13 23:17:29 UTC (rev 3109)
+++ jboss-logmanager/trunk/pom.xml	2009-04-13 23:24:25 UTC (rev 3110)
@@ -19,7 +19,14 @@
             <artifactId>testng</artifactId>
             <version>5.8</version>
             <classifier>jdk15</classifier>
+            <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.jboss.logging</groupId>
+            <artifactId>jboss-logging-spi</artifactId>
+            <version>2.0.5.GA</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

Added: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggerPluginImpl.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggerPluginImpl.java	                        (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggerPluginImpl.java	2009-04-13 23:24:25 UTC (rev 3110)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.logmanager;
+
+import org.jboss.logging.LoggerPlugin;
+import org.jboss.logging.NDCSupport;
+import org.jboss.logging.MDCSupport;
+import org.jboss.logging.NDCProvider;
+import org.jboss.logging.MDCProvider;
+
+public final class LoggerPluginImpl implements LoggerPlugin, NDCSupport, MDCSupport {
+
+    private Logger logger;
+
+    public void init(final String name) {
+        logger = Logger.getLogger(name);
+    }
+
+    public boolean isTraceEnabled() {
+        return logger.isTraceEnabled();
+    }
+
+    public void trace(final Object message) {
+        logger.trace(String.valueOf(message));
+    }
+
+    public void trace(final Object message, final Throwable t) {
+        logger.trace(String.valueOf(message), t);
+    }
+
+    @Deprecated
+    public boolean isDebugEnabled() {
+        return logger.isDebugEnabled();
+    }
+
+    public void debug(final Object message) {
+        logger.debug(String.valueOf(message));
+    }
+
+    public void debug(final Object message, final Throwable t) {
+        logger.debug(String.valueOf(message), t);
+    }
+
+    @Deprecated
+    public boolean isInfoEnabled() {
+        return logger.isInfoEnabled();
+    }
+
+    public void info(final Object message) {
+        logger.info(String.valueOf(message));
+    }
+
+    public void info(final Object message, final Throwable t) {
+        logger.info(String.valueOf(message), t);
+    }
+
+    public void warn(final Object message) {
+        logger.warn(String.valueOf(message));
+    }
+
+    public void warn(final Object message, final Throwable t) {
+        logger.warn(String.valueOf(message), t);
+    }
+
+    public void error(final Object message) {
+        logger.error(String.valueOf(message));
+    }
+
+    public void error(final Object message, final Throwable t) {
+        logger.error(String.valueOf(message), t);
+    }
+
+    public void fatal(final Object message) {
+        logger.fatal(String.valueOf(message));
+    }
+
+    public void fatal(final Object message, final Throwable t) {
+        logger.fatal(String.valueOf(message), t);
+    }
+
+    public NDCProvider getNDCProvider() {
+        return NDCProviderImpl.getInstance();
+    }
+
+    public MDCProvider getMDCProvider() {
+        return MDCProviderImpl.getInstance();
+    }
+}

Added: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/MDCProviderImpl.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/MDCProviderImpl.java	                        (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/MDCProviderImpl.java	2009-04-13 23:24:25 UTC (rev 3110)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.logmanager;
+
+import java.util.Map;
+import org.jboss.logging.MDCProvider;
+
+public final class MDCProviderImpl implements MDCProvider {
+
+    public void put(final String key, final Object value) {
+        MDC.put(key, String.valueOf(value));
+    }
+
+    public Object get(final String key) {
+        return MDC.get(key);
+    }
+
+    public void remove(final String key) {
+        MDC.remove(key);
+    }
+
+    @SuppressWarnings({ "unchecked" })
+    public Map<String, Object> getMap() {
+        // we can re-define the erasure of this map because MDC does not make further use of the copy
+        return (Map)MDC.copy();
+    }
+
+    private static final MDCProvider instance = new MDCProviderImpl();
+
+    public static MDCProvider getInstance() {
+        return instance;
+    }
+}

Added: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/NDCProviderImpl.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/NDCProviderImpl.java	                        (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/NDCProviderImpl.java	2009-04-13 23:24:25 UTC (rev 3110)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.logmanager;
+
+import org.jboss.logging.NDCProvider;
+
+public final class NDCProviderImpl implements NDCProvider {
+
+    public void clear() {
+        NDC.clear();
+    }
+
+    public String get() {
+        return NDC.get();
+    }
+
+    public int getDepth() {
+        return NDC.getDepth();
+    }
+
+    public String pop() {
+        return NDC.pop();
+    }
+
+    public String peek() {
+        return NDC.get();
+    }
+
+    public void push(final String message) {
+        NDC.push(message);
+    }
+
+    public void setMaxDepth(final int maxDepth) {
+        NDC.trimTo(maxDepth);
+    }
+
+    private static final NDCProvider instance = new NDCProviderImpl();
+
+    public static NDCProvider getInstance() {
+        return instance;
+    }
+}




More information about the jboss-svn-commits mailing list