[jboss-svn-commits] JBoss Common SVN: r3070 - 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
Thu Mar 12 17:20:44 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-03-12 17:20:43 -0400 (Thu, 12 Mar 2009)
New Revision: 3070
Added:
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Slf4jLoggerFactory.java
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Slf4jMDCAdapter.java
Modified:
jboss-logmanager/trunk/pom.xml
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggerInstance.java
Log:
Direct slf4j support. not 100% that this is the right way to go but it makes some things easier...
Modified: jboss-logmanager/trunk/pom.xml
===================================================================
--- jboss-logmanager/trunk/pom.xml 2009-03-12 20:32:47 UTC (rev 3069)
+++ jboss-logmanager/trunk/pom.xml 2009-03-12 21:20:43 UTC (rev 3070)
@@ -8,7 +8,13 @@
<artifactId>jboss-logmanager</artifactId>
<packaging>jar</packaging>
<version>1.1.0.CR1</version>
- <dependencies/>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<plugin>
Modified: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggerInstance.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggerInstance.java 2009-03-12 20:32:47 UTC (rev 3069)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggerInstance.java 2009-03-12 21:20:43 UTC (rev 3070)
@@ -31,10 +31,13 @@
import java.util.logging.LogRecord;
import java.util.logging.Logger;
+import org.slf4j.spi.LocationAwareLogger;
+import org.slf4j.Marker;
+
/**
* An actual logger instance. This is the end-user interface into the logging system.
*/
-public class LoggerInstance extends Logger {
+public class LoggerInstance extends Logger implements LocationAwareLogger {
/**
* The named logger tree node.
@@ -294,6 +297,7 @@
}
private static final int OFF_INT = Level.OFF.intValue();
+
private static final int SEVERE_INT = Level.SEVERE.intValue();
private static final int WARNING_INT = Level.WARNING.intValue();
private static final int INFO_INT = Level.INFO.intValue();
@@ -302,6 +306,12 @@
private static final int FINER_INT = Level.FINER.intValue();
private static final int FINEST_INT = Level.FINEST.intValue();
+ private static final int ALT_ERROR_INT = org.jboss.logmanager.Level.ERROR.intValue();
+ private static final int ALT_WARN_INT = org.jboss.logmanager.Level.WARN.intValue();
+ private static final int ALT_INFO_INT = org.jboss.logmanager.Level.INFO.intValue();
+ private static final int ALT_DEBUG_INT = org.jboss.logmanager.Level.DEBUG.intValue();
+ private static final int ALT_TRACE_INT = org.jboss.logmanager.Level.TRACE.intValue();
+
/** {@inheritDoc} */
public void log(LogRecord record) {
final int effectiveLevel = this.effectiveLevel;
@@ -579,4 +589,488 @@
super.finalize();
}
}
+
+ // slf4j implementation
+
+ public void log(final Marker marker, final String fqcn, final int levelVal, final String message, final Throwable t) {
+ // ignore marker
+ final Level level;
+ switch (levelVal) {
+ case LocationAwareLogger.TRACE_INT: level = org.jboss.logmanager.Level.TRACE; break;
+ case LocationAwareLogger.DEBUG_INT: level = org.jboss.logmanager.Level.DEBUG; break;
+ case LocationAwareLogger.INFO_INT: level = org.jboss.logmanager.Level.INFO; break;
+ case LocationAwareLogger.WARN_INT: level = org.jboss.logmanager.Level.WARN; break;
+ case LocationAwareLogger.ERROR_INT: level = org.jboss.logmanager.Level.ERROR; break;
+ default: level = org.jboss.logmanager.Level.DEBUG; break;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(level, message, fqcn);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isTraceEnabled() {
+ return ALT_TRACE_INT < effectiveLevel;
+ }
+
+ public void trace(final String msg) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.TRACE, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void trace(final String format, final Object arg) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.TRACE, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void trace(final String format, final Object arg1, final Object arg2) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.TRACE, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void trace(final String format, final Object[] argArray) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.TRACE, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void trace(final String msg, final Throwable t) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.TRACE, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isTraceEnabled(final Marker marker) {
+ return ALT_TRACE_INT < effectiveLevel;
+ }
+
+ public void trace(final Marker marker, final String msg) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.TRACE, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void trace(final Marker marker, final String format, final Object arg) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.TRACE, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void trace(final Marker marker, final String format, final Object arg1, final Object arg2) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.TRACE, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void trace(final Marker marker, final String format, final Object[] argArray) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.TRACE, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void trace(final Marker marker, final String msg, final Throwable t) {
+ if (ALT_TRACE_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.TRACE, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isDebugEnabled() {
+ return ALT_DEBUG_INT < effectiveLevel;
+ }
+
+ public void debug(final String msg) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void debug(final String format, final Object arg) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void debug(final String format, final Object arg1, final Object arg2) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void debug(final String format, final Object[] argArray) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void debug(final String msg, final Throwable t) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isDebugEnabled(final Marker marker) {
+ return ALT_DEBUG_INT < effectiveLevel;
+ }
+
+ public void debug(final Marker marker, final String msg) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void debug(final Marker marker, final String format, final Object arg) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void debug(final Marker marker, final String format, final Object arg1, final Object arg2) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void debug(final Marker marker, final String format, final Object[] argArray) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void debug(final Marker marker, final String msg, final Throwable t) {
+ if (ALT_DEBUG_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.DEBUG, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isInfoEnabled() {
+ return ALT_INFO_INT < effectiveLevel;
+ }
+
+ // info(String) is defined above, and happens to be compatible
+
+ public void info(final String format, final Object arg) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.INFO, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void info(final String format, final Object arg1, final Object arg2) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.INFO, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void info(final String format, final Object[] argArray) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.INFO, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void info(final String msg, final Throwable t) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.INFO, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isInfoEnabled(final Marker marker) {
+ return ALT_INFO_INT < effectiveLevel;
+ }
+
+ public void info(final Marker marker, final String msg) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.INFO, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void info(final Marker marker, final String format, final Object arg) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.INFO, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void info(final Marker marker, final String format, final Object arg1, final Object arg2) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.INFO, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void info(final Marker marker, final String format, final Object[] argArray) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.INFO, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void info(final Marker marker, final String msg, final Throwable t) {
+ if (ALT_INFO_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.INFO, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isWarnEnabled() {
+ return ALT_WARN_INT < effectiveLevel;
+ }
+
+ public void warn(final String msg) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.WARN, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void warn(final String format, final Object arg) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.WARN, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void warn(final String format, final Object arg1, final Object arg2) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.WARN, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void warn(final String format, final Object[] argArray) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.WARN, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void warn(final String msg, final Throwable t) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.WARN, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isWarnEnabled(final Marker marker) {
+ return ALT_WARN_INT < effectiveLevel;
+ }
+
+ public void warn(final Marker marker, final String msg) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.WARN, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void warn(final Marker marker, final String format, final Object arg) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.WARN, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void warn(final Marker marker, final String format, final Object arg1, final Object arg2) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.WARN, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void warn(final Marker marker, final String format, final Object[] argArray) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.WARN, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void warn(final Marker marker, final String msg, final Throwable t) {
+ if (ALT_WARN_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.WARN, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isErrorEnabled() {
+ return ALT_ERROR_INT < effectiveLevel;
+ }
+
+ public void error(final String msg) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.ERROR, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void error(final String format, final Object arg) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.ERROR, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void error(final String format, final Object arg1, final Object arg2) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.ERROR, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void error(final String format, final Object[] argArray) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.ERROR, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void error(final String msg, final Throwable t) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.ERROR, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
+ public boolean isErrorEnabled(final Marker marker) {
+ return ALT_ERROR_INT < effectiveLevel;
+ }
+
+ public void error(final Marker marker, final String msg) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ doLog(new ExtLogRecord(org.jboss.logmanager.Level.ERROR, msg, LOGGER_CLASS_NAME));
+ }
+
+ public void error(final Marker marker, final String format, final Object arg) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.ERROR, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg });
+ doLog(rec);
+ }
+
+ public void error(final Marker marker, final String format, final Object arg1, final Object arg2) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.ERROR, format, LOGGER_CLASS_NAME);
+ rec.setParameters(new Object[] { arg1, arg2 });
+ doLog(rec);
+ }
+
+ public void error(final Marker marker, final String format, final Object[] argArray) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.ERROR, format, LOGGER_CLASS_NAME);
+ rec.setParameters(argArray);
+ doLog(rec);
+ }
+
+ public void error(final Marker marker, final String msg, final Throwable t) {
+ if (ALT_ERROR_INT < effectiveLevel) {
+ return;
+ }
+ final ExtLogRecord rec = new ExtLogRecord(org.jboss.logmanager.Level.ERROR, msg, LOGGER_CLASS_NAME);
+ rec.setThrown(t);
+ doLog(rec);
+ }
+
}
Added: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Slf4jLoggerFactory.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Slf4jLoggerFactory.java (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Slf4jLoggerFactory.java 2009-03-12 21:20:43 UTC (rev 3070)
@@ -0,0 +1,33 @@
+/*
+ * 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.slf4j.ILoggerFactory;
+import org.slf4j.Logger;
+
+public final class Slf4jLoggerFactory implements ILoggerFactory {
+
+ public Logger getLogger(final String name) {
+ return (Logger) LogContext.getLogContext().getLogger(name);
+ }
+}
Added: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Slf4jMDCAdapter.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Slf4jMDCAdapter.java (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/Slf4jMDCAdapter.java 2009-03-12 21:20:43 UTC (rev 3070)
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+public final class Slf4jMDCAdapter implements org.slf4j.spi.MDCAdapter {
+
+ public void put(final String key, final String val) {
+ MDC.put(key, val);
+ }
+
+ public String get(final String key) {
+ return MDC.get(key);
+ }
+
+ public void remove(final String key) {
+ MDC.remove(key);
+ }
+
+ public void clear() {
+ MDC.clear();
+ }
+
+ public Map getCopyOfContextMap() {
+ return MDC.copy();
+ }
+
+ public void setContextMap(final Map contextMap) {
+ MDC.clear();
+ for (Map.Entry<?, ?> entry : ((Map<?, ?>) contextMap).entrySet()) {
+ final Object key = entry.getKey();
+ final Object value = entry.getValue();
+ if (key != null && value != null) {
+ MDC.put(key.toString(), value.toString());
+ }
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list