[jboss-svn-commits] JBoss Common SVN: r3274 - in common-logging-logmanager/trunk: src and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jun 16 23:16:44 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-06-16 23:16:44 -0400 (Tue, 16 Jun 2009)
New Revision: 3274
Added:
common-logging-logmanager/trunk/src/
common-logging-logmanager/trunk/src/main/
common-logging-logmanager/trunk/src/main/java/
common-logging-logmanager/trunk/src/main/java/org/
common-logging-logmanager/trunk/src/main/java/org/jboss/
common-logging-logmanager/trunk/src/main/java/org/jboss/logging/
common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/
common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginImpl.java
common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/MDCProviderImpl.java
common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/NDCProviderImpl.java
Log:
Initial import of common-logging-logmanager
Added: common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginImpl.java
===================================================================
--- common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginImpl.java (rev 0)
+++ common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginImpl.java 2009-06-17 03:16:44 UTC (rev 3274)
@@ -0,0 +1,163 @@
+/*
+ * 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.logging.logmanager;
+
+import org.jboss.logging.LoggerPlugin;
+import org.jboss.logging.MDCProvider;
+import org.jboss.logging.MDCSupport;
+import org.jboss.logging.NDCProvider;
+import org.jboss.logging.NDCSupport;
+import org.jboss.logmanager.Logger;
+import org.jboss.logmanager.Level;
+
+/**
+ * The JBoss Common Logging plugin implementation.
+ */
+public final class LoggerPluginImpl implements LoggerPlugin, NDCSupport, MDCSupport {
+
+ private Logger logger;
+
+ private static final String FQCN = org.jboss.logging.Logger.class.getName();
+
+ /** {@inheritDoc} */
+ public void init(final String name) {
+ logger = Logger.getLogger(name);
+ }
+
+ /** {@inheritDoc} */
+ public boolean isTraceEnabled() {
+ return logger.isLoggable(Level.TRACE);
+ }
+
+ /** {@inheritDoc} */
+ public void trace(final Object message) {
+ logger.log(FQCN, Level.TRACE, String.valueOf(message), null);
+ }
+
+ /** {@inheritDoc} */
+ public void trace(final Object message, final Throwable t) {
+ logger.log(FQCN, Level.TRACE, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void trace(final String loggerFcqn, final Object message, final Throwable t) {
+ logger.log(loggerFcqn, Level.TRACE, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ @Deprecated
+ public boolean isDebugEnabled() {
+ return logger.isLoggable(Level.DEBUG);
+ }
+
+ /** {@inheritDoc} */
+ public void debug(final Object message) {
+ logger.log(FQCN, Level.DEBUG, String.valueOf(message), null);
+ }
+
+ /** {@inheritDoc} */
+ public void debug(final Object message, final Throwable t) {
+ logger.log(FQCN, Level.DEBUG, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void debug(final String loggerFcqn, final Object message, final Throwable t) {
+ logger.log(loggerFcqn, Level.DEBUG, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ @Deprecated
+ public boolean isInfoEnabled() {
+ return logger.isLoggable(Level.INFO);
+ }
+
+ /** {@inheritDoc} */
+ public void info(final Object message) {
+ logger.log(FQCN, Level.INFO, String.valueOf(message), null);
+ }
+
+ /** {@inheritDoc} */
+ public void info(final Object message, final Throwable t) {
+ logger.log(FQCN, Level.INFO, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void info(final String loggerFcqn, final Object message, final Throwable t) {
+ logger.log(loggerFcqn, Level.INFO, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void warn(final Object message) {
+ logger.log(FQCN, Level.WARN, String.valueOf(message), null);
+ }
+
+ /** {@inheritDoc} */
+ public void warn(final Object message, final Throwable t) {
+ logger.log(FQCN, Level.WARN, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void warn(final String loggerFcqn, final Object message, final Throwable t) {
+ logger.log(loggerFcqn, Level.WARN, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void error(final Object message) {
+ logger.log(FQCN, Level.ERROR, String.valueOf(message), null);
+ }
+
+ /** {@inheritDoc} */
+ public void error(final Object message, final Throwable t) {
+ logger.log(FQCN, Level.ERROR, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void error(final String loggerFcqn, final Object message, final Throwable t) {
+ logger.log(loggerFcqn, Level.ERROR, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void fatal(final Object message) {
+ logger.log(FQCN, Level.FATAL, String.valueOf(message), null);
+ }
+
+ /** {@inheritDoc} */
+ public void fatal(final Object message, final Throwable t) {
+ logger.log(FQCN, Level.FATAL, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public void fatal(final String loggerFcqn, final Object message, final Throwable t) {
+ logger.log(loggerFcqn, Level.FATAL, String.valueOf(message), t);
+ }
+
+ /** {@inheritDoc} */
+ public NDCProvider getNDCProvider() {
+ return NDCProviderImpl.getInstance();
+ }
+
+ /** {@inheritDoc} */
+ public MDCProvider getMDCProvider() {
+ return MDCProviderImpl.getInstance();
+ }
+}
Added: common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/MDCProviderImpl.java
===================================================================
--- common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/MDCProviderImpl.java (rev 0)
+++ common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/MDCProviderImpl.java 2009-06-17 03:16:44 UTC (rev 3274)
@@ -0,0 +1,54 @@
+/*
+ * 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.logging.logmanager;
+
+import java.util.Map;
+import org.jboss.logging.MDCProvider;
+import org.jboss.logmanager.MDC;
+
+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: common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/NDCProviderImpl.java
===================================================================
--- common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/NDCProviderImpl.java (rev 0)
+++ common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/NDCProviderImpl.java 2009-06-17 03:16:44 UTC (rev 3274)
@@ -0,0 +1,63 @@
+/*
+ * 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.logging.logmanager;
+
+import org.jboss.logging.NDCProvider;
+import org.jboss.logmanager.NDC;
+
+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