[jboss-svn-commits] JBoss Common SVN: r3384 - in common-logging-logmanager/trunk: src/main/java/org/jboss/logging/logmanager and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 22 15:21:29 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-07-22 15:21:28 -0400 (Wed, 22 Jul 2009)
New Revision: 3384
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/LoggerPluginInstanceImpl.java
Removed:
common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginImpl.java
Modified:
common-logging-logmanager/trunk/pom.xml
Log:
Add proper localization API; add capability to cache logger instances by breaking up the LoggerPlugin interface
Modified: common-logging-logmanager/trunk/pom.xml
===================================================================
--- common-logging-logmanager/trunk/pom.xml 2009-07-22 19:21:19 UTC (rev 3383)
+++ common-logging-logmanager/trunk/pom.xml 2009-07-22 19:21:28 UTC (rev 3384)
@@ -28,7 +28,7 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-logmanager</artifactId>
- <version>1.0.0.CR3-SNAPSHOT</version>
+ <version>2.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<url>http://www.jboss.org</url>
<description>JBoss Logging LogManager Implementation</description>
@@ -36,12 +36,12 @@
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-spi</artifactId>
- <version>2.1.0.GA</version>
+ <version>2.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
- <version>1.1.0.CR3</version>
+ <version>1.1.0.CR5-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
Deleted: 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 2009-07-22 19:21:19 UTC (rev 3383)
+++ common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginImpl.java 2009-07-22 19:21:28 UTC (rev 3384)
@@ -1,163 +0,0 @@
-/*
- * 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/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-07-22 19:21:28 UTC (rev 3384)
@@ -0,0 +1,64 @@
+/*
+ * 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.LoggerPluginInstance;
+import org.jboss.logging.MDCProvider;
+import org.jboss.logging.NDCProvider;
+import org.jboss.logmanager.Logger;
+
+/**
+ *
+ */
+public class LoggerPluginImpl implements LoggerPlugin {
+ private final MDCProvider mdcProvider;
+ private final NDCProvider ndcProvider;
+ private static final Logger.AttachmentKey<LoggerPluginInstance> KEY = new Logger.AttachmentKey<LoggerPluginInstance>();
+
+ public LoggerPluginImpl() {
+ mdcProvider = new MDCProviderImpl();
+ ndcProvider = new NDCProviderImpl();
+ }
+
+ public LoggerPluginInstance getInstance(String name) {
+ Logger logger = Logger.getLogger(name);
+ LoggerPluginInstance lpi = logger.getAttachment(KEY);
+ if (lpi == null) {
+ lpi = new LoggerPluginInstanceImpl(logger);
+ LoggerPluginInstance appeared = logger.attachIfAbsent(KEY, lpi);
+ if (appeared != null) {
+ return appeared;
+ }
+ }
+ return lpi;
+ }
+
+ public MDCProvider getMDCProvider() {
+ return mdcProvider;
+ }
+
+ public NDCProvider getNDCProvider() {
+ return ndcProvider;
+ }
+}
Copied: common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginInstanceImpl.java (from rev 3274, common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginImpl.java)
===================================================================
--- common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginInstanceImpl.java (rev 0)
+++ common-logging-logmanager/trunk/src/main/java/org/jboss/logging/logmanager/LoggerPluginInstanceImpl.java 2009-07-22 19:21:28 UTC (rev 3384)
@@ -0,0 +1,153 @@
+/*
+ * 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.*;
+import org.jboss.logmanager.Logger;
+import org.jboss.logmanager.Level;
+import org.jboss.logmanager.ExtLogRecord;
+
+/**
+ * The JBoss Common Logging plugin implementation.
+ */
+public final class LoggerPluginInstanceImpl implements LoggerPluginInstance {
+
+ private final Logger logger;
+
+ public LoggerPluginInstanceImpl(Logger logger) {
+ this.logger = logger;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isTraceEnabled() {
+ return logger.isLoggable(Level.TRACE);
+ }
+
+ public void trace(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.TRACE, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.TRACE, String.valueOf(message), ExtLogRecord.FormatStyle.MESSAGE_FORMAT, params, t);
+ }
+ }
+
+ public void tracef(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.TRACE, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.TRACE, String.valueOf(message), ExtLogRecord.FormatStyle.PRINTF, params, t);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Deprecated
+ public boolean isDebugEnabled() {
+ return logger.isLoggable(Level.DEBUG);
+ }
+
+ public void debug(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.DEBUG, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.DEBUG, String.valueOf(message), ExtLogRecord.FormatStyle.MESSAGE_FORMAT, params, t);
+ }
+ }
+
+ public void debugf(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.DEBUG, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.DEBUG, String.valueOf(message), ExtLogRecord.FormatStyle.PRINTF, params, t);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Deprecated
+ public boolean isInfoEnabled() {
+ return logger.isLoggable(Level.INFO);
+ }
+
+ public void info(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.INFO, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.INFO, String.valueOf(message), ExtLogRecord.FormatStyle.MESSAGE_FORMAT, params, t);
+ }
+ }
+
+ public void infof(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.INFO, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.INFO, String.valueOf(message), ExtLogRecord.FormatStyle.PRINTF, params, t);
+ }
+ }
+
+ public void warn(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.WARN, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.WARN, String.valueOf(message), ExtLogRecord.FormatStyle.MESSAGE_FORMAT, params, t);
+ }
+ }
+
+ public void warnf(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.WARN, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.WARN, String.valueOf(message), ExtLogRecord.FormatStyle.PRINTF, params, t);
+ }
+ }
+
+ public void error(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.ERROR, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.ERROR, String.valueOf(message), ExtLogRecord.FormatStyle.MESSAGE_FORMAT, params, t);
+ }
+ }
+
+ public void errorf(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.ERROR, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.ERROR, String.valueOf(message), ExtLogRecord.FormatStyle.PRINTF, params, t);
+ }
+ }
+
+ public void fatal(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.FATAL, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.FATAL, String.valueOf(message), ExtLogRecord.FormatStyle.MESSAGE_FORMAT, params, t);
+ }
+ }
+
+ public void fatalf(String loggerFcqn, Object message, Object[] params, Throwable t) {
+ if (params == null) {
+ logger.log(loggerFcqn, Level.FATAL, String.valueOf(message), t);
+ } else {
+ logger.log(loggerFcqn, Level.FATAL, String.valueOf(message), ExtLogRecord.FormatStyle.PRINTF, params, t);
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list