diff --git a/jul-to-slf4j/pom.xml b/jul-to-slf4j/pom.xml index b18742fb9..b5f71226e 100644 --- a/jul-to-slf4j/pom.xml +++ b/jul-to-slf4j/pom.xml @@ -23,24 +23,16 @@ - + org.slf4j slf4j-api - - + + org.slf4j slf4j-log4j12 ${project.version} test - - - - org.slf4j - jcl104-over-slf4j - ${project.version} - test - - + diff --git a/pom.xml b/pom.xml index 3c1186e7a..306e2196c 100644 --- a/pom.xml +++ b/pom.xml @@ -138,6 +138,11 @@ org.apache.log4j + + java.util.logging (JUL) to SLF4J bridge + org.slf4j.bridge + + diff --git a/slf4j-osgi-integration-test/pom.xml b/slf4j-osgi-integration-test/pom.xml index f7fa1c2bc..5cc867908 100644 --- a/slf4j-osgi-integration-test/pom.xml +++ b/slf4j-osgi-integration-test/pom.xml @@ -1,240 +1,240 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-osgi-integration-test - jar - SLF4J OSGi Integration Test - - http://www.slf4j.org - - OSGi integration tests for the slf4j. - - - - - - org.apache.felix - javax.servlet - 0.8.0-SNAPSHOT - test - - - - org.osgi - org.osgi.compendium - 4.0 - provided - - - - junit - junit - 3.8.1 - test - - - org.slf4j - slf4j-osgi-test-bundle - ${parent.version} - test - - - org.springframework.osgi - org.springframework.osgi.test - 1.0-SNAPSHOT - provided - - - org.springframework.osgi - spring-core - 2.1-SNAPSHOT - provided - - - org.springframework.osgi - spring-context - 2.1-SNAPSHOT - provided - - - org.springframework.osgi - spring-beans - 2.1-SNAPSHOT - provided - - - - - org.springframework.osgi - spring-mock - 2.1-SNAPSHOT - jar - test - - - org.springframework.osgi - jcl104-over-slf4j.osgi - 1.1.0 - provided - - - org.slf4j - slf4j-log4j-full - 1.1.0 - provided - - - org.springframework.osgi - log4j.osgi - 1.2.13-SNAPSHOT - test - - - org.springframework.osgi - backport-util-concurrent - 3.0-SNAPSHOT - test - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - org.springframework.osgi.test.framework - ${osgi.test.platform} - - - org.osgi.framework.system.packages - ${osgi.test.system.packages} - - - - - - - default - test - - - - integration-test - integration-test - - test - - - false - pertest - - - - - - - - - equinox - - true - - - - org.eclipse.equinox - org.eclipse.osgi - 3.2.0 - jar - provided - - - - org.xml.sax, org.w3c.dom, javax.xml.parsers, javax.naming, javax.management - equinox - - - - knopflerfish - - - org.knopflerfish - framework - 2.0.1 - jar - provided - - - - - org.xml.sax, org.w3c.dom, javax.xml.parsers, javax.naming, javax.management - knopflerfish - - - - felix - - - org.apache.felix - org.apache.felix.framework - 0.8.0-SNAPSHOT - jar - provided - - - org.apache.felix - org.apache.felix.main - 0.8.0-SNAPSHOT - jar - provided - - - org.apache.felix - org.osgi.core - 0.8.0-SNAPSHOT - jar - runtime - - - - felix - - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + + org.slf4j + slf4j-parent + 1.5.1 + + + 4.0.0 + + org.slf4j + slf4j-osgi-integration-test + jar + SLF4J OSGi Integration Test + + http://www.slf4j.org + + OSGi integration tests for the slf4j. + + + + + + org.apache.felix + javax.servlet + 0.8.0-SNAPSHOT + test + + + + org.osgi + org.osgi.compendium + 4.0 + provided + + + + junit + junit + 3.8.1 + test + + + org.slf4j + slf4j-osgi-test-bundle + ${parent.version} + test + + + org.springframework.osgi + org.springframework.osgi.test + 1.0-SNAPSHOT + provided + + + org.springframework.osgi + spring-core + 2.1-SNAPSHOT + provided + + + org.springframework.osgi + spring-context + 2.1-SNAPSHOT + provided + + + org.springframework.osgi + spring-beans + 2.1-SNAPSHOT + provided + + + + + org.springframework.osgi + spring-mock + 2.1-SNAPSHOT + jar + test + + + org.springframework.osgi + jcl104-over-slf4j.osgi + 1.1.0 + provided + + + org.slf4j + slf4j-log4j-full + 1.1.0 + provided + + + org.springframework.osgi + log4j.osgi + 1.2.13-SNAPSHOT + test + + + org.springframework.osgi + backport-util-concurrent + 3.0-SNAPSHOT + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + org.springframework.osgi.test.framework + ${osgi.test.platform} + + + org.osgi.framework.system.packages + ${osgi.test.system.packages} + + + + + + + default + test + + + + integration-test + integration-test + + test + + + false + pertest + + + + + + + + + equinox + + true + + + + org.eclipse.equinox + org.eclipse.osgi + 3.2.0 + jar + provided + + + + org.xml.sax, org.w3c.dom, javax.xml.parsers, javax.naming, javax.management + equinox + + + + knopflerfish + + + org.knopflerfish + framework + 2.0.1 + jar + provided + + + + + org.xml.sax, org.w3c.dom, javax.xml.parsers, javax.naming, javax.management + knopflerfish + + + + felix + + + org.apache.felix + org.apache.felix.framework + 0.8.0-SNAPSHOT + jar + provided + + + org.apache.felix + org.apache.felix.main + 0.8.0-SNAPSHOT + jar + provided + + + org.apache.felix + org.osgi.core + 0.8.0-SNAPSHOT + jar + runtime + + + + felix + + + + \ No newline at end of file diff --git a/slf4j-osgi-test-bundle/pom.xml b/slf4j-osgi-test-bundle/pom.xml index 1bd90f4ce..ad6e22879 100644 --- a/slf4j-osgi-test-bundle/pom.xml +++ b/slf4j-osgi-test-bundle/pom.xml @@ -39,7 +39,7 @@ commons logging testing.--> org.slf4j - jcl104-over-slf4j + jcl-over-slf4j ${project.version} provided diff --git a/trunk/LICENSE.txt b/trunk/LICENSE.txt deleted file mode 100644 index f1c9e3707..000000000 --- a/trunk/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2004-2008 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - diff --git a/trunk/TODO.txt b/trunk/TODO.txt deleted file mode 100644 index db909b926..000000000 --- a/trunk/TODO.txt +++ /dev/null @@ -1,15 +0,0 @@ - -TODO ITEMS -========== - -- FAQ using maven. -- javadoc aggregation. -- support for log4j 1.3 - -DONE ITEMS -========== - -- Add X11 license. - - - diff --git a/trunk/codeStyle.xml b/trunk/codeStyle.xml deleted file mode 100644 index 21b42b61c..000000000 --- a/trunk/codeStyle.xml +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/goVersion.sh b/trunk/goVersion.sh deleted file mode 100644 index 9c6706859..000000000 --- a/trunk/goVersion.sh +++ /dev/null @@ -1,7 +0,0 @@ - -VER=$1 -echo "Will use version $VER" - -find . -name "pom.xml" |grep -v archetype-resources|xargs perl version.pl $VER - -#perl version.pl $VER ./slf4j-site/src/site/site.xml \ No newline at end of file diff --git a/trunk/jcl-over-slf4j/LICENSE.txt b/trunk/jcl-over-slf4j/LICENSE.txt deleted file mode 100644 index 21254fc75..000000000 --- a/trunk/jcl-over-slf4j/LICENSE.txt +++ /dev/null @@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/trunk/jcl-over-slf4j/pom.xml b/trunk/jcl-over-slf4j/pom.xml deleted file mode 100644 index e7e7e02e4..000000000 --- a/trunk/jcl-over-slf4j/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - jcl-over-slf4j - jar - JCL 1.1.1 implemented over SLF4J - - http://www.slf4j.org - - JCL 1.1.1 implementation over SLF4J - - - - - org.slf4j - slf4j-simple - ${project.version} - provided - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.version} - ${project.description} - ${project.version} - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - - - \ No newline at end of file diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/Log.java b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/Log.java deleted file mode 100644 index ed5b0ed2b..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/Log.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.commons.logging; - -/** - *

A simple logging interface abstracting logging APIs. In order to be - * instantiated successfully by {@link LogFactory}, classes that implement - * this interface must have a constructor that takes a single String - * parameter representing the "name" of this Log.

- * - *

The six logging levels used by Log are (in order): - *

    - *
  1. trace (the least serious)
  2. - *
  3. debug
  4. - *
  5. info
  6. - *
  7. warn
  8. - *
  9. error
  10. - *
  11. fatal (the most serious)
  12. - *
- * The mapping of these log levels to the concepts used by the underlying - * logging system is implementation dependent. - * The implemention should ensure, though, that this ordering behaves - * as expected.

- * - *

Performance is often a logging concern. - * By examining the appropriate property, - * a component can avoid expensive operations (producing information - * to be logged).

- * - *

For example, - *

- *    if (log.isDebugEnabled()) {
- *        ... do something expensive ...
- *        log.debug(theResult);
- *    }
- * 
- *

- * - *

Configuration of the underlying logging system will generally be done - * external to the Logging APIs, through whatever mechanism is supported by - * that system.

- * - *

Please note that this interface is identical to that found in JCL 1.0.4.

- * - * @author Scott Sanders - * @author Rod Waldhoff - * @version $Id: Log.java,v 1.19 2004/06/06 21:16:04 rdonkin Exp $ - */ -public interface Log { - - - // ----------------------------------------------------- Logging Properties - - - /** - *

Is debug logging currently enabled?

- * - *

Call this method to prevent having to perform expensive operations - * (for example, String concatenation) - * when the log level is more than debug.

- */ - public boolean isDebugEnabled(); - - - /** - *

Is error logging currently enabled?

- * - *

Call this method to prevent having to perform expensive operations - * (for example, String concatenation) - * when the log level is more than error.

- */ - public boolean isErrorEnabled(); - - - /** - *

Is fatal logging currently enabled?

- * - *

Call this method to prevent having to perform expensive operations - * (for example, String concatenation) - * when the log level is more than fatal.

- */ - public boolean isFatalEnabled(); - - - /** - *

Is info logging currently enabled?

- * - *

Call this method to prevent having to perform expensive operations - * (for example, String concatenation) - * when the log level is more than info.

- */ - public boolean isInfoEnabled(); - - - /** - *

Is trace logging currently enabled?

- * - *

Call this method to prevent having to perform expensive operations - * (for example, String concatenation) - * when the log level is more than trace.

- */ - public boolean isTraceEnabled(); - - - /** - *

Is warn logging currently enabled?

- * - *

Call this method to prevent having to perform expensive operations - * (for example, String concatenation) - * when the log level is more than warn.

- */ - public boolean isWarnEnabled(); - - - // -------------------------------------------------------- Logging Methods - - - /** - *

Log a message with trace log level.

- * - * @param message log this message - */ - public void trace(Object message); - - - /** - *

Log an error with trace log level.

- * - * @param message log this message - * @param t log this cause - */ - public void trace(Object message, Throwable t); - - - /** - *

Log a message with debug log level.

- * - * @param message log this message - */ - public void debug(Object message); - - - /** - *

Log an error with debug log level.

- * - * @param message log this message - * @param t log this cause - */ - public void debug(Object message, Throwable t); - - - /** - *

Log a message with info log level.

- * - * @param message log this message - */ - public void info(Object message); - - - /** - *

Log an error with info log level.

- * - * @param message log this message - * @param t log this cause - */ - public void info(Object message, Throwable t); - - - /** - *

Log a message with warn log level.

- * - * @param message log this message - */ - public void warn(Object message); - - - /** - *

Log an error with warn log level.

- * - * @param message log this message - * @param t log this cause - */ - public void warn(Object message, Throwable t); - - - /** - *

Log a message with error log level.

- * - * @param message log this message - */ - public void error(Object message); - - - /** - *

Log an error with error log level.

- * - * @param message log this message - * @param t log this cause - */ - public void error(Object message, Throwable t); - - - /** - *

Log a message with fatal log level.

- * - * @param message log this message - */ - public void fatal(Object message); - - - /** - *

Log an error with fatal log level.

- * - * @param message log this message - * @param t log this cause - */ - public void fatal(Object message, Throwable t); - - -} diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogConfigurationException.java b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogConfigurationException.java deleted file mode 100644 index 02d28cdfd..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogConfigurationException.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.logging; - - -/** - *

An exception that is thrown only if a suitable LogFactory - * or Log instance cannot be created by the corresponding - * factory methods.

- * - *

In this version of JCL, this exception will never be thrown in practice. However, it is - * included here to ensure total compile time and run time compatibility with the original JCL 1.0.4. - * - * @author Craig R. McClanahan - */ - -public class LogConfigurationException extends RuntimeException { - - - /** - * Construct a new exception with null as its detail message. - */ - public LogConfigurationException() { - - super(); - - } - - - /** - * Construct a new exception with the specified detail message. - * - * @param message The detail message - */ - public LogConfigurationException(String message) { - - super(message); - - } - - - /** - * Construct a new exception with the specified cause and a derived - * detail message. - * - * @param cause The underlying cause - */ - public LogConfigurationException(Throwable cause) { - - this((cause == null) ? null : cause.toString(), cause); - - } - - - /** - * Construct a new exception with the specified detail message and cause. - * - * @param message The detail message - * @param cause The underlying cause - */ - public LogConfigurationException(String message, Throwable cause) { - - super(message + " (Caused by " + cause + ")"); - this.cause = cause; // Two-argument version requires JDK 1.4 or later - - } - - - /** - * The underlying cause of this exception. - */ - protected Throwable cause = null; - - - /** - * Return the underlying cause of this exception (if any). - */ - public Throwable getCause() { - - return (this.cause); - - } - - -} diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java deleted file mode 100644 index a839b1fec..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.logging; - -import java.util.Hashtable; - -import org.apache.commons.logging.impl.SLF4JLogFactory; - -/** - *

- * Factory for creating {@link Log} instances, which always delegates to an - * instance of {@link SLF4JLogFactory}. - * - *

- * - * @author Craig R. McClanahan - * @author Costin Manolache - * @author Richard A. Sitze - * @author Ceki Gülcü - */ - -public abstract class LogFactory { - - static String UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J = "http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j"; - - static LogFactory logFactory = new SLF4JLogFactory(); - - /** - * The name (priority) of the key in the config file used to - * specify the priority of that particular config file. The associated value - * is a floating-point number; higher values take priority over lower values. - * - *

- * This property is not used but preserved here for compatibility. - */ - public static final String PRIORITY_KEY = "priority"; - - /** - * The name (use_tccl) of the key in the config file used to - * specify whether logging classes should be loaded via the thread context - * class loader (TCCL), or not. By default, the TCCL is used. - * - *

- * This property is not used but preserved here for compatibility. - */ - public static final String TCCL_KEY = "use_tccl"; - - /** - * The name of the property used to identify the LogFactory implementation - * class name. - *

- * This property is not used but preserved here for compatibility. - */ - public static final String FACTORY_PROPERTY = "org.apache.commons.logging.LogFactory"; - - /** - * The fully qualified class name of the fallback LogFactory - * implementation class to use, if no other can be found. - * - *

- * This property is not used but preserved here for compatibility. - */ - public static final String FACTORY_DEFAULT = "org.apache.commons.logging.impl.SLF4JLogFactory"; - - /** - * The name of the properties file to search for. - *

- * This property is not used but preserved here for compatibility. - */ - public static final String FACTORY_PROPERTIES = "commons-logging.properties"; - - - /** - * JDK1.3+ - * 'Service Provider' specification. - *

- * This property is not used but preserved here for compatibility. - */ - protected static final String SERVICE_ID = - "META-INF/services/org.apache.commons.logging.LogFactory"; - - /** - * The name (org.apache.commons.logging.diagnostics.dest) of - * the property used to enable internal commons-logging diagnostic output, in - * order to get information on what logging implementations are being - * discovered, what classloaders they are loaded through, etc. - * - *

- * This property is not used but preserved here for compatibility. - */ - public static final String DIAGNOSTICS_DEST_PROPERTY = "org.apache.commons.logging.diagnostics.dest"; - - /** - *

- * Setting this system property value allows the Hashtable used - * to store classloaders to be substituted by an alternative implementation. - *

- * This property is not used but preserved here for compatibility. - */ - public static final String HASHTABLE_IMPLEMENTATION_PROPERTY = "org.apache.commons.logging.LogFactory.HashtableImpl"; - - /** - * The previously constructed LogFactory instances, keyed by - * the ClassLoader with which it was created. - * - *

- * This property is not used but preserved here for compatibility. - */ - protected static Hashtable factories = null; - - /** - *

- * This property is not used but preserved here for compatibility. - */ - protected static LogFactory nullClassLoaderFactory = null; - - /** - * Protected constructor that is not available for public use. - */ - protected LogFactory() { - } - - // --------------------------------------------------------- Public Methods - - /** - * Return the configuration attribute with the specified name (if any), or - * null if there is no such attribute. - * - * @param name - * Name of the attribute to return - */ - public abstract Object getAttribute(String name); - - /** - * Return an array containing the names of all currently defined configuration - * attributes. If there are no such attributes, a zero length array is - * returned. - */ - public abstract String[] getAttributeNames(); - - /** - * Convenience method to derive a name from the specified class and call - * getInstance(String) with it. - * - * @param clazz - * Class for which a suitable Log name will be derived - * - * @exception LogConfigurationException - * if a suitable Log instance cannot be - * returned - */ - public abstract Log getInstance(Class clazz) throws LogConfigurationException; - - /** - *

- * Construct (if necessary) and return a Log instance, using - * the factory's current set of configuration attributes. - *

- * - *

- * NOTE - Depending upon the implementation of the - * LogFactory you are using, the Log instance - * you are returned may or may not be local to the current application, and - * may or may not be returned again on a subsequent call with the same name - * argument. - *

- * - * @param name - * Logical name of the Log instance to be - * returned (the meaning of this name is only known to the - * underlying logging implementation that is being wrapped) - * - * @exception LogConfigurationException - * if a suitable Log instance cannot be - * returned - */ - public abstract Log getInstance(String name) throws LogConfigurationException; - - /** - * Release any internal references to previously created {@link Log}instances - * returned by this factory. This is useful in environments like servlet - * containers, which implement application reloading by throwing away a - * ClassLoader. Dangling references to objects in that class loader would - * prevent garbage collection. - */ - public abstract void release(); - - /** - * Remove any configuration attribute associated with the specified name. If - * there is no such attribute, no action is taken. - * - * @param name - * Name of the attribute to remove - */ - public abstract void removeAttribute(String name); - - /** - * Set the configuration attribute with the specified name. Calling this with - * a null value is equivalent to calling - * removeAttribute(name). - * - * @param name - * Name of the attribute to set - * @param value - * Value of the attribute to set, or null to - * remove any setting for this attribute - */ - public abstract void setAttribute(String name, Object value); - - // --------------------------------------------------------- Static Methods - - /** - *

- * Construct (if necessary) and return a LogFactory instance, - * using the following ordered lookup procedure to determine the name of the - * implementation class to be loaded. - *

- * - * - *

- * NOTE- If the properties file method of identifying the - * LogFactory implementation class is utilized, all of the - * properties defined in this file will be set as configuration attributes on - * the corresponding LogFactory instance. - *

- * - * @exception LogConfigurationException - * if the implementation class is not available or cannot - * be instantiated. - */ - public static LogFactory getFactory() throws LogConfigurationException { - return logFactory; - } - - /** - * Convenience method to return a named logger, without the application having - * to care about factories. - * - * @param clazz - * Class from which a log name will be derived - * - * @exception LogConfigurationException - * if a suitable Log instance cannot be - * returned - */ - public static Log getLog(Class clazz) throws LogConfigurationException { - return (getFactory().getInstance(clazz)); - } - - /** - * Convenience method to return a named logger, without the application having - * to care about factories. - * - * @param name - * Logical name of the Log instance to be - * returned (the meaning of this name is only known to the - * underlying logging implementation that is being wrapped) - * - * @exception LogConfigurationException - * if a suitable Log instance cannot be - * returned - */ - public static Log getLog(String name) throws LogConfigurationException { - return (getFactory().getInstance(name)); - } - - /** - * Release any internal references to previously created {@link LogFactory} - * instances that have been associated with the specified class loader (if - * any), after calling the instance method release() on each of - * them. - * - * @param classLoader - * ClassLoader for which to release the LogFactory - */ - public static void release(ClassLoader classLoader) { - // since SLF4J based JCL does not make use of classloaders, there is nothing - // to do here - } - - /** - * Release any internal references to previously created {@link LogFactory} - * instances, after calling the instance method release() on - * each of them. This is useful in environments like servlet containers, which - * implement application reloading by throwing away a ClassLoader. Dangling - * references to objects in that class loader would prevent garbage - * collection. - */ - public static void releaseAll() { - // since SLF4J based JCL does not make use of classloaders, there is nothing - // to do here - } - - /** - * Returns a string that uniquely identifies the specified object, including - * its class. - *

- * The returned string is of form "classname@hashcode", ie is the same as the - * return value of the Object.toString() method, but works even when the - * specified object's class has overidden the toString method. - * - * @param o - * may be null. - * @return a string of form classname@hashcode, or "null" if param o is null. - * @since 1.1 - */ - public static String objectId(Object o) { - if (o == null) { - return "null"; - } else { - return o.getClass().getName() + "@" + System.identityHashCode(o); - } - } - - // protected methods which were added in JCL 1.1. These are not used - // by SLF4JLogFactory - - /** - * This method exists to ensure signature compatibility. - */ - protected static Object createFactory(String factoryClass, ClassLoader classLoader) { - throw new UnsupportedOperationException( - "Operation [factoryClass] is not supported in jcl-over-slf4j. See also " - + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J); - } - - /** - * This method exists to ensure signature compatibility. - */ - protected static ClassLoader directGetContextClassLoader() { - throw new UnsupportedOperationException( - "Operation [directGetContextClassLoader] is not supported in jcl-over-slf4j. See also " - + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J); - } - - /** - * This method exists to ensure signature compatibility. - */ - protected static ClassLoader getContextClassLoader() - throws LogConfigurationException { - throw new UnsupportedOperationException( - "Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also " - + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J); - } - - /** - * This method exists to ensure signature compatibility. - */ - protected static ClassLoader getClassLoader(Class clazz) { - throw new UnsupportedOperationException( - "Operation [getClassLoader] is not supported in jcl-over-slf4j. See also " - + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J); - } - - /** - * This method exists to ensure signature compatibility. - */ - protected static boolean isDiagnosticsEnabled() { - throw new UnsupportedOperationException( - "Operation [isDiagnosticsEnabled] is not supported in jcl-over-slf4j. See also " - + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J); - } - - /** - * This method exists to ensure signature compatibility. - */ - protected static void logRawDiagnostic(String msg) { - throw new UnsupportedOperationException( - "Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also " - + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J); - } - - /** - * This method exists to ensure signature compatibility. - */ - protected static LogFactory newFactory(final String factoryClass, - final ClassLoader classLoader, final ClassLoader contextClassLoader) { - throw new UnsupportedOperationException( - "Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also " - + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J); - } - - /** - * This method exists to ensure signature compatibility. - */ - protected static LogFactory newFactory(final String factoryClass, - final ClassLoader classLoader) { - throw new UnsupportedOperationException( - "Operation [newFactory] is not supported in jcl-over-slf4j. See also " - + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J); - } - - -} \ No newline at end of file diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/NoOpLog.java b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/NoOpLog.java deleted file mode 100644 index cbef4a741..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/NoOpLog.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.commons.logging.impl; - - -import java.io.Serializable; -import org.apache.commons.logging.Log; - - -/** - *

Trivial implementation of Log that throws away all messages. No - * configurable system properties are supported.

- * - * @author Scott Sanders - * @author Rod Waldhoff - * @version $Id: NoOpLog.java,v 1.8 2004/06/06 21:13:12 rdonkin Exp $ - */ -public class NoOpLog implements Log, Serializable { - - /** Convenience constructor */ - public NoOpLog() { } - /** Base constructor */ - public NoOpLog(String name) { } - /** Do nothing */ - public void trace(Object message) { } - /** Do nothing */ - public void trace(Object message, Throwable t) { } - /** Do nothing */ - public void debug(Object message) { } - /** Do nothing */ - public void debug(Object message, Throwable t) { } - /** Do nothing */ - public void info(Object message) { } - /** Do nothing */ - public void info(Object message, Throwable t) { } - /** Do nothing */ - public void warn(Object message) { } - /** Do nothing */ - public void warn(Object message, Throwable t) { } - /** Do nothing */ - public void error(Object message) { } - /** Do nothing */ - public void error(Object message, Throwable t) { } - /** Do nothing */ - public void fatal(Object message) { } - /** Do nothing */ - public void fatal(Object message, Throwable t) { } - - /** - * Debug is never enabled. - * - * @return false - */ - public final boolean isDebugEnabled() { return false; } - - /** - * Error is never enabled. - * - * @return false - */ - public final boolean isErrorEnabled() { return false; } - - /** - * Fatal is never enabled. - * - * @return false - */ - public final boolean isFatalEnabled() { return false; } - - /** - * Info is never enabled. - * - * @return false - */ - public final boolean isInfoEnabled() { return false; } - - /** - * Trace is never enabled. - * - * @return false - */ - public final boolean isTraceEnabled() { return false; } - - /** - * Warn is never enabled. - * - * @return false - */ - public final boolean isWarnEnabled() { return false; } - -} diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLocationAwareLog.java b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLocationAwareLog.java deleted file mode 100644 index 6ff1ddf01..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLocationAwareLog.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.logging.impl; - -import java.io.Serializable; - -import org.apache.commons.logging.Log; -import org.slf4j.Logger; -import org.slf4j.spi.LocationAwareLogger; - -/** - * Implementation of {@link Log org.apache.commons.logging.Log} interface which - * delegates all processing to a wrapped {@link Logger org.slf4j.Logger} instance. - * - *

JCL's FATAL level is mapped to ERROR. All other levels map one to one. - * - * @author Ceki Gülcü - */ -public class SLF4JLocationAwareLog implements Log, Serializable { - - private static final long serialVersionUID = -2379157579039314822L; - - // in both Log4jLogger and Jdk14Logger classes in the original JCL, the - // logger instance is transient - private transient LocationAwareLogger logger; - - private static final String FQCN = SLF4JLocationAwareLog.class.getName(); - - SLF4JLocationAwareLog(LocationAwareLogger logger) { - this.logger = logger; - } - - /** - * Delegates to the isTraceEnabled method of the wrapped - * org.slf4j.Logger instance. - */ - public boolean isTraceEnabled() { - return logger.isTraceEnabled(); - } - - /** - * Directly delegates to the wrapped org.slf4j.Logger instance. - */ - public boolean isDebugEnabled() { - return logger.isDebugEnabled(); - } - - /** - * Directly delegates to the wrapped org.slf4j.Logger instance. - */ - public boolean isInfoEnabled() { - return logger.isInfoEnabled(); - } - - /** - * Directly delegates to the wrapped org.slf4j.Logger instance. - */ - public boolean isWarnEnabled() { - return logger.isWarnEnabled(); - } - - /** - * Directly delegates to the wrapped org.slf4j.Logger instance. - */ - public boolean isErrorEnabled() { - return logger.isErrorEnabled(); - } - - /** - * Delegates to the isErrorEnabled method of the wrapped - * org.slf4j.Logger instance. - */ - public boolean isFatalEnabled() { - return logger.isErrorEnabled(); - } - - - /** - * Converts the input parameter to String and then delegates to - * the debug method of the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void trace(Object message) { - logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), null); - } - - /** - * Converts the first input parameter to String and then delegates to - * the debug method of the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void trace(Object message, Throwable t) { - logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), t); - } - - /** - * Converts the input parameter to String and then delegates to the wrapped - * org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void debug(Object message) { - logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), null); - } - - /** - * Converts the first input parameter to String and then delegates to - * the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void debug(Object message, Throwable t) { - logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), t); - } - - /** - * Converts the input parameter to String and then delegates to the wrapped - * org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void info(Object message) { - logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String.valueOf(message), null); - } - - /** - * Converts the first input parameter to String and then delegates to - * the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void info(Object message, Throwable t) { - logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String.valueOf(message), t); - } - - /** - * Converts the input parameter to String and then delegates to the wrapped - * org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void warn(Object message) { - logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String.valueOf(message), null); - } - - /** - * Converts the first input parameter to String and then delegates to - * the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void warn(Object message, Throwable t) { - logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String.valueOf(message), t); - } - - /** - * Converts the input parameter to String and then delegates to the wrapped - * org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void error(Object message) { - logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null); - } - - /** - * Converts the first input parameter to String and then delegates to - * the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void error(Object message, Throwable t) { - logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), t); - } - - - - /** - * Converts the input parameter to String and then delegates to - * the error method of the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void fatal(Object message) { - logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null); - } - - /** - * Converts the first input parameter to String and then delegates to - * the error method of the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void fatal(Object message, Throwable t) { - logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), t); - } - -} \ No newline at end of file diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java deleted file mode 100644 index fd3c10a7b..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.logging.impl; - -import java.io.Serializable; - -import org.apache.commons.logging.Log; -import org.slf4j.Logger; - -/** - * Implementation of {@link Log org.apache.commons.logging.Log} interface which - * delegates all processing to a wrapped {@link Logger org.slf4j.Logger} instance. - * - *

JCL's FATAL and TRACE levels are mapped to ERROR and DEBUG respectively. All - * other levels map one to one. - * - * @author Ceki Gülcü - */ -public class SLF4JLog implements Log, Serializable { - - private static final long serialVersionUID = 680728617011167209L; - - // in both Log4jLogger and Jdk14Logger classes in the original JCL, the - // logger instance is transient - private transient Logger logger; - - SLF4JLog(Logger logger) { - this.logger = logger; - } - - /** - * Directly delegates to the wrapped org.slf4j.Logger instance. - */ - public boolean isDebugEnabled() { - return logger.isDebugEnabled(); - } - - /** - * Directly delegates to the wrapped org.slf4j.Logger instance. - */ - public boolean isErrorEnabled() { - return logger.isErrorEnabled(); - } - - /** - * Delegates to the isErrorEnabled method of the wrapped - * org.slf4j.Logger instance. - */ - public boolean isFatalEnabled() { - return logger.isErrorEnabled(); - } - - /** - * Directly delegates to the wrapped org.slf4j.Logger instance. - */ - public boolean isInfoEnabled() { - return logger.isInfoEnabled(); - } - - /** - * Delegates to the isDebugEnabled method of the wrapped - * org.slf4j.Logger instance. - */ - public boolean isTraceEnabled() { - return logger.isTraceEnabled(); - } - - /** - * Directly delegates to the wrapped org.slf4j.Logger instance. - */ - public boolean isWarnEnabled() { - return logger.isWarnEnabled(); - } - - /** - * Converts the input parameter to String and then delegates to - * the debug method of the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void trace(Object message) { - logger.trace(String.valueOf(message)); - } - - /** - * Converts the first input parameter to String and then delegates to - * the debug method of the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void trace(Object message, Throwable t) { - logger.trace(String.valueOf(message), t); - } - - /** - * Converts the input parameter to String and then delegates to the wrapped - * org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void debug(Object message) { - logger.debug(String.valueOf(message)); - } - - /** - * Converts the first input parameter to String and then delegates to - * the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void debug(Object message, Throwable t) { - logger.debug(String.valueOf(message), t); - } - - /** - * Converts the input parameter to String and then delegates to the wrapped - * org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void info(Object message) { - logger.info(String.valueOf(message)); - } - - /** - * Converts the first input parameter to String and then delegates to - * the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void info(Object message, Throwable t) { - logger.info(String.valueOf(message), t); - } - - /** - * Converts the input parameter to String and then delegates to the wrapped - * org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void warn(Object message) { - logger.warn(String.valueOf(message)); - } - - /** - * Converts the first input parameter to String and then delegates to - * the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void warn(Object message, Throwable t) { - logger.warn(String.valueOf(message), t); - } - - /** - * Converts the input parameter to String and then delegates to the wrapped - * org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void error(Object message) { - logger.error(String.valueOf(message)); - } - - /** - * Converts the first input parameter to String and then delegates to - * the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void error(Object message, Throwable t) { - logger.error(String.valueOf(message), t); - } - - - - /** - * Converts the input parameter to String and then delegates to - * the error method of the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - */ - public void fatal(Object message) { - logger.error(String.valueOf(message)); - } - - /** - * Converts the first input parameter to String and then delegates to - * the error method of the wrapped org.slf4j.Logger instance. - * - * @param message the message to log. Converted to {@link String} - * @param t the exception to log - */ - public void fatal(Object message, Throwable t) { - logger.error(String.valueOf(message), t); - } - -} \ No newline at end of file diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLogFactory.java b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLogFactory.java deleted file mode 100644 index a6e2e7698..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLogFactory.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.logging.impl; - -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; -import java.util.Vector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogConfigurationException; -import org.apache.commons.logging.LogFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.spi.LocationAwareLogger; - -/** - *

- * Concrete subclass of {@link LogFactory} which always delegates to the - * {@link LoggerFactory org.slf4j.LoggerFactory} class. - * - *

- * This factory generates instances of {@link SLF4JLog}. It will remember - * previously created instances for the same name, and will return them on - * repeated requests to the getInstance() method. - * - *

- * This implementation ignores any configured attributes. - *

- * - * @author Rod Waldhoff - * @author Craig R. McClanahan - * @author Richard A. Sitze - * @author Ceki Gülcü - */ - -public class SLF4JLogFactory extends LogFactory { - - // ----------------------------------------------------------- Constructors - - /** - * The {@link org.apache.commons.logging.Log}instances that have already been - * created, keyed by logger name. - */ - Map loggerMap; - - /** - * Public no-arguments constructor required by the lookup mechanism. - */ - public SLF4JLogFactory() { - loggerMap = new HashMap(); - } - - // ----------------------------------------------------- Manifest Constants - - /** - * The name of the system property identifying our {@link Log}implementation - * class. - */ - public static final String LOG_PROPERTY = "org.apache.commons.logging.Log"; - - // ----------------------------------------------------- Instance Variables - - /** - * Configuration attributes. - */ - protected Hashtable attributes = new Hashtable(); - - // --------------------------------------------------------- Public Methods - - /** - * Return the configuration attribute with the specified name (if any), or - * null if there is no such attribute. - * - * @param name - * Name of the attribute to return - */ - public Object getAttribute(String name) { - - return (attributes.get(name)); - - } - - /** - * Return an array containing the names of all currently defined configuration - * attributes. If there are no such attributes, a zero length array is - * returned. - */ - public String[] getAttributeNames() { - - Vector names = new Vector(); - Enumeration keys = attributes.keys(); - while (keys.hasMoreElements()) { - names.addElement((String) keys.nextElement()); - } - String results[] = new String[names.size()]; - for (int i = 0; i < results.length; i++) { - results[i] = (String) names.elementAt(i); - } - return (results); - - } - - /** - * Convenience method to derive a name from the specified class and call - * getInstance(String) with it. - * - * @param clazz - * Class for which a suitable Log name will be derived - * - * @exception LogConfigurationException - * if a suitable Log instance cannot be returned - */ - public Log getInstance(Class clazz) throws LogConfigurationException { - - return (getInstance(clazz.getName())); - - } - - /** - *

- * Construct (if necessary) and return a Log instance, using - * the factory's current set of configuration attributes. - *

- * - * @param name - * Logical name of the Log instance to be returned - * (the meaning of this name is only known to the underlying logging - * implementation that is being wrapped) - * - * @exception LogConfigurationException - * if a suitable Log instance cannot be returned - */ - public Log getInstance(String name) throws LogConfigurationException { - Log instance = null; - // protect against concurrent access of loggerMap - synchronized (this) { - instance = (Log) loggerMap.get(name); - if (instance == null) { - Logger logger = LoggerFactory.getLogger(name); - if(logger instanceof LocationAwareLogger) { - instance = new SLF4JLocationAwareLog((LocationAwareLogger) logger); - } else { - instance = new SLF4JLog(logger); - } - loggerMap.put(name, instance); - } - } - return (instance); - - } - - /** - * Release any internal references to previously created - * {@link org.apache.commons.logging.Log}instances returned by this factory. - * This is useful in environments like servlet containers, which implement - * application reloading by throwing away a ClassLoader. Dangling references - * to objects in that class loader would prevent garbage collection. - */ - public void release() { - // This method is never called by jcl-over-slf4j classes. However, - // in certain deployment scenarios, in particular if jcl-over-slf4j.jar - // is - // in the the web-app class loader and the official commons-logging.jar is - // deployed in some parent class loader (e.g. commons/lib), then it is - // possible - // for the parent class loader to mask the classes shipping in - // jcl-over-slf4j.jar. - System.out.println("WARN: The method " + SLF4JLogFactory.class - + "#release() was invoked."); - System.out - .println("WARN: Please see http://www.slf4j.org/codes.html#release for an explanation."); - System.out.flush(); - } - - /** - * Remove any configuration attribute associated with the specified name. If - * there is no such attribute, no action is taken. - * - * @param name - * Name of the attribute to remove - */ - public void removeAttribute(String name) { - attributes.remove(name); - } - - /** - * Set the configuration attribute with the specified name. Calling this with - * a null value is equivalent to calling - * removeAttribute(name). - * - * @param name - * Name of the attribute to set - * @param value - * Value of the attribute to set, or null to remove - * any setting for this attribute - */ - public void setAttribute(String name, Object value) { - - if (value == null) { - attributes.remove(name); - } else { - attributes.put(name, value); - } - - } -} \ No newline at end of file diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java deleted file mode 100644 index 426b6f2d7..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java +++ /dev/null @@ -1,652 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.commons.logging.impl; - -import java.io.InputStream; -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogConfigurationException; - -/** - *

Simple implementation of Log that sends all enabled log messages, - * for all defined loggers, to System.err. The following system properties - * are supported to configure the behavior of this logger:

- *
    - *
  • org.apache.commons.logging.simplelog.defaultlog - - * Default logging detail level for all instances of SimpleLog. - * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal"). - * If not specified, defaults to "info".
  • - *
  • org.apache.commons.logging.simplelog.log.xxxxx - - * Logging detail level for a SimpleLog instance named "xxxxx". - * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal"). - * If not specified, the default logging detail level is used.
  • - *
  • org.apache.commons.logging.simplelog.showlogname - - * Set to true if you want the Log instance name to be - * included in output messages. Defaults to false.
  • - *
  • org.apache.commons.logging.simplelog.showShortLogname - - * Set to true if you want the last component of the name to be - * included in output messages. Defaults to true.
  • - *
  • org.apache.commons.logging.simplelog.showdatetime - - * Set to true if you want the current date and time - * to be included in output messages. Default is false.
  • - *
  • org.apache.commons.logging.simplelog.dateTimeFormat - - * The date and time format to be used in the output messages. - * The pattern describing the date and time format is the same that is - * used in java.text.SimpleDateFormat. If the format is not - * specified or is invalid, the default format is used. - * The default format is yyyy/MM/dd HH:mm:ss:SSS zzz.
  • - *
- * - *

In addition to looking for system properties with the names specified - * above, this implementation also checks for a class loader resource named - * "simplelog.properties", and includes any matching definitions - * from this resource (if it exists).

- * - * @author Scott Sanders - * @author Rod Waldhoff - * @author Robert Burrell Donkin - * - * @version $Id: SimpleLog.java,v 1.21 2004/06/06 20:47:56 rdonkin Exp $ - */ -public class SimpleLog implements Log, Serializable { - - - // ------------------------------------------------------- Class Attributes - - /** All system properties used by SimpleLog start with this */ - static protected final String systemPrefix = - "org.apache.commons.logging.simplelog."; - - /** Properties loaded from simplelog.properties */ - static protected final Properties simpleLogProps = new Properties(); - - /** The default format to use when formating dates */ - static protected final String DEFAULT_DATE_TIME_FORMAT = - "yyyy/MM/dd HH:mm:ss:SSS zzz"; - - /** Include the instance name in the log message? */ - static protected boolean showLogName = false; - /** Include the short name ( last component ) of the logger in the log - * message. Defaults to true - otherwise we'll be lost in a flood of - * messages without knowing who sends them. - */ - static protected boolean showShortName = true; - /** Include the current time in the log message */ - static protected boolean showDateTime = false; - /** The date and time format to use in the log message */ - static protected String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT; - /** Used to format times */ - static protected DateFormat dateFormatter = null; - - // ---------------------------------------------------- Log Level Constants - - - /** "Trace" level logging. */ - public static final int LOG_LEVEL_TRACE = 1; - /** "Debug" level logging. */ - public static final int LOG_LEVEL_DEBUG = 2; - /** "Info" level logging. */ - public static final int LOG_LEVEL_INFO = 3; - /** "Warn" level logging. */ - public static final int LOG_LEVEL_WARN = 4; - /** "Error" level logging. */ - public static final int LOG_LEVEL_ERROR = 5; - /** "Fatal" level logging. */ - public static final int LOG_LEVEL_FATAL = 6; - - /** Enable all logging levels */ - public static final int LOG_LEVEL_ALL = (LOG_LEVEL_TRACE - 1); - - /** Enable no logging levels */ - public static final int LOG_LEVEL_OFF = (LOG_LEVEL_FATAL + 1); - - // ------------------------------------------------------------ Initializer - - private static String getStringProperty(String name) { - String prop = null; - try { - prop = System.getProperty(name); - } catch (SecurityException e) { - ; // Ignore - } - return (prop == null) ? simpleLogProps.getProperty(name) : prop; - } - - private static String getStringProperty(String name, String dephault) { - String prop = getStringProperty(name); - return (prop == null) ? dephault : prop; - } - - private static boolean getBooleanProperty(String name, boolean dephault) { - String prop = getStringProperty(name); - return (prop == null) ? dephault : "true".equalsIgnoreCase(prop); - } - - // Initialize class attributes. - // Load properties file, if found. - // Override with system properties. - static { - // Add props from the resource simplelog.properties - InputStream in = getResourceAsStream("simplelog.properties"); - if(null != in) { - try { - simpleLogProps.load(in); - in.close(); - } catch(java.io.IOException e) { - // ignored - } - } - - showLogName = getBooleanProperty( systemPrefix + "showlogname", showLogName); - showShortName = getBooleanProperty( systemPrefix + "showShortLogname", showShortName); - showDateTime = getBooleanProperty( systemPrefix + "showdatetime", showDateTime); - - if(showDateTime) { - dateTimeFormat = getStringProperty(systemPrefix + "dateTimeFormat", - dateTimeFormat); - try { - dateFormatter = new SimpleDateFormat(dateTimeFormat); - } catch(IllegalArgumentException e) { - // If the format pattern is invalid - use the default format - dateTimeFormat = DEFAULT_DATE_TIME_FORMAT; - dateFormatter = new SimpleDateFormat(dateTimeFormat); - } - } - } - - - // ------------------------------------------------------------- Attributes - - /** The name of this simple log instance */ - protected String logName = null; - /** The current log level */ - protected int currentLogLevel; - /** The short name of this simple log instance */ - private String shortLogName = null; - - - // ------------------------------------------------------------ Constructor - - /** - * Construct a simple log with given name. - * - * @param name log name - */ - public SimpleLog(String name) { - - logName = name; - - // Set initial log level - // Used to be: set default log level to ERROR - // IMHO it should be lower, but at least info ( costin ). - setLevel(SimpleLog.LOG_LEVEL_INFO); - - // Set log level from properties - String lvl = getStringProperty(systemPrefix + "log." + logName); - int i = String.valueOf(name).lastIndexOf("."); - while(null == lvl && i > -1) { - name = name.substring(0,i); - lvl = getStringProperty(systemPrefix + "log." + name); - i = String.valueOf(name).lastIndexOf("."); - } - - if(null == lvl) { - lvl = getStringProperty(systemPrefix + "defaultlog"); - } - - if("all".equalsIgnoreCase(lvl)) { - setLevel(SimpleLog.LOG_LEVEL_ALL); - } else if("trace".equalsIgnoreCase(lvl)) { - setLevel(SimpleLog.LOG_LEVEL_TRACE); - } else if("debug".equalsIgnoreCase(lvl)) { - setLevel(SimpleLog.LOG_LEVEL_DEBUG); - } else if("info".equalsIgnoreCase(lvl)) { - setLevel(SimpleLog.LOG_LEVEL_INFO); - } else if("warn".equalsIgnoreCase(lvl)) { - setLevel(SimpleLog.LOG_LEVEL_WARN); - } else if("error".equalsIgnoreCase(lvl)) { - setLevel(SimpleLog.LOG_LEVEL_ERROR); - } else if("fatal".equalsIgnoreCase(lvl)) { - setLevel(SimpleLog.LOG_LEVEL_FATAL); - } else if("off".equalsIgnoreCase(lvl)) { - setLevel(SimpleLog.LOG_LEVEL_OFF); - } - - } - - - // -------------------------------------------------------- Properties - - /** - *

Set logging level.

- * - * @param currentLogLevel new logging level - */ - public void setLevel(int currentLogLevel) { - - this.currentLogLevel = currentLogLevel; - - } - - - /** - *

Get logging level.

- */ - public int getLevel() { - - return currentLogLevel; - } - - - // -------------------------------------------------------- Logging Methods - - - /** - *

Do the actual logging. - * This method assembles the message - * and then calls write() to cause it to be written.

- * - * @param type One of the LOG_LEVEL_XXX constants defining the log level - * @param message The message itself (typically a String) - * @param t The exception whose stack trace should be logged - */ - protected void log(int type, Object message, Throwable t) { - // Use a string buffer for better performance - StringBuffer buf = new StringBuffer(); - - // Append date-time if so configured - if(showDateTime) { - buf.append(dateFormatter.format(new Date())); - buf.append(" "); - } - - // Append a readable representation of the log level - switch(type) { - case SimpleLog.LOG_LEVEL_TRACE: buf.append("[TRACE] "); break; - case SimpleLog.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break; - case SimpleLog.LOG_LEVEL_INFO: buf.append("[INFO] "); break; - case SimpleLog.LOG_LEVEL_WARN: buf.append("[WARN] "); break; - case SimpleLog.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break; - case SimpleLog.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break; - } - - // Append the name of the log instance if so configured - if( showShortName) { - if( shortLogName==null ) { - // Cut all but the last component of the name for both styles - shortLogName = logName.substring(logName.lastIndexOf(".") + 1); - shortLogName = - shortLogName.substring(shortLogName.lastIndexOf("/") + 1); - } - buf.append(String.valueOf(shortLogName)).append(" - "); - } else if(showLogName) { - buf.append(String.valueOf(logName)).append(" - "); - } - - // Append the message - buf.append(String.valueOf(message)); - - // Append stack trace if not null - if(t != null) { - buf.append(" <"); - buf.append(t.toString()); - buf.append(">"); - - java.io.StringWriter sw= new java.io.StringWriter(1024); - java.io.PrintWriter pw= new java.io.PrintWriter(sw); - t.printStackTrace(pw); - pw.close(); - buf.append(sw.toString()); - } - - // Print to the appropriate destination - write(buf); - - } - - - /** - *

Write the content of the message accumulated in the specified - * StringBuffer to the appropriate output destination. The - * default implementation writes to System.err.

- * - * @param buffer A StringBuffer containing the accumulated - * text to be logged - */ - protected void write(StringBuffer buffer) { - - System.err.println(buffer.toString()); - - } - - - /** - * Is the given log level currently enabled? - * - * @param logLevel is this level enabled? - */ - protected boolean isLevelEnabled(int logLevel) { - // log level are numerically ordered so can use simple numeric - // comparison - return (logLevel >= currentLogLevel); - } - - - // -------------------------------------------------------- Log Implementation - - - /** - *

Log a message with debug log level.

- */ - public final void debug(Object message) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) { - log(SimpleLog.LOG_LEVEL_DEBUG, message, null); - } - } - - - /** - *

Log an error with debug log level.

- */ - public final void debug(Object message, Throwable t) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) { - log(SimpleLog.LOG_LEVEL_DEBUG, message, t); - } - } - - - /** - *

Log a message with trace log level.

- */ - public final void trace(Object message) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) { - log(SimpleLog.LOG_LEVEL_TRACE, message, null); - } - } - - - /** - *

Log an error with trace log level.

- */ - public final void trace(Object message, Throwable t) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) { - log(SimpleLog.LOG_LEVEL_TRACE, message, t); - } - } - - - /** - *

Log a message with info log level.

- */ - public final void info(Object message) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) { - log(SimpleLog.LOG_LEVEL_INFO,message,null); - } - } - - - /** - *

Log an error with info log level.

- */ - public final void info(Object message, Throwable t) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) { - log(SimpleLog.LOG_LEVEL_INFO, message, t); - } - } - - - /** - *

Log a message with warn log level.

- */ - public final void warn(Object message) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) { - log(SimpleLog.LOG_LEVEL_WARN, message, null); - } - } - - - /** - *

Log an error with warn log level.

- */ - public final void warn(Object message, Throwable t) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) { - log(SimpleLog.LOG_LEVEL_WARN, message, t); - } - } - - - /** - *

Log a message with error log level.

- */ - public final void error(Object message) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) { - log(SimpleLog.LOG_LEVEL_ERROR, message, null); - } - } - - - /** - *

Log an error with error log level.

- */ - public final void error(Object message, Throwable t) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) { - log(SimpleLog.LOG_LEVEL_ERROR, message, t); - } - } - - - /** - *

Log a message with fatal log level.

- */ - public final void fatal(Object message) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) { - log(SimpleLog.LOG_LEVEL_FATAL, message, null); - } - } - - - /** - *

Log an error with fatal log level.

- */ - public final void fatal(Object message, Throwable t) { - - if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) { - log(SimpleLog.LOG_LEVEL_FATAL, message, t); - } - } - - - /** - *

Are debug messages currently enabled?

- * - *

This allows expensive operations such as String - * concatenation to be avoided when the message will be ignored by the - * logger.

- */ - public final boolean isDebugEnabled() { - - return isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG); - } - - - /** - *

Are error messages currently enabled?

- * - *

This allows expensive operations such as String - * concatenation to be avoided when the message will be ignored by the - * logger.

- */ - public final boolean isErrorEnabled() { - - return isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR); - } - - - /** - *

Are fatal messages currently enabled?

- * - *

This allows expensive operations such as String - * concatenation to be avoided when the message will be ignored by the - * logger.

- */ - public final boolean isFatalEnabled() { - - return isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL); - } - - - /** - *

Are info messages currently enabled?

- * - *

This allows expensive operations such as String - * concatenation to be avoided when the message will be ignored by the - * logger.

- */ - public final boolean isInfoEnabled() { - - return isLevelEnabled(SimpleLog.LOG_LEVEL_INFO); - } - - - /** - *

Are trace messages currently enabled?

- * - *

This allows expensive operations such as String - * concatenation to be avoided when the message will be ignored by the - * logger.

- */ - public final boolean isTraceEnabled() { - - return isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE); - } - - - /** - *

Are warn messages currently enabled?

- * - *

This allows expensive operations such as String - * concatenation to be avoided when the message will be ignored by the - * logger.

- */ - public final boolean isWarnEnabled() { - - return isLevelEnabled(SimpleLog.LOG_LEVEL_WARN); - } - - - /** - * Return the thread context class loader if available. - * Otherwise return null. - * - * The thread context class loader is available for JDK 1.2 - * or later, if certain security conditions are met. - * - * @exception LogConfigurationException if a suitable class loader - * cannot be identified. - */ - private static ClassLoader getContextClassLoader() - { - ClassLoader classLoader = null; - - if (classLoader == null) { - try { - // Are we running on a JDK 1.2 or later system? - Method method = Thread.class.getMethod("getContextClassLoader", null); - - // Get the thread context class loader (if there is one) - try { - classLoader = (ClassLoader)method.invoke(Thread.currentThread(), null); - } catch (IllegalAccessException e) { - ; // ignore - } catch (InvocationTargetException e) { - /** - * InvocationTargetException is thrown by 'invoke' when - * the method being invoked (getContextClassLoader) throws - * an exception. - * - * getContextClassLoader() throws SecurityException when - * the context class loader isn't an ancestor of the - * calling class's class loader, or if security - * permissions are restricted. - * - * In the first case (not related), we want to ignore and - * keep going. We cannot help but also ignore the second - * with the logic below, but other calls elsewhere (to - * obtain a class loader) will trigger this exception where - * we can make a distinction. - */ - if (e.getTargetException() instanceof SecurityException) { - ; // ignore - } else { - // Capture 'e.getTargetException()' exception for details - // alternate: log 'e.getTargetException()', and pass back 'e'. - throw new LogConfigurationException - ("Unexpected InvocationTargetException", e.getTargetException()); - } - } - } catch (NoSuchMethodException e) { - // Assume we are running on JDK 1.1 - ; // ignore - } - } - - if (classLoader == null) { - classLoader = SimpleLog.class.getClassLoader(); - } - - // Return the selected class loader - return classLoader; - } - - private static InputStream getResourceAsStream(final String name) - { - return (InputStream)AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - ClassLoader threadCL = getContextClassLoader(); - - if (threadCL != null) { - return threadCL.getResourceAsStream(name); - } else { - return ClassLoader.getSystemResourceAsStream(name); - } - } - }); - } -} - diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/package.html b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/package.html deleted file mode 100644 index 128d15f82..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

SLF4J based implementation of commons-logging wrapper APIs.

- - diff --git a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/package.html b/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/package.html deleted file mode 100644 index 8e76ba473..000000000 --- a/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/package.html +++ /dev/null @@ -1,169 +0,0 @@ - - - -

Jakarta Commons Logging implemented over SLF4J.

- - -

Overview

- -

This package contains the same public user interface as Jakarta Commons -Logging (JCL). It is intended as a 100% compatible drop-in -replacement for the original JCL version 1.0.4. -

- -

As the original JCL version 1.0.4, the present version supports -various logging APIs. It differs from the original in implementation -but not the public API. This implementation uses SLF4J under the -covers. As as such, all the logging systems that SLF4J supports, -e.g. NOP, Simple, JDK14, nlog4j are supported by this version of JCL. -

- -

Quick Start Guide

- -

For those impatient to just get on with it, the following example -illustrates the typical declaration and use of a logger that is named (by -convention) after the calling class: - -

-    import org.apache.commons.logging.Log;
-    import org.apache.commons.logging.LogFactory;
-
-    public class Foo {
-
-        static Log log = LogFactory.getLog(Foo.class);
-
-        public void foo() {
-            ...
-            try {
-                if (log.isDebugEnabled()) {
-                    log.debug("About to do something to object " + name);
-                }
-                name.bar();
-            } catch (IllegalStateException e) {
-                log.error("Something bad happened to " + name, e);
-            }
-            ...
-        }
-
- -

Configuring the Commons Logging Package

- -

In this version of JCL, the selection of the logging system to use -is chosen by the underlying SLF4J API. Consequently, all JCL-specific -configration parameters are ignored. -

- -

Choosing a LogFactory Implementation

- -

From an application perspective, the first requirement is to -retrieve an object reference to the LogFactory instance -that will be used to create Log -instances for this application. This is normally accomplished by -calling the static getFactory() method. This method -always returns the same factory, i.e. a unique instance of the SLF4FLogFactory class. -

- - - -

Configuring the Underlying Logging System

- -

The basic principle is that the user is totally responsible for the -configuration of the underlying logging system. -Commons-logging should not change the existing configuration.

- -

Each individual Log implementation may -support its own configuration properties. These will be documented in the -class descriptions for the corresponding implementation class.

- -

Finally, some Log implementations (such as the one for Log4J) -require an external configuration file for the entire logging environment. -This file should be prepared in a manner that is specific to the actual logging -technology being used.

- - -

Using the Logging Package APIs

- -

Use of the Logging Package APIs, from the perspective of an application -component, consists of the following steps:

-
    -
  1. Acquire a reference to an instance of - org.apache.commons.logging.Log, by calling the - factory method - - LogFactory.getInstance(String name). Your application can contain - references to multiple loggers that are used for different - purposes. A typical scenario for a server application is to have each - major component of the server use its own Log instance.
  2. -
  3. Cause messages to be logged (if the corresponding detail level is enabled) - by calling appropriate methods (trace(), debug(), - info(), warn(), error, and - fatal()).
  4. -
- -

For convenience, LogFactory also offers a static method -getLog() that combines the typical two-step pattern:

-
-  Log log = LogFactory.getFactory().getInstance(Foo.class);
-
-

into a single method call:

-
-  Log log = LogFactory.getLog(Foo.class);
-
- -

For example, you might use the following technique to initialize and -use a Log instance in an application component:

-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class MyComponent {
-
-  protected static Log log =
-    LogFactory.getLog(MyComponent.class);
-
-  // Called once at startup time
-  public void start() {
-    ...
-    log.info("MyComponent started");
-    ...
-  }
-
-  // Called once at shutdown time
-  public void stop() {
-    ...
-    log.info("MyComponent stopped");
-    ...
-  }
-
-  // Called repeatedly to process a particular argument value
-  // which you want logged if debugging is enabled
-  public void process(String value) {
-    ...
-    // Do the string concatenation only if logging is enabled
-    if (log.isDebugEnabled())
-      log.debug("MyComponent processing " + value);
-    ...
-  }
-
-}
-
- - diff --git a/trunk/jcl-over-slf4j/src/main/resources/META-INF/MANIFEST.MF b/trunk/jcl-over-slf4j/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 3a3903708..000000000 --- a/trunk/jcl-over-slf4j/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,9 +0,0 @@ -Implementation-Title: jcl-over-slf4j -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: jcl.over.slf4j -Bundle-Name: jcl-over-slf4j -Bundle-Vendor: SLF4J.ORG -Bundle-RequiredExecutionEnvironment: J2SE-1.3 -Export-Package: org.apache.commons.logging;version=1.1.1, - org.apache.commons.logging.impl;version=1.1.1 -Import-Package: org.slf4j;version=${project.version}, org.slf4j.spi;version=${project.version} diff --git a/trunk/jcl-over-slf4j/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory b/trunk/jcl-over-slf4j/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory deleted file mode 100644 index 50a7c3bc9..000000000 --- a/trunk/jcl-over-slf4j/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory +++ /dev/null @@ -1,5 +0,0 @@ -org.apache.commons.logging.impl.SLF4JLogFactory - -# Axis gets at JCL through its own mechanism as defined by Commons Discovery, which -# in turn follows the instructions found at: -# http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Service Provider diff --git a/trunk/jcl-over-slf4j/src/test/java/org/apache/commons/logging/InvokeJCLTest.java b/trunk/jcl-over-slf4j/src/test/java/org/apache/commons/logging/InvokeJCLTest.java deleted file mode 100644 index 35f1fd109..000000000 --- a/trunk/jcl-over-slf4j/src/test/java/org/apache/commons/logging/InvokeJCLTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - - -package org.apache.commons.logging; - -import junit.framework.TestCase; - - -public class InvokeJCLTest extends TestCase { - - public void testIsEnabledAPI() { - // assume that we are running over slf4j-simple - Log log = LogFactory.getLog(InvokeJCLTest.class); - assertFalse(log.isTraceEnabled()); - assertFalse(log.isDebugEnabled()); - assertTrue(log.isInfoEnabled()); - assertTrue(log.isWarnEnabled()); - assertTrue(log.isErrorEnabled()); - assertTrue(log.isFatalEnabled()); - } - - public void testPrintAPI() { - Log log = LogFactory.getLog(InvokeJCLTest.class); - Exception e = new Exception("just testing"); - - log.trace(null); - log.trace("trace message"); - - log.debug(null); - log.debug("debug message"); - - log.info(null); - log.info("info message"); - - log.warn(null); - log.warn("warn message"); - - log.error(null); - log.error("error message"); - - log.fatal(null); - log.fatal("fatal message"); - - - log.trace(null, e); - log.trace("trace message", e); - - log.debug(null, e); - log.debug("debug message", e); - - log.info(null, e); - log.info("info message", e); - - log.warn(null, e); - log.warn("warn message", e); - - log.error(null, e); - log.error("error message", e); - - log.fatal(null, e); - log.fatal("fatal message", e); - } -} diff --git a/trunk/jcl-over-slf4j/src/test/java/org/apache/commons/logging/impl/SerializationTest.java b/trunk/jcl-over-slf4j/src/test/java/org/apache/commons/logging/impl/SerializationTest.java deleted file mode 100644 index cb7342f36..000000000 --- a/trunk/jcl-over-slf4j/src/test/java/org/apache/commons/logging/impl/SerializationTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.commons.logging.impl; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; - -import junit.framework.TestCase; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class SerializationTest extends TestCase { - - ObjectOutputStream oos; - - public SerializationTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - oos = new ObjectOutputStream(baos); - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - oos.close(); - } - - - public void testSmokeSimple() throws IOException { - Log log = LogFactory.getLog("testing"); - oos.writeObject(log); - } - - public void testSmokeLocationAware() throws IOException { - SLF4JLocationAwareLog log = new SLF4JLocationAwareLog(null); - oos.writeObject(log); - } -} diff --git a/trunk/jcl104-over-slf4j/pom.xml b/trunk/jcl104-over-slf4j/pom.xml deleted file mode 100644 index 0baa40998..000000000 --- a/trunk/jcl104-over-slf4j/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - jcl104-over-slf4j - - - - org.slf4j - jcl-over-slf4j - - As it now supports JCL versions 1.0.4, 1.1 and 1.1.1, the jcl104-over-slf4j module has been renamed as jcl-over-slf4j. - - - - - \ No newline at end of file diff --git a/trunk/jul-to-slf4j/pom.xml b/trunk/jul-to-slf4j/pom.xml deleted file mode 100644 index b5f71226e..000000000 --- a/trunk/jul-to-slf4j/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - jul-to-slf4j - - jar - JUL to SLF4J bridge - - http://www.slf4j.org - - JUL to SLF4J bridge - - - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-log4j12 - ${project.version} - test - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.4 - 1.4 - - - - - - - \ No newline at end of file diff --git a/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java b/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java deleted file mode 100644 index ae74ce18c..000000000 --- a/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - */ - -package org.slf4j.bridge; - -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.spi.LocationAwareLogger; - - -// Based on http://bugzilla.slf4j.org/show_bug.cgi?id=38 - -/** - * Bridge/route all JUL log records to the SLF4J API. - * - *

Essentially, the idea is to install on the root logger an instance of - * SLF4JBridgeHandler as the sole JUL handler in the system. Subsequently, the - * SLF4JBridgeHandler instance will redirect all JUL log records are redirected to - * the SLF4J API based on the following mapping of levels: - * - *

- * FINEST  -> TRACE
- * FINER   -> DEBUG
- * FINE    -> DEBUG
- * INFO    -> INFO
- * WARNING -> WARN
- * SEVER   -> ERROR
- * 
- * - * Usage: - * - *
- *   // once during initialization time of your application
- *   SLF4JHandler.install(handler);
- *   
- *   // usual pattern: get a Logger and then log a message
- *   java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger("org.wombat");
- *   julLogger.fine("hello world"); // this will get redirected to SLF4J
- * 
- * - * @author Christian Stein - * @author Joern Huxhorn - * @author Ceki G¨lc¨ - * - * @since 1.5.1 - */ -public class SLF4JBridgeHandler extends Handler { - - // The caller is java.util.logging.Logger - private static final String FQCN = java.util.logging.Logger.class.getName(); - private static final String UNKNOWN_LOGGER_NAME = "unknown.jul.logger"; - - private static final int TRACE_LEVEL_THRESHOLD = Level.FINEST.intValue(); - private static final int DEBUG_LEVEL_THRESHOLD = Level.FINE.intValue(); - private static final int INFO_LEVEL_THRESHOLD = Level.INFO.intValue(); - private static final int WARN_LEVEL_THRESHOLD = Level.WARNING.intValue(); - - /** - * Resets the entire JUL logging system and adds new SLF4JHandler instance to - * the root logger. - */ - public static void install() { - LogManager.getLogManager().reset(); - LogManager.getLogManager().getLogger("").addHandler(new SLF4JBridgeHandler()); - } - - /** - * Rereads the JUL configuration. - * - * @see LogManager#readConfiguration(); - * @throws Exception - * A SecurityException is thrown, if a security - * manager exists and if the caller does not have - * LoggingPermission("control"). IOException if - * there are IO problems reading the configuration. - */ - public static void uninstall() throws Exception { - LogManager.getLogManager().readConfiguration(); - } - - /** - * Initialize this handler. - * - */ - public SLF4JBridgeHandler() { - } - - /** - * No-op implementation. - */ - public void close() { - // empty - } - - /** - * No-op implementation. - */ - public void flush() { - // empty - } - - /** - * Return the Logger instance that will be used for logging. - */ - protected Logger getSLF4JLogger(LogRecord record) { - String name = record.getLoggerName(); - if (name == null) { - name = UNKNOWN_LOGGER_NAME; - } - return LoggerFactory.getLogger(name); - } - - protected void callLocationAwareLogger(LocationAwareLogger lal, LogRecord record) { - int julLevelValue = record.getLevel().intValue(); - int slf4jLevel; - - if (julLevelValue <= TRACE_LEVEL_THRESHOLD) { - slf4jLevel = LocationAwareLogger.TRACE_INT; - } else if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) { - slf4jLevel = LocationAwareLogger.DEBUG_INT; - } else if (julLevelValue <= INFO_LEVEL_THRESHOLD) { - slf4jLevel = LocationAwareLogger.INFO_INT; - } else if (julLevelValue <= WARN_LEVEL_THRESHOLD) { - slf4jLevel = LocationAwareLogger.WARN_INT; - } else { - slf4jLevel = LocationAwareLogger.ERROR_INT; - } - lal.log(null, FQCN, slf4jLevel, record.getMessage(), record.getThrown()); - } - - protected void callPlainSLF4JLogger(Logger slf4jLogger, LogRecord record) { - int julLevelValue = record.getLevel().intValue(); - if (julLevelValue <= TRACE_LEVEL_THRESHOLD) { - slf4jLogger.trace(record.getMessage(), record.getThrown()); - } else if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) { - slf4jLogger.debug(record.getMessage(), record.getThrown()); - } else if (julLevelValue <= INFO_LEVEL_THRESHOLD) { - slf4jLogger.info(record.getMessage(), record.getThrown()); - } else if (julLevelValue <= WARN_LEVEL_THRESHOLD) { - slf4jLogger.warn(record.getMessage(), record.getThrown()); - } else { - slf4jLogger.error(record.getMessage(), record.getThrown()); - } - } - - /** - * Publish a LogRecord. - *

- * The logging request was made initially to a Logger object, which - * initialized the LogRecord and forwarded it here. - *

- * This handler ignores the Level attached to the LogRecord, as SLF4J cares - * about discarding log statements. - * - * @param record - * Description of the log event. A null record is silently - * ignored and is not published. - */ - public void publish(LogRecord record) { - // Silently ignore null records. - if (record == null) { - return; - } - - Logger slf4jLogger = getSLF4JLogger(record); - String message = record.getMessage(); // can be null! - if (message == null) { - return; - } - if (slf4jLogger instanceof LocationAwareLogger) { - callLocationAwareLogger((LocationAwareLogger) slf4jLogger, record); - } else { - callPlainSLF4JLogger(slf4jLogger, record); - } - } -} diff --git a/trunk/jul-to-slf4j/src/test/java/org/slf4j/bridge/ListAppender.java b/trunk/jul-to-slf4j/src/test/java/org/slf4j/bridge/ListAppender.java deleted file mode 100644 index 640e4cf38..000000000 --- a/trunk/jul-to-slf4j/src/test/java/org/slf4j/bridge/ListAppender.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.slf4j.bridge; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LoggingEvent; - -public class ListAppender extends AppenderSkeleton { - - public List list = new ArrayList(); - - public boolean extractLocationInfo = false; - - protected void append(LoggingEvent event) { - list.add(event); - if(extractLocationInfo) { - event.getLocationInformation(); - } - } - - public void close() { - } - - public boolean requiresLayout() { - return false; - } - -} diff --git a/trunk/jul-to-slf4j/src/test/java/org/slf4j/bridge/SLF4JBridgeHandlerTest.java b/trunk/jul-to-slf4j/src/test/java/org/slf4j/bridge/SLF4JBridgeHandlerTest.java deleted file mode 100644 index 58e12ab36..000000000 --- a/trunk/jul-to-slf4j/src/test/java/org/slf4j/bridge/SLF4JBridgeHandlerTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.slf4j.bridge; - -import java.util.logging.Level; - -import org.apache.log4j.spi.LocationInfo; -import org.apache.log4j.spi.LoggingEvent; -import org.slf4j.bridge.SLF4JBridgeHandler; - -import junit.framework.TestCase; - -public class SLF4JBridgeHandlerTest extends TestCase { - - static String LOGGER_NAME = "yay"; - - ListAppender listAppender = new ListAppender(); - org.apache.log4j.Logger log4jRoot; - java.util.logging.Logger julLogger = java.util.logging.Logger - .getLogger("yay"); - - public SLF4JBridgeHandlerTest(String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); - listAppender.extractLocationInfo = true; - log4jRoot = org.apache.log4j.Logger.getRootLogger(); - log4jRoot.addAppender(listAppender); - log4jRoot.setLevel(org.apache.log4j.Level.TRACE); - } - - protected void tearDown() throws Exception { - super.tearDown(); - log4jRoot.getLoggerRepository().resetConfiguration(); - } - - public void testSmoke() { - SLF4JBridgeHandler.install(); - String msg = "msg"; - julLogger.info(msg); - assertEquals(1, listAppender.list.size()); - LoggingEvent le = (LoggingEvent) listAppender.list.get(0); - assertEquals(LOGGER_NAME, le.getLoggerName()); - assertEquals(msg, le.getMessage()); - - // get the location info in the event. - // Note that this must have been computed previously - // within an appender for the following assertion to - // work properly - LocationInfo li = le.getLocationInformation(); - System.out.println(li.fullInfo); - assertEquals("SLF4JBridgeHandlerTest.java", li.getFileName()); - assertEquals("testSmoke", li.getMethodName()); - } - - public void testLevels() { - SLF4JBridgeHandler.install(); - String msg = "msg"; - julLogger.setLevel(Level.ALL); - - julLogger.finest(msg); - julLogger.finer(msg); - julLogger.fine(msg); - julLogger.info(msg); - julLogger.warning(msg); - julLogger.severe(msg); - - assertEquals(6, listAppender.list.size()); - int i = 0; - assertLevel(i++, org.apache.log4j.Level.TRACE); - assertLevel(i++, org.apache.log4j.Level.DEBUG); - assertLevel(i++, org.apache.log4j.Level.DEBUG); - assertLevel(i++, org.apache.log4j.Level.INFO); - assertLevel(i++, org.apache.log4j.Level.WARN); - assertLevel(i++, org.apache.log4j.Level.ERROR); - } - - void assertLevel(int index, org.apache.log4j.Level expectedLevel) { - LoggingEvent le = (LoggingEvent) listAppender.list.get(index); - assertEquals(expectedLevel, le.getLevel()); - } -} diff --git a/trunk/log4j-over-slf4j/compatibility/build.xml b/trunk/log4j-over-slf4j/compatibility/build.xml deleted file mode 100644 index b60875a02..000000000 --- a/trunk/log4j-over-slf4j/compatibility/build.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - These are some of the targets supported by this ANT build scpript: - - all - run all available tests - refresh - copy required jar files to the lib directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/log4j-over-slf4j/compatibility/lib/junit-3.8.1.jar b/trunk/log4j-over-slf4j/compatibility/lib/junit-3.8.1.jar deleted file mode 100644 index 674d71e89..000000000 Binary files a/trunk/log4j-over-slf4j/compatibility/lib/junit-3.8.1.jar and /dev/null differ diff --git a/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.2.14.jar b/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.2.14.jar deleted file mode 100644 index 625130719..000000000 Binary files a/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.2.14.jar and /dev/null differ diff --git a/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.3alpha-8.jar b/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.3alpha-8.jar deleted file mode 100644 index 64d6c3cb4..000000000 Binary files a/trunk/log4j-over-slf4j/compatibility/lib/log4j-1.3alpha-8.jar and /dev/null differ diff --git a/trunk/log4j-over-slf4j/compatibility/lib/log4j-over-slf4j-1.4.2.jar b/trunk/log4j-over-slf4j/compatibility/lib/log4j-over-slf4j-1.4.2.jar deleted file mode 100644 index e534620cc..000000000 Binary files a/trunk/log4j-over-slf4j/compatibility/lib/log4j-over-slf4j-1.4.2.jar and /dev/null differ diff --git a/trunk/log4j-over-slf4j/compatibility/lib/logback-classic-0.9.8-SNAPSHOT.jar b/trunk/log4j-over-slf4j/compatibility/lib/logback-classic-0.9.8-SNAPSHOT.jar deleted file mode 100644 index 8efc27cd4..000000000 Binary files a/trunk/log4j-over-slf4j/compatibility/lib/logback-classic-0.9.8-SNAPSHOT.jar and /dev/null differ diff --git a/trunk/log4j-over-slf4j/compatibility/lib/logback-core-0.9.8-SNAPSHOT.jar b/trunk/log4j-over-slf4j/compatibility/lib/logback-core-0.9.8-SNAPSHOT.jar deleted file mode 100644 index 0f64802dc..000000000 Binary files a/trunk/log4j-over-slf4j/compatibility/lib/logback-core-0.9.8-SNAPSHOT.jar and /dev/null differ diff --git a/trunk/log4j-over-slf4j/compatibility/lib/slf4j-api-1.4.2.jar b/trunk/log4j-over-slf4j/compatibility/lib/slf4j-api-1.4.2.jar deleted file mode 100644 index c8cae17e9..000000000 Binary files a/trunk/log4j-over-slf4j/compatibility/lib/slf4j-api-1.4.2.jar and /dev/null differ diff --git a/trunk/log4j-over-slf4j/compatibility/readme.txt b/trunk/log4j-over-slf4j/compatibility/readme.txt deleted file mode 100644 index 575b35818..000000000 --- a/trunk/log4j-over-slf4j/compatibility/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ - -This directory is used to test the module against various log4j calls. -Two test cases simulate the typical calls that one can find in an application -that uses either log4j 1.2.x, or log4j 1.3.x. - -In the same directory is a build.xml file that uses ant to -compile the test cases with the corresponding log4j version, -and to runs these tests without log4j in the classpath but with -logback jars instead. - -To run the tests, one must have ant installed. Issuing the following command, -once in the compatibility directory will launch the tests: - -ant all - -To obtain more information about the use of the log4j-over-slf4j module, -please visit http://www..slf4j.org/log4j-over-slf4j.html \ No newline at end of file diff --git a/trunk/log4j-over-slf4j/compatibility/src/main/java/test/DummyObject.java b/trunk/log4j-over-slf4j/compatibility/src/main/java/test/DummyObject.java deleted file mode 100644 index 73473eeca..000000000 --- a/trunk/log4j-over-slf4j/compatibility/src/main/java/test/DummyObject.java +++ /dev/null @@ -1,8 +0,0 @@ -package test; - -public class DummyObject { - - public String toString() { - return "dummy"; - } -} diff --git a/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j12Calls.java b/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j12Calls.java deleted file mode 100644 index 1a1860cb0..000000000 --- a/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j12Calls.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * - * Copyright (C) 1999-2006, QOS.ch - * - * This library 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. - */ -package test; - -import junit.framework.TestCase; - -import org.apache.log4j.Logger; -import org.apache.log4j.MDC; - -/** - * - * A test case that issues the typical calls - * that an application using log4j 1.2 would do. - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public class Log4j12Calls extends TestCase { - public static final Logger logger = Logger.getLogger(Log4j12Calls.class); - - public void testLog() { - MDC.put("key", "value1"); - - logger.trace("Trace level can be noisy"); - logger.debug("Entering application"); - logger.info("Violets are blue"); - logger.warn("Here is a warning"); - logger.error("Exiting application", new Exception("just testing")); - - MDC.remove("key"); - } -} diff --git a/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j13Calls.java b/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j13Calls.java deleted file mode 100644 index b44e4ed5d..000000000 --- a/trunk/log4j-over-slf4j/compatibility/src/main/java/test/Log4j13Calls.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * - * Copyright (C) 1999-2006, QOS.ch - * - * This library 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. - */ - -package test; - -import junit.framework.TestCase; - -import org.apache.log4j.Logger; -import org.apache.log4j.MDC; - -/** - * - * A test case that issues the typical calls - * that an application using log4j 1.3 would do. - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ - -public class Log4j13Calls extends TestCase { - public static final Logger logger = Logger.getLogger(Log4j12Calls.class); - - public void testLog() { - MDC.put("key", "value1"); - - logger.trace("Trace level can be noisy"); - logger.debug("Entering application"); - logger.info("Violets are blue"); - logger.warn("Here is a warning"); - logger.info("The answer is {}.", new Integer(42)); - logger.info("Number: {} and another one: {}.", new Integer(42), new Integer(24)); - - logger.error("Exiting application", new Exception("just testing")); - - MDC.remove("key"); - - MDC.clear(); - } -} diff --git a/trunk/log4j-over-slf4j/compatibility/src/main/java/test/LoggerTest.java b/trunk/log4j-over-slf4j/compatibility/src/main/java/test/LoggerTest.java deleted file mode 100644 index 61c5a79cf..000000000 --- a/trunk/log4j-over-slf4j/compatibility/src/main/java/test/LoggerTest.java +++ /dev/null @@ -1,169 +0,0 @@ -package test; - -import junit.framework.TestCase; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.spi.LoggingEvent; -import ch.qos.logback.core.read.ListAppender; -import org.apache.log4j.Level; - -/** - * A class that tests the invocation of the org.apache.log4j.Logger class that - * belongs to the log4j-bridge package - * - * @author Sébastien Pennec - * @author Ceki Gülcü - */ - -public class LoggerTest extends TestCase { - - LoggerContext context; - ListAppender appender; - ch.qos.logback.classic.Logger logbackLogger; - org.apache.log4j.Logger log4jLogger; - - public void setUp() throws Exception { - context = (LoggerContext) LoggerFactory.getILoggerFactory(); - context.shutdownAndReset(); - appender = new ListAppender(); - appender.setContext(context); - appender.setName("listAppender"); - appender.start(); - ch.qos.logback.classic.Logger lbLogger = context - .getLogger(LoggerContext.ROOT_NAME); - lbLogger.addAppender(appender); - - log4jLogger = org.apache.log4j.Logger.getLogger(LoggerTest.class); - logbackLogger = context.getLogger(LoggerTest.class); - super.setUp(); - } - - public void tearDown() throws Exception { - appender.stop(); - context.stop(); - appender = null; - context = null; - logbackLogger = null; - log4jLogger = null; - super.tearDown(); - } - - public void testLogWithObjectMessages() { - LoggingEvent event; - - log4jLogger.debug("test"); - event = appender.list.get(0); - assertEquals("test", event.getMessage()); - appender.list.clear(); - - log4jLogger.debug(null); - event = appender.list.get(0); - assertEquals(null, event.getMessage()); - appender.list.clear(); - - DummyObject dummy = new DummyObject(); - log4jLogger.debug(dummy); - event = appender.list.get(0); - assertEquals(dummy.toString(), event.getMessage()); - appender.list.clear(); - } - - public void testIsEnabledAPI() { - assertFalse(log4jLogger.isTraceEnabled()); - assertTrue(log4jLogger.isDebugEnabled()); - assertTrue(log4jLogger.isInfoEnabled()); - assertTrue(log4jLogger.isWarnEnabled()); - assertTrue(log4jLogger.isErrorEnabled()); - } - - public void testPrintAPI() { - Exception e = new Exception("just testing"); - - log4jLogger.trace(null); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.debug(null); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.debug("debug message"); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.info(null); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.info("info message"); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.warn(null); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.warn("warn message"); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.error(null); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.error("error message"); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.debug(null, e); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.debug("debug message", e); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.info(null, e); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.info("info message", e); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.warn(null, e); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.warn("warn message", e); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.error(null, e); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - log4jLogger.error("error message", e); - assertEquals(1, appender.list.size()); - appender.list.clear(); - - } - - public void testLogAPI() { - log4jLogger.log("x", Level.TRACE, "x", null); - assertEquals(0, appender.list.size()); - - log4jLogger.log("x", Level.DEBUG, "x", null); - log4jLogger.log("x", Level.INFO, "x", null); - log4jLogger.log("x", Level.WARN, "x", null); - log4jLogger.log("x", Level.ERROR, "x", null); - log4jLogger.log("x", Level.FATAL, "x", null); - - assertEquals(5, appender.list.size()); - appender.list.clear(); - - } - -} diff --git a/trunk/log4j-over-slf4j/pom.xml b/trunk/log4j-over-slf4j/pom.xml deleted file mode 100644 index 9d2fc71f4..000000000 --- a/trunk/log4j-over-slf4j/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - log4j-over-slf4j - jar - Log4j Implemented Over SLF4J - - http://www.slf4j.org - - - - Log4j implemented over SLF4J - - - - Apache Software Licenses - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - - org.slf4j - slf4j-api - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - bundle-test-jar - package - - jar - - - - - - - - \ No newline at end of file diff --git a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java b/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java deleted file mode 100644 index 1b9706436..000000000 --- a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.log4j; - -import org.slf4j.LoggerFactory; -import org.slf4j.Marker; -import org.slf4j.MarkerFactory; -import org.slf4j.spi.LocationAwareLogger; - -/** - *

- * This class is a minimal implementation of the original - * org.apache.log4j.Logger class by delegation of all calls - * to a {@link org.slf4j.Logger.Logger} instance. - *

- * - *

- * Log4j's trace, debug(), info(), - * warn(), error() printing methods are directly - * mapped to their SLF4J equivalents. Log4j's fatal() - * printing method is mapped to SLF4J's error() method - * with a FATAL marker. - * - * @author Sébastien Pennec - * @author Ceki Gülcü - */ - -public class Category { - - private String name; - - private org.slf4j.Logger slf4jLogger; - private org.slf4j.spi.LocationAwareLogger locationAwareLogger; - - private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL"); - - Category(String name) { - this.name = name; - slf4jLogger = LoggerFactory.getLogger(name); - if(slf4jLogger instanceof LocationAwareLogger) { - locationAwareLogger = (LocationAwareLogger) slf4jLogger; - } - } - - public static Logger getLogger(String name) { - return Log4jLoggerFactory.getLogger(name); - } - - public static Logger getLogger(Class clazz) { - return getLogger(clazz.getName()); - } - - /** - * Does the obvious. - * - * @return - */ - public static Logger getRootLogger() { - return getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); - } - - /** - * Returns the obvious. - * - * @return - */ - public String getName() { - return name; - } - - /** - * Return the level in effect for this category/logger. - * - *

- * The result is computed by simulation. - * - * @return - */ - public Level getEffectiveLevel() { - if(slf4jLogger.isTraceEnabled()) { - return Level.TRACE; - } - if(slf4jLogger.isDebugEnabled()) { - return Level.DEBUG; - } - if(slf4jLogger.isInfoEnabled()) { - return Level.INFO; - } - if(slf4jLogger.isWarnEnabled()) { - return Level.WARN; - } - return Level.ERROR; - } - - /** - * Returns the assigned {@link Level}, if any, for this Category. - * This implementation always returns null. - * - * @return Level - the assigned Level, can be null. - */ - final public Level getLevel() { - return null; - } - - - /** - * @deprecated Please use {@link #getLevel} instead. - */ - final public Level getPriority() { - return null; - } - - /** - * Delegates to {@link org.slf4j.Logger#isTraceEnabled} - * method of SLF4J. - */ - public boolean isTraceEnabled() { - return slf4jLogger.isTraceEnabled(); - } - - /** - * Delegates to {@link org.slf4j.Logger#isDebugEnabled} method in SLF4J - */ - public boolean isDebugEnabled() { - return slf4jLogger.isDebugEnabled(); - } - - /** - * Delegates to {@link org.slf4j.Logger#isInfoEnabled} method in SLF4J - */ - public boolean isInfoEnabled() { - return slf4jLogger.isInfoEnabled(); - } - - /** - * Delegates to {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J - */ - public boolean isWarnEnabled() { - return slf4jLogger.isWarnEnabled(); - } - - /** - * Delegates to {@link org.slf4j.Logger#isErrorEnabled} method in SLF4J - */ - public boolean isErrorEnabled() { - return slf4jLogger.isErrorEnabled(); - } - - /** - * Delegates to {@link #isEnabledFor(Level)}. - * - * @param p the priority to check against - * @return true if this logger is enabled for the given priority, false otehrwise. - */ - public boolean isEnabledFor(Priority p) { - return isEnabledFor(Level.toLevel(p.level)); - } - - /** - * Determines whether the level passes as parameter is enabled in - * the underlying SLF4J logger. Each log4j level is mapped directly to - * its SLF4J equivalent, except for FATAL which is mapped as ERROR. - * - * @param l the level to check against - * @return true if this logger is enabled for the given level, false otehrwise. - */ - public boolean isEnabledFor(Level l) { - switch (l.level) { - case Level.TRACE_INT: - return slf4jLogger.isTraceEnabled(); - case Level.DEBUG_INT: - return slf4jLogger.isDebugEnabled(); - case Level.INFO_INT: - return slf4jLogger.isInfoEnabled(); - case Level.WARN_INT: - return slf4jLogger.isWarnEnabled(); - case Level.ERROR_INT: - return slf4jLogger.isErrorEnabled(); - case Priority.FATAL_INT: - return slf4jLogger.isErrorEnabled(); - } - return false; - } - - /** - * Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J. - */ - public void trace(Object message) { - // casting to String as SLF4J only accepts String instances, not Object - // instances. - slf4jLogger.trace(convertToString(message)); - } - - /** - * Delegates to {@link org.slf4j.Logger#trace(String,Throwable)} - * method in SLF4J. - */ - public void trace(Object message, Throwable t) { - slf4jLogger.trace(convertToString(message), t); - } - - /** - * Delegates to {@link org.slf4j.Logger#debug(String)} method of - * SLF4J. - */ - public void debug(Object message) { - // casting to String as SLF4J only accepts String instances, not Object - // instances. - slf4jLogger.debug(convertToString(message)); - } - - /** - * Delegates to {@link org.slf4j.Logger#debug(String,Throwable)} - * method in SLF4J. - */ - public void debug(Object message, Throwable t) { - slf4jLogger.debug(convertToString(message), t); - } - - /** - * Delegates to {@link org.slf4j.Logger#info(String)} - * method in SLF4J. - */ - public void info(Object message) { - slf4jLogger.info(convertToString(message)); - } - - /** - * Delegates to {@link org.slf4j.Logger#info(String,Throwable)} - * method in SLF4J. - */ - public void info(Object message, Throwable t) { - slf4jLogger.info(convertToString(message), t); - } - - /** - * Delegates to {@link org.slf4j.Logger#warn(String)} - * method in SLF4J. - */ - public void warn(Object message) { - slf4jLogger.warn(convertToString(message)); - } - - /** - * Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} - * method in SLF4J. - */ - public void warn(Object message, Throwable t) { - slf4jLogger.warn(convertToString(message), t); - } - - - /** - * Delegates to {@link org.slf4j.Logger#error(String)} - * method in SLF4J. - */ - public void error(Object message) { - slf4jLogger.error(convertToString(message)); - } - - /** - * Delegates to {@link org.slf4j.Logger#error(String,Throwable)} - * method in SLF4J. - */ - public void error(Object message, Throwable t) { - slf4jLogger.error(convertToString(message), t); - } - - /** - * Delegates to {@link org.slf4j.Logger#error(String)} - * method in SLF4J. - */ - public void fatal(Object message) { - slf4jLogger.error(FATAL_MARKER, convertToString(message)); - } - - /** - * Delegates to {@link org.slf4j.Logger#error(String,Throwable)} - * method in SLF4J. In addition, the call is marked with a marker named "FATAL". - */ - public void fatal(Object message, Throwable t) { - slf4jLogger.error(FATAL_MARKER, convertToString(message), t); - } - - public void log(String FQCN, Priority p, Object msg, Throwable t) { - int levelInt = priorityToLevelInt(p); - if(locationAwareLogger != null) { - if(msg != null) { - locationAwareLogger.log(null, FQCN, levelInt, msg.toString(), t); - } else { - locationAwareLogger.log(null, FQCN, levelInt, null, t); - } - } else { - throw new UnsupportedOperationException("The logger ["+slf4jLogger+"] does not seem to be location aware."); - } - - } - - private int priorityToLevelInt(Priority p) { - switch (p.level) { - case Level.TRACE_INT: - return LocationAwareLogger.TRACE_INT; - case Priority.DEBUG_INT: - return LocationAwareLogger.DEBUG_INT; - case Priority.INFO_INT: - return LocationAwareLogger.INFO_INT; - case Priority.WARN_INT: - return LocationAwareLogger.WARN_INT; - case Priority.ERROR_INT: - return LocationAwareLogger.ERROR_INT; - case Priority.FATAL_INT: - return LocationAwareLogger.ERROR_INT; - default: - throw new IllegalStateException("Unknown Priority " + p); - } - } - - private final String convertToString(Object message) { - if (message == null) { - return (String)message; - } else { - return message.toString(); - } - } - -} diff --git a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java b/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java deleted file mode 100644 index f4c685f28..000000000 --- a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 1999-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Contributors: Kitching Simon -// Nicholas Wolff - -package org.apache.log4j; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamException; -import java.io.Serializable; - -/** - Defines the minimum set of levels recognized by the system, that is - OFF, FATAL, ERROR, - WARN, INFODEBUG and - ALL. - -

The Level class may be subclassed to define a larger - level set. - - @author Ceki Gülcü - - */ -public class Level extends Priority implements Serializable { - - /** - * TRACE level integer value. - * @since 1.2.12 - */ - public static final int TRACE_INT = 5000; - - /** - The OFF has the highest possible rank and is - intended to turn off logging. */ - final static public Level OFF = new Level(OFF_INT, "OFF", 0); - - /** - The FATAL level designates very severe error - events that will presumably lead the application to abort. - */ - final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0); - - /** - The ERROR level designates error events that - might still allow the application to continue running. */ - final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3); - - /** - The WARN level designates potentially harmful situations. - */ - final static public Level WARN = new Level(WARN_INT, "WARN", 4); - - /** - The INFO level designates informational messages - that highlight the progress of the application at coarse-grained - level. */ - final static public Level INFO = new Level(INFO_INT, "INFO", 6); - - /** - The DEBUG Level designates fine-grained - informational events that are most useful to debug an - application. */ - final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7); - - /** - * The TRACE Level designates finer-grained - * informational events than the DEBUGALL has the lowest possible rank and is intended to - turn on all logging. */ - final static public Level ALL = new Level(ALL_INT, "ALL", 7); - - /** - * Serialization version id. - */ - static final long serialVersionUID = 3491141966387921974L; - - /** - Instantiate a Level object. - */ - protected - Level(int level, String levelStr, int syslogEquivalent) { - super(level, levelStr, syslogEquivalent); - } - - - /** - Convert the string passed as argument to a level. If the - conversion fails, then this method returns {@link #DEBUG}. - */ - public - static - Level toLevel(String sArg) { - return (Level) toLevel(sArg, Level.DEBUG); - } - - /** - Convert an integer passed as argument to a level. If the - conversion fails, then this method returns {@link #DEBUG}. - - */ - public - static - Level toLevel(int val) { - return (Level) toLevel(val, Level.DEBUG); - } - - /** - Convert an integer passed as argument to a level. If the - conversion fails, then this method returns the specified default. - */ - public - static - Level toLevel(int val, Level defaultLevel) { - switch(val) { - case ALL_INT: return ALL; - case DEBUG_INT: return Level.DEBUG; - case INFO_INT: return Level.INFO; - case WARN_INT: return Level.WARN; - case ERROR_INT: return Level.ERROR; - case FATAL_INT: return Level.FATAL; - case OFF_INT: return OFF; - case TRACE_INT: return Level.TRACE; - default: return defaultLevel; - } - } - - /** - Convert the string passed as argument to a level. If the - conversion fails, then this method returns the value of - defaultLevel. - */ - public - static - Level toLevel(String sArg, Level defaultLevel) { - if(sArg == null) - return defaultLevel; - - String s = sArg.toUpperCase(); - - if(s.equals("ALL")) return Level.ALL; - if(s.equals("DEBUG")) return Level.DEBUG; - if(s.equals("INFO")) return Level.INFO; - if(s.equals("WARN")) return Level.WARN; - if(s.equals("ERROR")) return Level.ERROR; - if(s.equals("FATAL")) return Level.FATAL; - if(s.equals("OFF")) return Level.OFF; - if(s.equals("TRACE")) return Level.TRACE; - return defaultLevel; - } - - /** - * Custom deserialization of Level. - * @param s serialization stream. - * @throws IOException if IO exception. - * @throws ClassNotFoundException if class not found. - */ - private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); - level = s.readInt(); - syslogEquivalent = s.readInt(); - levelStr = s.readUTF(); - if (levelStr == null) { - levelStr = ""; - } - } - - /** - * Serialize level. - * @param s serialization stream. - * @throws IOException if exception during serialization. - */ - private void writeObject(final ObjectOutputStream s) throws IOException { - s.defaultWriteObject(); - s.writeInt(level); - s.writeInt(syslogEquivalent); - s.writeUTF(levelStr); - } - - /** - * Resolved deserialized level to one of the stock instances. - * May be overriden in classes derived from Level. - * @return resolved object. - * @throws ObjectStreamException if exception during resolution. - */ - private Object readResolve() throws ObjectStreamException { - // - // if the deserizalized object is exactly an instance of Level - // - if (getClass() == Level.class) { - return toLevel(level); - } - // - // extension of Level can't substitute stock item - // - return this; - } -} \ No newline at end of file diff --git a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java b/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java deleted file mode 100644 index 0b02a0881..000000000 --- a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.log4j; - -import java.util.Hashtable; - -/** - * This class is a factory that creates and maintains org.apache.log4j.Loggers - * warpping org.slf4j.Loggers. - * - * It keeps a hashtable of all created org.apache.log4j.Logger instances so that - * all newly created instances are not dulpicates of existing loggers. - * - * @author Sébastien Pennec - */ -class Log4jLoggerFactory { - - // String, Logger - private static Hashtable log4jLoggers = new Hashtable(); - - public static synchronized Logger getLogger(String name) { - if (log4jLoggers.containsKey(name)) { - return (org.apache.log4j.Logger) log4jLoggers.get(name); - } else { - Logger log4jLogger = new Logger(name); - - log4jLoggers.put(name, log4jLogger); - return log4jLogger; - } - } - -} diff --git a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java b/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java deleted file mode 100644 index 2c4da8a27..000000000 --- a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.log4j; - -public class Logger extends Category { - - Logger(String name) { - super(name); - } - -} diff --git a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java b/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java deleted file mode 100644 index e5b4bd5bd..000000000 --- a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.apache.log4j; - -public class MDC { - - public static void put(String key, String value) { - org.slf4j.MDC.put(key, value); - } - - public static void put(String key, Object value) { - if (value != null) { - put(key, value.toString()); - } else { - put(key, null); - } - } - - public static Object get(String key) { - return org.slf4j.MDC.get(key); - } - - public static void remove(String key) { - org.slf4j.MDC.remove(key); - } - - public static void clear() { - org.slf4j.MDC.clear(); - } -} diff --git a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java b/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java deleted file mode 100644 index 68fab1108..000000000 --- a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright 1999-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Contributors: Kitching Simon - -package org.apache.log4j; - -/** - Refrain from using this class directly, use - the {@link Level} class instead. - - @author Ceki Gülcü */ -public class Priority { - - transient int level; - transient String levelStr; - transient int syslogEquivalent; - - public final static int OFF_INT = Integer.MAX_VALUE; - public final static int FATAL_INT = 50000; - public final static int ERROR_INT = 40000; - public final static int WARN_INT = 30000; - public final static int INFO_INT = 20000; - public final static int DEBUG_INT = 10000; - //public final static int FINE_INT = DEBUG_INT; - public final static int ALL_INT = Integer.MIN_VALUE; - - /** - * @deprecated Use {@link Level#FATAL} instead. - */ - final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0); - - /** - * @deprecated Use {@link Level#ERROR} instead. - */ - final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3); - - /** - * @deprecated Use {@link Level#WARN} instead. - */ - final static public Priority WARN = new Level(WARN_INT, "WARN", 4); - - /** - * @deprecated Use {@link Level#INFO} instead. - */ - final static public Priority INFO = new Level(INFO_INT, "INFO", 6); - - /** - * @deprecated Use {@link Level#DEBUG} instead. - */ - final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7); - - - /** - * Default constructor for deserialization. - */ - protected Priority() { - level = DEBUG_INT; - levelStr = "DEBUG"; - syslogEquivalent = 7; - } - - /** - Instantiate a level object. - */ - protected - Priority(int level, String levelStr, int syslogEquivalent) { - this.level = level; - this.levelStr = levelStr; - this.syslogEquivalent = syslogEquivalent; - } - - /** - Two priorities are equal if their level fields are equal. - @since 1.2 - */ - public - boolean equals(Object o) { - if(o instanceof Priority) { - Priority r = (Priority) o; - return (this.level == r.level); - } else { - return false; - } - } - - /** - Return the syslog equivalent of this priority as an integer. - */ - public - final - int getSyslogEquivalent() { - return syslogEquivalent; - } - - - - /** - Returns true if this level has a higher or equal - level than the level passed as argument, false - otherwise. - -

You should think twice before overriding the default - implementation of isGreaterOrEqual method. - - */ - public - boolean isGreaterOrEqual(Priority r) { - return level >= r.level; - } - - /** - Return all possible priorities as an array of Level objects in - descending order. - - @deprecated This method will be removed with no replacement. - */ - public - static - Priority[] getAllPossiblePriorities() { - return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN, - Priority.INFO, Priority.DEBUG}; - } - - - /** - Returns the string representation of this priority. - */ - final - public - String toString() { - return levelStr; - } - - /** - Returns the integer representation of this level. - */ - public - final - int toInt() { - return level; - } - - /** - * @deprecated Please use the {@link Level#toLevel(String)} method instead. - */ - public - static - Priority toPriority(String sArg) { - return Level.toLevel(sArg); - } - - /** - * @deprecated Please use the {@link Level#toLevel(int)} method instead. - */ - public - static - Priority toPriority(int val) { - return toPriority(val, Priority.DEBUG); - } - - /** - * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead. - */ - public - static - Priority toPriority(int val, Priority defaultPriority) { - return Level.toLevel(val, (Level) defaultPriority); - } - - /** - * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead. - */ - public - static - Priority toPriority(String sArg, Priority defaultPriority) { - return Level.toLevel(sArg, (Level) defaultPriority); - } -} \ No newline at end of file diff --git a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html b/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html deleted file mode 100644 index 357d0e66b..000000000 --- a/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - -

An rather minimal but sufficient implementation redirecting all - calls to a log4j logger to a logback logger.

- - - - - diff --git a/trunk/osgi-over-slf4j/pom.xml b/trunk/osgi-over-slf4j/pom.xml deleted file mode 100644 index c3c05add0..000000000 --- a/trunk/osgi-over-slf4j/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - osgi-over-slf4j - bundle - OSGi LogService Implemented Over SLF4J - - http://www.slf4j.org - - OSGi LogService implementation over SLF4J - - - - - org.osgi - org.osgi.core - 4.0 - provided - - - org.osgi - org.osgi.compendium - 4.0 - provided - - - - org.slf4j - slf4j-simple - ${project.version} - provided - - - - - - org.apache.felix - maven-bundle-plugin - 0.9.0-incubator-SNAPSHOT - true - - - org.osgi.service.log - org.slf4j;version=${project.version},* - org.slf4j.osgi.logservice.impl - org.slf4j.osgi.logservice.impl.Activator - - - - - - \ No newline at end of file diff --git a/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/Activator.java b/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/Activator.java deleted file mode 100644 index 06e31e939..000000000 --- a/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/Activator.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.logservice.impl; - -import java.util.Hashtable; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceFactory; -import org.osgi.service.log.LogService; - -/** - * Activator implements a simple bundle that registers a - * {@link LogServiceFactory} for the creation of {@link LogService} implementations. -**/ -public class Activator implements BundleActivator { - - /** - * - * Implements BundleActivator.start() to register a - * LogServiceFactory. - * - * @param bundleContext the framework context for the bundle - * @throws Exception - */ - public void start(BundleContext bundleContext) throws Exception { - Hashtable props = new Hashtable(); - props.put("description", "An slf4j implementation."); - ServiceFactory factory = new LogServiceFactory(); - bundleContext.registerService(LogService.class.getName(), factory, props); - } - - /** - * - * Implements BundleActivator.stop(). - * - * @param bundleContext the framework context for the bundle - * @throws Exception - */ - public void stop(BundleContext bundleContext) throws Exception { - - // Note: It is not required that we remove the service here, since - // the framework will do it automatically anyway. - } - - -} diff --git a/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceFactory.java b/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceFactory.java deleted file mode 100644 index babba0975..000000000 --- a/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.logservice.impl; - -import org.osgi.framework.Bundle; -import org.osgi.framework.ServiceFactory; -import org.osgi.framework.ServiceRegistration; - -/** - * LogServiceFactory creates LogService implemenations. - * - * @author John Conlon - * @version $Rev$, $Date$ - */ -public class LogServiceFactory implements ServiceFactory -{ - - - /* (non-Javadoc) - * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration) - */ - public Object getService( Bundle bundle, ServiceRegistration arg1 ) - { - - return new LogServiceImpl(bundle); - } - - - /* (non-Javadoc) - * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object) - */ - public void ungetService( Bundle bundle, ServiceRegistration arg1, Object arg2 ) - { - // Ignore for now - - } - -} diff --git a/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java b/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java deleted file mode 100644 index 9253f080e..000000000 --- a/trunk/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.logservice.impl; - -import org.osgi.framework.Bundle; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceReference; -import org.osgi.service.log.LogService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * LogServiceImpl is a simple OSGi LogService implemenation that delegates to a slf4j - * Logger. - * - * @author John Conlon - */ -public class LogServiceImpl implements LogService { - - private static final String UNKNOWN = "[Unknown]"; - - private final Logger delegate; - - /** - * Creates a new instance of LogServiceImpl. - * - */ - public LogServiceImpl(Bundle bundle) { - String name = (String) bundle.getHeaders().get( - Constants.BUNDLE_SYMBOLICNAME); - String version = (String) bundle.getHeaders().get( - Constants.BUNDLE_VERSION); - delegate = LoggerFactory.getLogger(name + '.' + version); - } - - /* - * (non-Javadoc) - * - * @see org.osgi.service.log.LogService#log(int, java.lang.String) - */ - public void log(int level, String message) { - switch (level) { - case LOG_DEBUG: - delegate.debug(message); - break; - case LOG_ERROR: - delegate.error(message); - break; - case LOG_INFO: - delegate.info(message); - break; - case LOG_WARNING: - delegate.warn(message); - break; - default: - break; - } - - } - - /* - * (non-Javadoc) - * - * @see org.osgi.service.log.LogService#log(int, java.lang.String, - * java.lang.Throwable) - */ - public void log(int level, String message, Throwable exception) { - switch (level) { - case LOG_DEBUG: - delegate.debug(message, exception); - break; - case LOG_ERROR: - delegate.error(message, exception); - break; - case LOG_INFO: - delegate.info(message, exception); - break; - case LOG_WARNING: - delegate.warn(message, exception); - break; - default: - break; - } - } - - /* - * (non-Javadoc) - * - * @see org.osgi.service.log.LogService#log(org.osgi.framework.ServiceReference, - * int, java.lang.String) - */ - public void log(ServiceReference sr, int level, String message) { - - switch (level) { - case LOG_DEBUG: - if(delegate.isDebugEnabled()){ - delegate.debug(createMessage(sr, message)); - } - break; - case LOG_ERROR: - if(delegate.isErrorEnabled()){ - delegate.error(createMessage(sr, message)); - } - break; - case LOG_INFO: - if(delegate.isInfoEnabled()){ - delegate.info(createMessage(sr, message)); - } - break; - case LOG_WARNING: - if(delegate.isWarnEnabled()){ - delegate.warn(createMessage(sr, message)); - } - break; - default: - break; - } - } - - /** - * createMessage. - * - * @param sr - * @param message - * @return - */ - private String createMessage(ServiceReference sr, String message) { - StringBuffer output = new StringBuffer(); - if (sr != null) { - output.append('[').append(sr.toString()).append(']') - .append(message); - } else { - output.append(UNKNOWN).append(message); - } - return output.toString(); - } - - /* - * (non-Javadoc) - * - * @see org.osgi.service.log.LogService#log(org.osgi.framework.ServiceReference, - * int, java.lang.String, java.lang.Throwable) - */ - public void log(ServiceReference sr, int level, String message, - Throwable exception) { - - switch (level) { - case LOG_DEBUG: - if(delegate.isDebugEnabled()){ - delegate.debug(createMessage(sr, message), exception); - } - break; - case LOG_ERROR: - if(delegate.isErrorEnabled()){ - delegate.error(createMessage(sr, message), exception); - } - break; - case LOG_INFO: - if(delegate.isInfoEnabled()){ - delegate.info(createMessage(sr, message), exception); - } - break; - case LOG_WARNING: - if(delegate.isWarnEnabled()){ - delegate.warn(createMessage(sr, message), exception); - } - break; - default: - break; - } - } - -} diff --git a/trunk/pom.xml b/trunk/pom.xml deleted file mode 100644 index 306e2196c..000000000 --- a/trunk/pom.xml +++ /dev/null @@ -1,286 +0,0 @@ - - - - 4.0.0 - - org.slf4j - slf4j-parent - 1.5.1 - - pom - SLF4J - - http://www.slf4j.org - - - QOS.ch - http://www.qos.ch - - 2005 - - - - 1.4.3 - - - - slf4j-api - slf4j-simple - slf4j-nop - slf4j-jdk14 - slf4j-log4j12 - slf4j-jcl - jcl-over-slf4j - jcl104-over-slf4j - log4j-over-slf4j - jul-to-slf4j - slf4j-site - slf4j-migrator - - - - - junit - junit - 3.8.1 - test - - - - - - - - - ${project.groupId} - slf4j-api - ${project.version} - - - - log4j - log4j - 1.2.14 - - - - - - - - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.3 - 1.3 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - once - plain - false - - **/AllTest.java - **/PackageTest.java - - - - - - org.apache.maven.plugins - maven-source-plugin - - - package - - jar - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - true - org.slf4j.migrator:org.slf4j.migrator.* - - - http://java.sun.com/j2se/1.5.0/docs/api - - - - - SLF4J packages - org.slf4j:org.slf4j.* - - - Jakarta Commons Logging packages - org.apache.commons.* - - - - Apache log4j - org.apache.log4j - - - - java.util.logging (JUL) to SLF4J bridge - org.slf4j.bridge - - - - - - - - - - - - - skipTests - - true - - - - osgi - - osgi-over-slf4j - slf4j-osgi-test-bundle - slf4j-osgi-integration-test - - - - - m2apache.snapshots - http://people.apache.org/repo/m2-snapshot-repository - - false - - - true - - - - - springframework.org - Springframework Maven SNAPSHOT Repository - http://static.springframework.org/maven2-snapshots/ - - true - - - - - - - - apache.snapshots - Apache Snapshot Plugin Repository - http://people.apache.org/repo/m2-snapshot-repository - - false - - - true - - - - - - - - - - apache.snapshots - Apache Snapshot Plugin Repository - http://people.apache.org/repo/m2-snapshot-repository - - false - - - true - - - - - - - - org.apache.maven.plugins - maven-site-plugin - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - - - - - - - maven-assembly-plugin - 2.1 - - - - src/main/assembly/source.xml - - - slf4j-${project.version} - false - target/site/dist/ - - - - - org.apache.maven.plugins - maven-jxr-plugin - - true - target/site/api/ - true - - - - - - - - - scm:svn:http://svn.slf4j.org/repos/slf4j/trunk - scm:svn:https://svn.slf4j.org/repos/slf4j/trunk - http://svn.slf4j.org/viewvc/slf4j/trunk/ - - - - - pixie - scp://pixie/var/www/www.slf4j.org/htdocs/ - - - - pixie - scp://pixie/var/mvnrepo/ - - - - - \ No newline at end of file diff --git a/trunk/slf4j-api/LICENSE.txt b/trunk/slf4j-api/LICENSE.txt deleted file mode 100644 index f6e2f31f7..000000000 --- a/trunk/slf4j-api/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2004-2007 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - diff --git a/trunk/slf4j-api/pom.xml b/trunk/slf4j-api/pom.xml deleted file mode 100644 index 863214bfa..000000000 --- a/trunk/slf4j-api/pom.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-api - jar - SLF4J API Module - - http://www.slf4j.org - The slf4j API - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - once - plain - false - - **/AllTest.java - **/PackageTest.java - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.version} - ${project.description} - ${project.version} - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - bundle-test-jar - package - - jar - test-jar - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - process-classes - - run - - - - - - Removing slf4j-api's dummy StaticLoggerBinder and StaticMarkerBinder - - - - - - - - - - - - - org.codehaus.mojo - clirr-maven-plugin - - 1.5.0 - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/ILoggerFactory.java b/trunk/slf4j-api/src/main/java/org/slf4j/ILoggerFactory.java deleted file mode 100644 index 26e7a554d..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/ILoggerFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j; - - -/** - * ILoggerFactory instances manufacture {@link Logger} - * instances by name. - * - *

Most users retrieve {@link Logger} instances through the static - * {@link LoggerFactory#getLogger(String)} method. An instance of of this - * interface is bound internally with {@link LoggerFactory} class at - * compile time. - * - * @author Ceki Gülcü - */ -public interface ILoggerFactory { - - /** - * Return an appropriate {@link Logger} instance as specified by the - * name parameter. - * - *

If the name parameter is equal to {@link Logger#ROOT_LOGGER_NAME}, that is - * the string value "ROOT" (case insensitive), then the root logger of the - * underlying logging system is returned. - * - *

Null-valued name arguments are considered invalid. - * - *

Certain extremely simple logging systems, e.g. NOP, may always - * return the same logger instance regardless of the requested name. - * - * @param name the name of the Logger to return - */ - public Logger getLogger(String name); -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/IMarkerFactory.java b/trunk/slf4j-api/src/main/java/org/slf4j/IMarkerFactory.java deleted file mode 100644 index 34e413d39..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/IMarkerFactory.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j; - - -/** - * Implementaitons of this interface are used to manufacture {@link Marker} - * instances. - * - *

See the section Implementing - * the SLF4J API in the FAQ for details on how to make your logging - * system conform to SLF4J. - * - * @author Ceki Gülcü - */ -public interface IMarkerFactory { - - /** - * Manufacture a {@link Marker} instance by name. If the instance has been - * created earlier, return the previously created instance. - * - *

Null name values are not allowed. - * - * @param name the name of the marker to be created, null value is - * not allowed. - * - * @return a Marker instance - */ - Marker getMarker(String name); - - /** - * Checks if the marker with the name already exists. If name is null, then false - * is returned. - * - * @return true id the marker exists, false otherwise. - */ - boolean exists(String name); - - /** - * Detach an existing marker. - *

- * Note that after a marker is detached, there might still be "dangling" references - * to the detached marker. - * - * - * @param name The name of the marker to detach - * @return whether the marker could be detached or not - */ - boolean detachMarker(String name); - - - /** - * Create a marker which is detached (even at birth) from this IMarkerFactory. - * - * @return a dangling marker - * @since 1.5.1 - */ - Marker getDetachedMarker(String name); -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/Logger.java b/trunk/slf4j-api/src/main/java/org/slf4j/Logger.java deleted file mode 100644 index e2e99a516..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/Logger.java +++ /dev/null @@ -1,721 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -package org.slf4j; - -/** - * The org.slf4j.Logger interface is the main user entry point of SLF4J API. - * It is expected that logging takes place through concrete implementations - * of this interface. - * - *

Typical usage pattern:

- *
- * import org.slf4j.Logger;
- * import org.slf4j.LoggerFactory;
- * 
- * public class Wombat {
- *
- *   final static Logger logger = LoggerFactory.getLogger(Wombat.class);
- *   Integer t;
- *   Integer oldT;
- *
- *   public void setTemperature(Integer temperature) {
- *     oldT = t;        
- *     t = temperature;
- *     logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);
- *     if(temperature.intValue() > 50) {
- *       logger.info("Temperature has risen above 50 degrees.");
- *     }
- *   }
- * }
- 
- - - - * @author Ceki Gülcü - */ -public interface Logger { - - - /** - * Case insensitive String constant used to retrieve the name of the root logger. - * @since 1.3 - */ - final public String ROOT_LOGGER_NAME = "ROOT"; - - /** - * Return the name of this Logger instance. - */ - public String getName(); - - /** - * Is the logger instance enabled for the TRACE level? - * @return True if this Logger is enabled for the TRACE level, - * false otherwise. - * - * @since 1.4 - */ - public boolean isTraceEnabled(); - - - /** - * Log a message at the TRACE level. - * - * @param msg the message string to be logged - * @since 1.4 - */ - public void trace(String msg); - - - /** - * Log a message at the TRACE level according to the specified format - * and argument. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the TRACE level.

- * - * @param format the format string - * @param arg the argument - * - * @since 1.4 - */ - public void trace(String format, Object arg); - - - - /** - * Log a message at the TRACE level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the TRACE level.

- * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - * - * @since 1.4 - */ - public void trace(String format, Object arg1, Object arg2); - - /** - * Log a message at the TRACE level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the TRACE level.

- * - * @param format the format string - * @param argArray an array of arguments - * - * @since 1.4 - */ - public void trace(String format, Object[] argArray); - - /** - * Log an exception (throwable) at the TRACE level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - * - * @since 1.4 - */ - public void trace(String msg, Throwable t); - - - /** - * Similar to {@link #isTraceEnabled()} method except that the - * marker data is also taken into account. - * - * @param marker The marker data to take into consideration - * - * @since 1.4 - */ - public boolean isTraceEnabled(Marker marker); - - /** - * Log a message with the specific Marker at the TRACE level. - * - * @param marker the marker data specific to this log statement - * @param msg the message string to be logged - * - * @since 1.4 - */ - public void trace(Marker marker, String msg); - - /** - * This method is similar to {@link #trace(String, Object)} method except that the - * marker data is also taken into consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg the argument - * - * @since 1.4 - */ - public void trace(Marker marker, String format, Object arg); - - - /** - * This method is similar to {@link #trace(String, Object, Object)} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - * - * @since 1.4 - */ - public void trace(Marker marker, String format, Object arg1, Object arg2); - - /** - * This method is similar to {@link #trace(String, Object[])} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param argArray an array of arguments - * - * @since 1.4 - */ - public void trace(Marker marker, String format, Object[] argArray); - - - /** - * This method is similar to {@link #trace(String, Throwable)} method except that the - * marker data is also taken into consideration. - * - * @param marker the marker data specific to this log statement - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - * - * @since 1.4 - */ - public void trace(Marker marker, String msg, Throwable t); - - - /** - * Is the logger instance enabled for the DEBUG level? - * @return True if this Logger is enabled for the DEBUG level, - * false otherwise. - * - */ - public boolean isDebugEnabled(); - - - /** - * Log a message at the DEBUG level. - * - * @param msg the message string to be logged - */ - public void debug(String msg); - - - /** - * Log a message at the DEBUG level according to the specified format - * and argument. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the DEBUG level.

- * - * @param format the format string - * @param arg the argument - */ - public void debug(String format, Object arg); - - - - /** - * Log a message at the DEBUG level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the DEBUG level.

- * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - public void debug(String format, Object arg1, Object arg2); - - /** - * Log a message at the DEBUG level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the DEBUG level.

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void debug(String format, Object[] argArray); - - /** - * Log an exception (throwable) at the DEBUG level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - public void debug(String msg, Throwable t); - - - /** - * Similar to {@link #isDebugEnabled()} method except that the - * marker data is also taken into account. - * - * @param marker The marker data to take into consideration - */ - public boolean isDebugEnabled(Marker marker); - - /** - * Log a message with the specific Marker at the DEBUG level. - * - * @param marker the marker data specific to this log statement - * @param msg the message string to be logged - */ - public void debug(Marker marker, String msg); - - /** - * This method is similar to {@link #debug(String, Object)} method except that the - * marker data is also taken into consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg the argument - */ - public void debug(Marker marker, String format, Object arg); - - - /** - * This method is similar to {@link #debug(String, Object, Object)} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - public void debug(Marker marker, String format, Object arg1, Object arg2); - - /** - * This method is similar to {@link #debug(String, Object[])} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param argArray an array of arguments - */ - public void debug(Marker marker, String format, Object[] argArray); - - - /** - * This method is similar to {@link #debug(String, Throwable)} method except that the - * marker data is also taken into consideration. - * - * @param marker the marker data specific to this log statement - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - public void debug(Marker marker, String msg, Throwable t); - - - /** - * Is the logger instance enabled for the INFO level? - * @return True if this Logger is enabled for the INFO level, - * false otherwise. - */ - public boolean isInfoEnabled(); - - - /** - * Log a message at the INFO level. - * - * @param msg the message string to be logged - */ - public void info(String msg); - - - /** - * Log a message at the INFO level according to the specified format - * and argument. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the INFO level.

- * - * @param format the format string - * @param arg the argument - */ - public void info(String format, Object arg); - - - /** - * Log a message at the INFO level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the INFO level.

- * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - public void info(String format, Object arg1, Object arg2); - - /** - * Log a message at the INFO level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the INFO level.

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void info(String format, Object[] argArray); - - /** - * Log an exception (throwable) at the INFO level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - public void info(String msg, Throwable t); - - /** - * Similar to {@link #isInfoEnabled()} method except that the marker - * data is also taken into consideration. - * - * @param marker The marker data to take into consideration - */ - public boolean isInfoEnabled(Marker marker); - - /** - * Log a message with the specific Marker at the INFO level. - * - * @param marker The marker specific to this log statement - * @param msg the message string to be logged - */ - public void info(Marker marker, String msg); - - /** - * This method is similar to {@link #info(String, Object)} method except that the - * marker data is also taken into consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg the argument - */ - public void info(Marker marker, String format, Object arg); - - /** - * This method is similar to {@link #info(String, Object, Object)} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - public void info(Marker marker, String format, Object arg1, Object arg2); - - - /** - * This method is similar to {@link #info(String, Object[])} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param argArray an array of arguments - */ - public void info(Marker marker, String format, Object[] argArray); - - - /** - * This method is similar to {@link #info(String, Throwable)} method - * except that the marker data is also taken into consideration. - * - * @param marker the marker data for this log statement - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - public void info(Marker marker, String msg, Throwable t); - - - /** - * Is the logger instance enabled for the WARN level? - * @return True if this Logger is enabled for the WARN level, - * false otherwise. - */ - public boolean isWarnEnabled(); - - /** - * Log a message at the WARN level. - * - * @param msg the message string to be logged - */ - public void warn(String msg); - - /** - * Log a message at the WARN level according to the specified format - * and argument. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the WARN level.

- * - * @param format the format string - * @param arg the argument - */ - public void warn(String format, Object arg); - - - /** - * Log a message at the WARN level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the WARN level.

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void warn(String format, Object[] argArray); - - /** - * Log a message at the WARN level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the WARN level.

- * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - public void warn(String format, Object arg1, Object arg2); - - /** - * Log an exception (throwable) at the WARN level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - public void warn(String msg, Throwable t); - - - /** - * Similar to {@link #isWarnEnabled()} method except that the marker - * data is also taken into consideration. - * - * @param marker The marker data to take into consideration - */ - public boolean isWarnEnabled(Marker marker); - - /** - * Log a message with the specific Marker at the WARN level. - * - * @param marker The marker specific to this log statement - * @param msg the message string to be logged - */ - public void warn(Marker marker, String msg); - - /** - * This method is similar to {@link #warn(String, Object)} method except that the - * marker data is also taken into consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg the argument - */ - public void warn(Marker marker, String format, Object arg); - - /** - * This method is similar to {@link #warn(String, Object, Object)} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - public void warn(Marker marker, String format, Object arg1, Object arg2); - - /** - * This method is similar to {@link #warn(String, Object[])} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param argArray an array of arguments - */ - public void warn(Marker marker, String format, Object[] argArray); - - - /** - * This method is similar to {@link #warn(String, Throwable)} method - * except that the marker data is also taken into consideration. - * - * @param marker the marker data for this log statement - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - public void warn(Marker marker, String msg, Throwable t); - - - /** - * Is the logger instance enabled for the ERROR level? - * @return True if this Logger is enabled for the ERROR level, - * false otherwise. - */ - public boolean isErrorEnabled(); - - /** - * Log a message at the ERROR level. - * - * @param msg the message string to be logged - */ - public void error(String msg); - - /** - * Log a message at the ERROR level according to the specified format - * and argument. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the ERROR level.

- * - * @param format the format string - * @param arg the argument - */ - public void error(String format, Object arg); - - /** - * Log a message at the ERROR level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the ERROR level.

- * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - public void error(String format, Object arg1, Object arg2); - - /** - * Log a message at the ERROR level according to the specified format - * and arguments. - * - *

This form avoids superfluous object creation when the logger - * is disabled for the ERROR level.

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void error(String format, Object[] argArray); - - /** - * Log an exception (throwable) at the ERROR level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - public void error(String msg, Throwable t); - - - /** - * Similar to {@link #isErrorEnabled()} method except that the - * marker data is also taken into consideration. - * - * @param marker The marker data to take into consideration - */ - public boolean isErrorEnabled(Marker marker); - - /** - * Log a message with the specific Marker at the ERROR level. - * - * @param marker The marker specific to this log statement - * @param msg the message string to be logged - */ - public void error(Marker marker, String msg); - - /** - * This method is similar to {@link #error(String, Object)} method except that the - * marker data is also taken into consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg the argument - */ - public void error(Marker marker, String format, Object arg); - - /** - * This method is similar to {@link #error(String, Object, Object)} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - public void error(Marker marker, String format, Object arg1, Object arg2); - - /** - * This method is similar to {@link #error(String, Object[])} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param format the format string - * @param argArray an array of arguments - */ - public void error(Marker marker, String format, Object[] argArray); - - - /** - * This method is similar to {@link #error(String, Throwable)} - * method except that the marker data is also taken into - * consideration. - * - * @param marker the marker data specific to this log statement - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - public void error(Marker marker, String msg, Throwable t); - -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java b/trunk/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java deleted file mode 100644 index 5cf709645..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j; - -import org.slf4j.helpers.Util; -import org.slf4j.impl.StaticLoggerBinder; - -/** - * The LoggerFactory is a utility class producing Loggers for - * various logging APIs, most notably for log4j, logback and JDK 1.4 logging. - * Other implementations such as {@link org.slf4j.impl.NOPLogger NOPLogger} and - * {@link org.slf4j.impl.SimpleLogger SimpleLogger} are also supported. - * - *

- * LoggerFactory is essentially a wrapper around an - * {@link ILoggerFactory} instance bound with LoggerFactory at - * compile time. - * - *

- * Please note that all methods in LoggerFactory are static. - * - * @author Ceki Gülcü - */ -public final class LoggerFactory { - - static ILoggerFactory loggerFactory; - - static final String NO_STATICLOGGERBINDER_URL = "http://www.slf4j.org/codes.html#StaticLoggerBinder"; - static final String NULL_LF_URL = "http://www.slf4j.org/codes.html#null_LF"; - - // private constructor prevents instantiation - private LoggerFactory() { - } - - - static { - try { - loggerFactory = StaticLoggerBinder.SINGLETON.getLoggerFactory(); - } catch(NoClassDefFoundError ncde) { - String msg = ncde.getMessage(); - if(msg != null && msg.indexOf("org/slf4j/impl/StaticLoggerBinder") != -1) { - Util.reportFailure("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\"."); - Util.reportFailure("See "+NO_STATICLOGGERBINDER_URL+" for further details."); - - } - throw ncde; - } catch (Exception e) { - // we should never get here - Util.reportFailure("Failed to instantiate logger [" - + StaticLoggerBinder.SINGLETON.getLoggerFactoryClassStr() + "]", e); - } - } - - /** - * Return a logger named according to the name parameter using the statically - * bound {@link ILoggerFactory} instance. - * - * @param name - * The name of the logger. - * @return logger - */ - public static Logger getLogger(String name) { - if(loggerFactory == null) { - throw new IllegalStateException("Logging factory implementation cannot be null. See also "+NULL_LF_URL); - } - return loggerFactory.getLogger(name); - } - - /** - * Return a logger named corresponding to the class passed as parameter, using - * the statically bound {@link ILoggerFactory} instance. - * - * @param clazz - * the returned logger will be named after clazz - * @return logger - */ - public static Logger getLogger(Class clazz) { - if(loggerFactory == null) { - throw new IllegalStateException("Logging factory implementation cannot be null. See also "+NULL_LF_URL); - } - return loggerFactory.getLogger(clazz.getName()); - } - - /** - * Return the {@link ILoggerFactory} instance in use. - * - *

ILoggerFactory instance is bound with this class at compile - * time. - * - * @return the ILoggerFactory instance in use - */ - public static ILoggerFactory getILoggerFactory() { - return loggerFactory; - } -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/MDC.java b/trunk/slf4j-api/src/main/java/org/slf4j/MDC.java deleted file mode 100644 index f24a908fd..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/MDC.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j; - -import java.util.Map; - -import org.slf4j.helpers.BasicMDCAdapter; -import org.slf4j.helpers.Util; -import org.slf4j.impl.StaticMDCBinder; -import org.slf4j.spi.MDCAdapter; - -/** - * This class hides and serves as a substitute for the underlying logging - * system's MDC implementation. - * - *

- * If the underlying logging system offers MDC functionality, then SLF4J's MDC, - * i.e. this class, will delegate to the underlying system's MDC. Note that at - * this time, only two logging systems, namely log4j and logback, offer MDC - * functionality. If the underlying system does not support MDC, e.g. java.util.logging, - * then SLF4J will use a {@link BasicMDCAdapter}. - * - *

- * Thus, as a SLF4J user, you can take advantage of MDC in the presence of log4j - * logback, or java.util.logging, but without forcing these systems as dependencies - * upon your users. - * - *

- * For more information on MDC please see the chapter on MDC in the - * logback manual. - * - *

- * Please note that all methods in this class are static. - * - * @author Ceki Gülcü - * @since 1.4.1 - */ -public class MDC { - - static final String NULL_MDCA_URL = "http://www.slf4j.org/codes.html#null_MDCA"; - static final String NO_STATIC_MDC_BINDER_URL = "http://www.slf4j.org/codes.html#no_static_mdc_binder"; - static MDCAdapter mdcAdapter; - - private MDC() { - } - - static { - try { - mdcAdapter = StaticMDCBinder.SINGLETON.getMDCA(); - } catch (NoClassDefFoundError ncde) { - String msg = ncde.getMessage(); - if (msg != null && msg.indexOf("org/slf4j/impl/StaticMDCBinder") != -1) { - Util - .reportFailure("Failed to load class \"org.slf4j.impl.StaticMDCBinder\"."); - Util.reportFailure("See " + NO_STATIC_MDC_BINDER_URL - + " for further details."); - - } - throw ncde; - } catch (Exception e) { - // we should never get here - Util.reportFailure("Could not bind with an instance of class [" - + StaticMDCBinder.SINGLETON.getMDCAdapterClassStr() + "]", e); - } - } - - /** - * Put a context value (the val parameter) as identified with - * the key parameter into the current thread's context map. - * The key parameter cannot be null. The code>val parameter - * can be null only if the underlying implementation supports it. - * - *

- * This method delegates all work to the MDC of the underlying logging system. - * - * @throws IllegalArgumentException in case the "key" parameter is null - */ - public static void put(String key, String val) throws IllegalArgumentException { - if (key == null) { - throw new IllegalArgumentException("key parameter cannot be null"); - } - if (mdcAdapter == null) { - throw new IllegalStateException("MDCAdapter cannot be null. See also " - + NULL_MDCA_URL); - } - mdcAdapter.put(key, val); - } - - /** - * Get the context identified by the key parameter. The - * key parameter cannot be null. - * - *

This method delegates all work to the MDC of the underlying logging system. - * - * @return the string value identified by the key parameter. - * @throws IllegalArgumentException in case the "key" parameter is null - */ - public static String get(String key) throws IllegalArgumentException { - if (key == null) { - throw new IllegalArgumentException("key parameter cannot be null"); - } - - if (mdcAdapter == null) { - throw new IllegalStateException("MDCAdapter cannot be null. See also " - + NULL_MDCA_URL); - } - return mdcAdapter.get(key); - } - - /** - * Remove the the context identified by the key parameter using - * the underlying system's MDC implementation. The key parameter - * cannot be null. This method does nothing if there is no previous value - * associated with key. - * - * @throws IllegalArgumentException in case the "key" parameter is null - */ - public static void remove(String key) throws IllegalArgumentException { - if (key == null) { - throw new IllegalArgumentException("key parameter cannot be null"); - } - - if (mdcAdapter == null) { - throw new IllegalStateException("MDCAdapter cannot be null. See also " - + NULL_MDCA_URL); - } - mdcAdapter.remove(key); - } - - /** - * Clear all entries in the MDC of the underlying implementation. - */ - public static void clear() { - if (mdcAdapter == null) { - throw new IllegalStateException("MDCAdapter cannot be null. See also " - + NULL_MDCA_URL); - } - mdcAdapter.clear(); - } - - /** - * Return a copy of the current thread's context map, with keys and - * values of type String. Returned value may be null. - * - * @return A copy of the current thread's context map. May be null. - * @since 1.5.1 - */ - public static Map getCopyOfContextMap() { - if (mdcAdapter == null) { - throw new IllegalStateException("MDCAdapter cannot be null. See also " - + NULL_MDCA_URL); - } - return mdcAdapter.getCopyOfContextMap(); - } - - /** - * Set the current thread's context map by first clearing any existing - * map and then copying the map passed as parameter. The context map passed - * as parameter must only contain keys and values of type String. - * - * @param contextMap must contain only keys and values of type String - * @since 1.5.1 - */ - public static void setContextMap(Map contextMap) { - if (mdcAdapter == null) { - throw new IllegalStateException("MDCAdapter cannot be null. See also " - + NULL_MDCA_URL); - } - mdcAdapter.setContextMap(contextMap); - } - - - /** - * Returns the MDCAdapter instance currently in use. - * - * @return the MDcAdapter instance currently in use. - * @since 1.4.2 - */ - public static MDCAdapter getMDCAdapter() { - return mdcAdapter; - } - - -} \ No newline at end of file diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/Marker.java b/trunk/slf4j-api/src/main/java/org/slf4j/Marker.java deleted file mode 100644 index 07bfb4e73..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/Marker.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j; - -import java.io.Serializable; -import java.util.Iterator; - -/** - * Markers are named objects used to enrich log statements. Conforming logging - * system Implementations of SLF4J determine how information conveyed by markers - * are used, if at all. In particular, many conforming logging systems ignore - * marker data. - * - *

- * Markers can contain child markers, which in turn can contain children of - * their own. - * - * @author Ceki Gülcü - */ -public interface Marker extends Serializable { - - /** - * This constant represents any marker, including a null marker. - */ - public final String ANY_MARKER = "*"; - - /** - * This constant represents any non-null marker. - */ - public final String ANY_NON_NULL_MARKER = "+"; - - /** - * Get the name of this Marker. - * - * @return name of marker - */ - public String getName(); - - /** - * Add a child Marker to this Marker. - * - * @param child - * a child marker - */ - public void add(Marker child); - - /** - * Remove a child Marker. - * - * @param child - * the child Marker to remove - * @return true if child could be found and removed, false otherwise. - */ - public boolean remove(Marker child); - - /** - * Does this marker have children? - * - * @return true if this marker has children, false otherwise. - */ - public boolean hasChildren(); - - /** - * Returns an Iterator which can be used to iterate over the children of this - * marker. An empty iterator is returned when this marker has no children. - * - * @return Iterator over the children of this marker - */ - public Iterator iterator(); - - /** - * Does this marker contain the 'other' marker? Marker A is defined to contain - * marker B, if A == B or if B is a child of A. - * - * @param other - * The marker to test for inclusion. - * @throws IllegalArgumentException - * if 'other' is null - * @return Whether this marker contains the other marker. - */ - public boolean contains(Marker other); - - /** - * Does this marker contain the marker named 'name'? - * - * If 'name' is null the returned value is always false. - * - * @param other - * The marker to test for inclusion. - * @return Whether this marker contains the other marker. - */ - public boolean contains(String name); - - /** - * Markers are considered equal if they have the same name. - * - * @param o - * @return true, if this.name equals o.name - * - * @since 1.5.1 - */ - public boolean equals(Object o); - - /** - * Compute the hash code based on the name of this marker. - * Note that markers are considered equal if they have the same name. - * - * @return the computed hashCode - * @since 1.5.1 - */ - public int hashCode(); - -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/MarkerFactory.java b/trunk/slf4j-api/src/main/java/org/slf4j/MarkerFactory.java deleted file mode 100644 index 42bb8753b..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/MarkerFactory.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j; - -import org.slf4j.helpers.Util; -import org.slf4j.impl.StaticMarkerBinder; - -/** - * MarkerFactory is a utility class producing {@link Marker} instances as - * appropriate for the logging system currently in use. - * - *

- * This class is essentially implemented as a wrapper around an - * {@link IMarkerFactory} instance bound at compile time. - * - *

- * Please note that all methods in this class are static. - * - * @author Ceki Gülcü - */ -public class MarkerFactory { - static IMarkerFactory markerFactory; - - private MarkerFactory() { - } - - static { - try { - markerFactory = StaticMarkerBinder.SINGLETON.getMarkerFactory(); - } catch (Exception e) { - // we should never get here - Util.reportFailure("Could not instantiate instance of class [" - + StaticMarkerBinder.SINGLETON.getMarkerFactoryClassStr() + "]", e); - } - } - - /** - * Return a Marker instance as specified by the name parameter using the - * previously bound {@link IMarkerFactory}instance. - * - * @param name - * The name of the {@link Marker} object to return. - * @return marker - */ - public static Marker getMarker(String name) { - return markerFactory.getMarker(name); - } - - /** - * Create a marker which is detached (even at birth) from the MarkerFactory. - * - * @return a dangling marker - * @since 1.5.1 - */ - public static Marker getDetachedMarker(String name) { - return markerFactory.getDetachedMarker(name); - } - - /** - * Return the {@link IMarkerFactory}instance in use. - * - *

The IMarkerFactory instance is usually bound with this class at - * compile time. - * - * @return the IMarkerFactory instance in use - */ - public static IMarkerFactory getIMarkerFactory() { - return markerFactory; - } -} \ No newline at end of file diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMDCAdapter.java b/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMDCAdapter.java deleted file mode 100644 index 6601a7603..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMDCAdapter.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package org.slf4j.helpers; - -import org.slf4j.spi.MDCAdapter; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Basic MDC implementation, which can be used with logging systems that lack - * out-of-the-box MDC support. - * - * This code is largely based on logback's - * LogbackMDCAdapter. - * - * @author Ceki Gulcu - * @author Maarten Bosteels - * - * @since 1.5.0 - */ -public class BasicMDCAdapter implements MDCAdapter { - - private InheritableThreadLocal inheritableThreadLocal = new InheritableThreadLocal(); - - /** - * Put a context value (the val parameter) as identified with - * the key parameter into the current thread's context map. - * Note that contrary to log4j, the val parameter can be null. - * - *

- * If the current thread does not have a context map it is created as a side - * effect of this call. - * - * @throws IllegalArgumentException - * in case the "key" parameter is null - */ - public void put(String key, String val) { - if (key == null) { - throw new IllegalArgumentException("key cannot be null"); - } - HashMap map = (HashMap) inheritableThreadLocal.get(); - if (map == null) { - map = new HashMap(); - inheritableThreadLocal.set(map); - } - map.put(key, val); - } - - /** - * Get the context identified by the key parameter. - */ - public String get(String key) { - HashMap hashMap = (HashMap) inheritableThreadLocal.get(); - if ((hashMap != null) && (key != null)) { - return (String) hashMap.get(key); - } else { - return null; - } - } - - /** - * Remove the the context identified by the key parameter. - */ - public void remove(String key) { - HashMap map = (HashMap) inheritableThreadLocal.get(); - if (map != null) { - map.remove(key); - } - } - - /** - * Clear all entries in the MDC. - */ - public void clear() { - HashMap hashMap = (HashMap) inheritableThreadLocal.get(); - if (hashMap != null) { - hashMap.clear(); - inheritableThreadLocal.remove(); - } - } - - /** - * Returns the keys in the MDC as a {@link Set} of {@link String}s The - * returned value can be null. - * - * @return the keys in the MDC - */ - public Set getKeys() { - HashMap hashMap = (HashMap) inheritableThreadLocal.get(); - if (hashMap != null) { - return hashMap.keySet(); - } else { - return null; - } - } - /** - * Return a copy of the current thread's context map. - * Returned value may be null. - * - */ - public Map getCopyOfContextMap() { - HashMap hashMap = (HashMap) inheritableThreadLocal.get(); - if (hashMap != null) { - return new HashMap(hashMap); - } else { - return null; - } - } - - public void setContextMap(Map contextMap) { - HashMap hashMap = (HashMap) inheritableThreadLocal.get(); - if (hashMap != null) { - hashMap.clear(); - hashMap.putAll(contextMap); - } else { - hashMap = new HashMap(contextMap); - inheritableThreadLocal.set(hashMap); - } - } - -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java b/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java deleted file mode 100644 index 0abf0721e..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarker.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.helpers; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.slf4j.Marker; - -/** - * An almost trivial implementation of the {@link Marker} interface. - * - *

- * BasicMarker lets users specify marker information. However, it - * does not offer any useful operations on that information. - * - *

- * Simple logging systems which ignore marker data, just return instances of - * this class in order to conform to the SLF4J API. - * - * @author Ceki Gülcü - * @author Joern Huxhorn - */ -public class BasicMarker implements Marker { - - private static final long serialVersionUID = 1803952589649545191L; - - private final String name; - private List children; - - BasicMarker(String name) { - if (name == null) { - throw new IllegalArgumentException("A merker name cannot be null"); - } - this.name = name; - } - - public String getName() { - return name; - } - - public synchronized void add(Marker markerToAddAsChild) { - if (markerToAddAsChild == null) { - throw new IllegalArgumentException( - "A null value cannot be added to a Marker as child."); - } - - // no point in adding the child multiple times - if (this.contains(markerToAddAsChild)) { - return; - - } else if (markerToAddAsChild.contains(this)) { // avoid recursion - // a potential child should not its future parent as a child - return; - } else { - // let's add the child - if (children == null) { - children = new Vector(); - } - children.add(markerToAddAsChild); - } - - } - - public synchronized boolean hasChildren() { - return ((children != null) && (children.size() > 0)); - } - - public synchronized Iterator iterator() { - if (children != null) { - return children.iterator(); - } else { - return Collections.EMPTY_LIST.iterator(); - } - } - - public synchronized boolean remove(Marker markerToRemove) { - if (children == null) { - return false; - } - - int size = children.size(); - for (int i = 0; i < size; i++) { - Marker m = (Marker) children.get(i); - if (m == markerToRemove) { - children.remove(i); - return true; - } - } - // could not find markerToRemove - return false; - } - - public boolean contains(Marker other) { - if (other == null) { - throw new IllegalArgumentException("Other cannot be null"); - } - - if (this == other) { - return true; - } - - if (hasChildren()) { - for (int i = 0; i < children.size(); i++) { - Marker child = (Marker) children.get(i); - if (child.contains(other)) { - return true; - } - } - } - return false; - } - - /** - * This method is mainly used with Expression Evaluators. - */ - public boolean contains(String name) { - if (name == null) { - throw new IllegalArgumentException("Other cannot be null"); - } - - if (this.name.equals(name)) { - return true; - } - - if (hasChildren()) { - for (int i = 0; i < children.size(); i++) { - Marker child = (Marker) children.get(i); - if (child.contains(name)) { - return true; - } - } - } - return false; - } - - private static String OPEN = "[ "; - private static String CLOSE = " ]"; - private static String SEP = ", "; - - - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof Marker)) - return false; - - final Marker other = (Marker) obj; - return name.equals(other.getName()); - } - - public int hashCode() { - return name.hashCode(); - } - - public String toString() { - if (!this.hasChildren()) { - return this.getName(); - } - Iterator it = this.iterator(); - Marker child; - StringBuffer sb = new StringBuffer(this.getName()); - sb.append(' ').append(OPEN); - while (it.hasNext()) { - child = (Marker) it.next(); - sb.append(child.getName()); - if (it.hasNext()) { - sb.append(SEP); - } - } - sb.append(CLOSE); - - return sb.toString(); - } -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarkerFactory.java b/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarkerFactory.java deleted file mode 100644 index 1f5be23f1..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/BasicMarkerFactory.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.helpers; - -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.IMarkerFactory; -import org.slf4j.Marker; - -/** - * An almost trivial implementation of the {@link IMarkerFactory} - * interface which creates {@link BasicMarker} instances. - * - *

Simple logging systems can conform to the SLF4J API by binding - * {@link org.slf4j.MarkerFactory} with an instance of this class. - * - * @author Ceki Gülcü - */ -public class BasicMarkerFactory implements IMarkerFactory { - - Map markerMap = new HashMap(); - - /** - * Regular users should not create - * BasicMarkerFactory instances. Marker - * instances can be obtained using the static {@link - * org.slf4j.MarkerFactory#getMarker} method. - */ - public BasicMarkerFactory() { - } - - /** - * Manufacture a {@link BasicMarker} instance by name. If the instance has been - * created earlier, return the previously created instance. - * - * @param name the name of the marker to be created - * @return a Marker instance - */ - public synchronized Marker getMarker(String name) { - if (name == null) { - throw new IllegalArgumentException("Marker name cannot be null"); - } - - Marker marker = (Marker) markerMap.get(name); - if (marker == null) { - marker = new BasicMarker(name); - markerMap.put(name, marker); - } - return marker; - } - - /** - * Does the name marked already exist? - */ - public synchronized boolean exists(String name) { - if (name == null) { - return false; - } - return markerMap.containsKey(name); - } - - public boolean detachMarker(String name) { - if(name == null) { - return false; - } - return (markerMap.remove(name) != null); - } - - - public Marker getDetachedMarker(String name) { - return new BasicMarker(name); - } - - - -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MarkerIgnoringBase.java b/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MarkerIgnoringBase.java deleted file mode 100644 index 52fd723b5..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MarkerIgnoringBase.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.helpers; - -import org.slf4j.Logger; -import org.slf4j.Marker; - - -/** - * This class serves as base for adapters or native implementations of logging systems - * lacking Marker support. In this implementation, methods taking marker data - * simply invoke the corresponding method without the Marker argument, discarding - * any marker data passed as argument. - * - * @author Ceki Gulcu - */ -public abstract class MarkerIgnoringBase implements Logger { - - public boolean isTraceEnabled(Marker marker) { - return isTraceEnabled(); - } - - public void trace(Marker marker, String msg) { - trace(msg); - } - - public void trace(Marker marker, String format, Object arg) { - trace(format, arg); - } - - public void trace(Marker marker, String format, Object arg1, Object arg2) { - trace(format, arg1, arg2); - } - - public void trace(Marker marker, String format, Object[] argArray) { - trace(format, argArray); - } - - public void trace(Marker marker, String msg, Throwable t) { - trace(msg, t); - } - - public boolean isDebugEnabled(Marker marker) { - return isDebugEnabled(); - } - - public void debug(Marker marker, String msg) { - debug(msg); - } - - public void debug(Marker marker, String format, Object arg) { - debug(format, arg); - } - - public void debug(Marker marker, String format, Object arg1, Object arg2) { - debug(format, arg1, arg2); - } - - public void debug(Marker marker, String format, Object[] argArray) { - debug(format, argArray); - } - - public void debug(Marker marker, String msg, Throwable t) { - debug(msg, t); - } - - public boolean isInfoEnabled(Marker marker) { - return isInfoEnabled(); - } - - public void info(Marker marker, String msg) { - info(msg); - } - - public void info(Marker marker, String format, Object arg) { - info(format, arg); - } - - public void info(Marker marker, String format, Object arg1, Object arg2) { - info(format, arg1, arg2); - } - - public void info(Marker marker, String format, Object[] argArray) { - info(format, argArray); - } - - public void info(Marker marker, String msg, Throwable t) { - info(msg, t); - } - - public boolean isWarnEnabled(Marker marker) { - return isWarnEnabled(); - } - - public void warn(Marker marker, String msg) { - warn(msg); - } - - public void warn(Marker marker, String format, Object arg) { - warn(format, arg); - } - - public void warn(Marker marker, String format, Object arg1, Object arg2) { - warn(format, arg1, arg2); - } - - public void warn(Marker marker, String format, Object[] argArray) { - warn(format, argArray); - } - - public void warn(Marker marker, String msg, Throwable t) { - warn(msg, t); - } - - - public boolean isErrorEnabled(Marker marker) { - return isErrorEnabled(); - } - - public void error(Marker marker, String msg) { - error(msg); - } - - public void error(Marker marker, String format, Object arg) { - error(format, arg); - } - - public void error(Marker marker, String format, Object arg1, Object arg2) { - error(format, arg1, arg2); - } - - public void error(Marker marker, String format, Object[] argArray) { - error(format, argArray); - } - - public void error(Marker marker, String msg, Throwable t) { - error(msg, t); - } - - public String toString() { - return this.getClass().getName()+"("+getName()+")"; - } -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java b/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java deleted file mode 100644 index 92699d7d2..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.helpers; - -/** - * Formats messages according to very simple substitution rules. Substitutions - * can be made 1, 2 or more arguments. - *

- * For example, - *

MessageFormatter.format("Hi {}.", "there");
- * will return the string "Hi there.". - *

- * The {} pair is called the formatting anchor. It serves to - * designate the location where arguments need to be substituted within the - * message pattern. - *

- * In the rare case where you need to place the '{' or '}' in the message - * pattern itself but do not want them to be interpreted as a formatting - * anchors, you can espace the '{' character with '\', that is the backslash - * character. Only the '{' character should be escaped. There is no need to - * escape the '}' character. For example, - *

MessageFormatter.format("Set \\{1,2,3} is not equal to {}.", "1,2");
- * will return the string "Set {1,2,3} is not equal to 1,2.". - * - *

- * The escaping behaviour just described can be overridden by - * escaping the escape character '\'. Calling - *

MessageFormatter.format("File name is C:\\\\{}.", "file.zip");
- * will return the string "File name is C:\file.zip". - * - *

- * See {@link #format(String, Object)}, {@link #format(String, Object, Object)} - * and {@link #arrayFormat(String, Object[])} methods for more details. - * - * @author Ceki Gülcü - */ -public class MessageFormatter { - static final char DELIM_START = '{'; - static final char DELIM_STOP = '}'; - private static final char ESCAPE_CHAR = '\\'; - - /** - * Performs single argument substitution for the 'messagePattern' passed as - * parameter. - *

- * For example, - * - *

-   * MessageFormatter.format("Hi {}.", "there");
-   * 
- * - * will return the string "Hi there.". - *

- * - * @param messagePattern - * The message pattern which will be parsed and formatted - * @param argument - * The argument to be substituted in place of the formatting anchor - * @return The formatted message - */ - public static String format(String messagePattern, Object arg) { - return arrayFormat(messagePattern, new Object[] { arg }); - } - - /** - * - * Performs a two argument substitution for the 'messagePattern' passed as - * parameter. - *

- * For example, - * - *

-   * MessageFormatter.format("Hi {}. My name is {}.", "Alice", "Bob");
-   * 
- * - * will return the string "Hi Alice. My name is Bob.". - * - * @param messagePattern - * The message pattern which will be parsed and formatted - * @param arg1 - * The argument to be substituted in place of the first formatting - * anchor - * @param arg2 - * The argument to be substituted in place of the second formatting - * anchor - * @return The formatted message - */ - public static String format(String messagePattern, Object arg1, Object arg2) { - return arrayFormat(messagePattern, new Object[] { arg1, arg2 }); - } - - /** - * Same principle as the {@link #format(String, Object)} and - * {@link #format(String, Object, Object)} methods except that any number of - * arguments can be passed in an array. - * - * @param messagePattern - * The message pattern which will be parsed and formatted - * @param argArray - * An array of arguments to be substituted in place of formatting - * anchors - * @return The formatted message - */ - public static String arrayFormat(String messagePattern, Object[] argArray) { - if (messagePattern == null) { - return null; - } - int i = 0; - int len = messagePattern.length(); - int j = messagePattern.indexOf(DELIM_START); - - if(argArray == null) { - return messagePattern; - } - - StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50); - - for (int L = 0; L < argArray.length; L++) { - - j = messagePattern.indexOf(DELIM_START, i); - - if (j == -1 || (j + 1 == len)) { - // no more variables - if (i == 0) { // this is a simple string - return messagePattern; - } else { // add the tail string which contains no variables and return - // the result. - sbuf.append(messagePattern.substring(i, messagePattern.length())); - return sbuf.toString(); - } - } else { - char delimStop = messagePattern.charAt(j + 1); - - if (isEscapedDelimeter(messagePattern, j)) { - if(!isDoubleEscaped(messagePattern, j)) { - L--; // DELIM_START was escaped, thus should not be incremented - sbuf.append(messagePattern.substring(i, j - 1)); - sbuf.append(DELIM_START); - i = j + 1; - } else { - // The escape character preceding the delemiter start is - // itself escaped: "abc x:\\{}" - // we have to consume one backward slash - sbuf.append(messagePattern.substring(i, j-1)); - sbuf.append(argArray[L]); - i = j + 2; - } - } else if ((delimStop != DELIM_STOP)) { - // invalid DELIM_START/DELIM_STOP pair - sbuf.append(messagePattern.substring(i, messagePattern.length())); - return sbuf.toString(); - } else { - // normal case - sbuf.append(messagePattern.substring(i, j)); - sbuf.append(argArray[L]); - i = j + 2; - } - } - } - // append the characters following the last {} pair. - sbuf.append(messagePattern.substring(i, messagePattern.length())); - return sbuf.toString(); - } - - static boolean isEscapedDelimeter(String messagePattern, - int delimeterStartIndex) { - - if (delimeterStartIndex == 0) { - return false; - } - char potentialEscape = messagePattern.charAt(delimeterStartIndex - 1); - if (potentialEscape == ESCAPE_CHAR) { - return true; - } else { - return false; - } - } - - static boolean isDoubleEscaped(String messagePattern, int delimeterStartIndex) { - if (delimeterStartIndex >= 2 - && messagePattern.charAt(delimeterStartIndex - 2) == ESCAPE_CHAR) { - return true; - } else { - return false; - } - } -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/NOPMakerAdapter.java b/trunk/slf4j-api/src/main/java/org/slf4j/helpers/NOPMakerAdapter.java deleted file mode 100644 index 5ed9aa2eb..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/NOPMakerAdapter.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.slf4j.helpers; - -import java.util.Map; - -import org.slf4j.spi.MDCAdapter; - -/** - * This adapter is an empty implementation of the {@link MDCAdapter} interface. - * It is used for all logging systems which do not support mapped - * diagnostic contexts such as JDK14, simple and NOP. - * - * @author Ceki Gülcü - * - * @since 1.4.1 - */ -public class NOPMakerAdapter implements MDCAdapter { - - public void clear() { - } - - public String get(String key) { - return null; - } - - public void put(String key, String val) { - } - - public void remove(String key) { - } - - public Map getCopyOfContextMap() { - return null; - } - - public void setContextMap(Map contextMap) { - // NOP - } - -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/Util.java b/trunk/slf4j-api/src/main/java/org/slf4j/helpers/Util.java deleted file mode 100644 index d91f11240..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/Util.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.helpers; - - -/** - * - * An internal utility class. - * - * @author Ceki Gülcü - */ -public class Util { - - static final public void reportFailure(String msg, Throwable t) { - System.err.println(msg); - System.err.println("Reported exception:"); - t.printStackTrace(); - } - - static final public void reportFailure(String msg) { - System.err.println("SLF4J: " +msg); - } -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/package.html b/trunk/slf4j-api/src/main/java/org/slf4j/helpers/package.html deleted file mode 100644 index 9d7c8c383..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/helpers/package.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - -

Helper classes.

- -
- - diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java deleted file mode 100644 index 71ebdf4dc..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.impl; - -import org.slf4j.ILoggerFactory; - -/** - * The binding of {@link LoggerFactory} class with an actual instance of - * {@link ILoggerFactory} is performed using information returned by this class. - * - * This class is meant to provide a dummy StaticLoggerBinder to the slf4j-api module. - * Real implementations are found in each SLF4J binding project, e.g. slf4j-nop, - * slf4j-log4j12 etc. - * - * @author Ceki Gülcü - */ -public class StaticLoggerBinder { - - /** - * The unique instance of this class. - */ - public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - - private StaticLoggerBinder() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } - - public ILoggerFactory getLoggerFactory() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } - - public String getLoggerFactoryClassStr() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMDCBinder.java deleted file mode 100644 index 81f2a8c27..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMDCBinder.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.slf4j.impl; - -import org.slf4j.spi.MDCAdapter; - - -/** - * This class is only a stub. Real implementations are found in - * each SLF4J binding project, e.g. slf4j-nop, slf4j-log4j12 etc. - * - * @author Ceki Gülcü - */ -public class StaticMDCBinder { - - - /** - * The unique instance of this class. - */ - public static final StaticMDCBinder SINGLETON = new StaticMDCBinder(); - - private StaticMDCBinder() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } - - /** - * Currently this method always returns an instance of - * {@link StaticMDCBinder}. - */ - public MDCAdapter getMDCA() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } - - public String getMDCAdapterClassStr() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java deleted file mode 100644 index efdd6bd63..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.impl; - -import org.slf4j.IMarkerFactory; -import org.slf4j.MarkerFactory; -import org.slf4j.helpers.BasicMarkerFactory; -import org.slf4j.spi.MarkerFactoryBinder; - -/** - * - * The binding of {@link MarkerFactory} class with an actual instance of - * {@link IMarkerFactory} is performed using information returned by this class. - * - * This class is meant to provide a *dummy* StaticMarkerBinder to the slf4j-api module. - * Real implementations are found in each SLF4J binding project, e.g. slf4j-nop, - * slf4j-simple, slf4j-log4j12 etc. - * - * @author Ceki Gülcü - */ -public class StaticMarkerBinder implements MarkerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder(); - - private StaticMarkerBinder() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } - - /** - * Currently this method always returns an instance of - * {@link BasicMarkerFactory}. - */ - public IMarkerFactory getMarkerFactory() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } - - /** - * Currently, this method returns the class name of - * {@link BasicMarkerFactory}. - */ - public String getMarkerFactoryClassStr() { - throw new UnsupportedOperationException("This code should never make it into the jar"); - } - - -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/impl/package.html b/trunk/slf4j-api/src/main/java/org/slf4j/impl/package.html deleted file mode 100644 index f4311e30e..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/impl/package.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - -

Implementations of core logging interfaces defined in the {@link - org.slf4j} package.

- -
- - diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/package.html b/trunk/slf4j-api/src/main/java/org/slf4j/package.html deleted file mode 100644 index 4f407d07e..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/package.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - -

Core logging interfaces.

- -
- - diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/spi/LocationAwareLogger.java b/trunk/slf4j-api/src/main/java/org/slf4j/spi/LocationAwareLogger.java deleted file mode 100644 index 58e13e2b2..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/spi/LocationAwareLogger.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.spi; - -import org.slf4j.Logger; -import org.slf4j.Marker; - -/** - * An optional interface helping integration with logging systems capable of - * extracting location information. This interface is mainly used by SLF4J bridges - * such as jcl104-over-slf4j which need to provide hints so that the underlying logging - * system can extract the correct locatin information (method name, line number, etc.). - * - * - * @author Ceki Gulcu - * @since 1.3 - */ -public interface LocationAwareLogger extends Logger { - - final public int TRACE_INT = 00; - final public int DEBUG_INT = 10; - final public int INFO_INT = 20; - final public int WARN_INT = 30; - final public int ERROR_INT = 40; - - - /** - * Printing method which support for location information. - * - * @param marker - * @param fqcn The fully qualified class name of the caller - * @param level - * @param message - * @param t - */ - public void log(Marker marker, String fqcn, int level, String message, Throwable t); - -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/spi/LoggerFactoryBinder.java b/trunk/slf4j-api/src/main/java/org/slf4j/spi/LoggerFactoryBinder.java deleted file mode 100644 index 9abedc528..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/spi/LoggerFactoryBinder.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.spi; - -import org.slf4j.ILoggerFactory; - -/** - * An internal interface which helps the static {@link org.slf4j.LoggerFactory} - * class bind with the appropriate {@link ILoggerFactory} instance. - * - * @author Ceki Gülcü - */ -public interface LoggerFactoryBinder { - - /** - * Return the instance of {@link ILoggerFactory} that - * {@link org.slf4j.LoggerFactory} class should bind to. - * - * @return the instance of {@link ILoggerFactory} that - * {@link org.slf4j.LoggerFactory} class should bind to. - */ - public ILoggerFactory getLoggerFactory(); - - /** - * The String form of the {@link ILoggerFactory} object that this - * LoggerFactoryBinder instance is intended to return. - * - *

This method allows the developer to intterogate this binder's intention - * which may be different from the {@link ILoggerFactory} instance it is able to - * yield in practice. The discrepency should only occur in case of errors. - * - * @return the class name of the intended {@link ILoggerFactory} instance - */ - public String getLoggerFactoryClassStr(); -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/spi/MDCAdapter.java b/trunk/slf4j-api/src/main/java/org/slf4j/spi/MDCAdapter.java deleted file mode 100644 index bc9bbb760..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/spi/MDCAdapter.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.spi; - -import java.util.Map; - -/** - * This interface abstracts the service offered by various MDC - * implementations. - * - * @author Ceki Gülcü - * @since 1.4.1 - */ -public interface MDCAdapter { - - /** - * Put a context value (the val parameter) as identified with - * the key parameter into the current thread's context map. - * The key parameter cannot be null. The code>val parameter - * can be null only if the underlying implementation supports it. - * - *

If the current thread does not have a context map it is created as a side - * effect of this call. - */ - public void put(String key, String val); - - /** - * Get the context identified by the key parameter. - * The key parameter cannot be null. - * - * @return the string value identified by the key parameter. - */ - public String get(String key); - - /** - * Remove the the context identified by the key parameter. - * The key parameter cannot be null. - * - *

- * This method does nothing if there is no previous value - * associated with key. - */ - public void remove(String key); - - /** - * Clear all entries in the MDC. - */ - public void clear(); - - /** - * Return a copy of the current thread's context map, with keys and - * values of type String. Returned value may be null. - * - * @return A copy of the current thread's context map. May be null. - * @since 1.5.1 - */ - public Map getCopyOfContextMap(); - - /** - * Set the current thread's context map by first clearing any existing - * map and then copying the map passed as parameter. The context map - * parameter must only contain keys and values of type String. - * - * @param contextMap must contain only keys and values of type String - * - * @since 1.5.1 - */ - public void setContextMap(Map contextMap); -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/spi/MarkerFactoryBinder.java b/trunk/slf4j-api/src/main/java/org/slf4j/spi/MarkerFactoryBinder.java deleted file mode 100644 index fc01d178e..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/spi/MarkerFactoryBinder.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.spi; - -import org.slf4j.IMarkerFactory; - - -/** - * An internal interface which helps the static {@link org.slf4j.MarkerFactory} - * class bind with the appropriate {@link IMarkerFactory} instance. - * - * @author Ceki Gülcü - */ -public interface MarkerFactoryBinder { - - /** - * Return the instance of {@link IMarkerFactory} that - * {@link org.slf4j.MarkerFactory} class should bind to. - * - * @return the instance of {@link IMarkerFactory} that - * {@link org.slf4j.MarkerFactory} class should bind to. - */ - public IMarkerFactory getMarkerFactory(); - - /** - * The String form of the {@link IMarkerFactory} object that this - * MarkerFactoryBinder instance is intended to return. - * - *

This method allows the developer to intterogate this binder's intention - * which may be different from the {@link IMarkerFactory} instance it is able to - * return. Such a discrepency should only occur in case of errors. - * - * @return the class name of the intended {@link IMarkerFactory} instance - */ - public String getMarkerFactoryClassStr(); -} diff --git a/trunk/slf4j-api/src/main/java/org/slf4j/spi/package.html b/trunk/slf4j-api/src/main/java/org/slf4j/spi/package.html deleted file mode 100644 index 242f19d55..000000000 --- a/trunk/slf4j-api/src/main/java/org/slf4j/spi/package.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - -Classes and interfaces which are internal to SLF4J. Under most -circumstances SLF4J users should be oblivious even to the existence of -this package. - \ No newline at end of file diff --git a/trunk/slf4j-api/src/main/resources/META-INF/MANIFEST.MF b/trunk/slf4j-api/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 8c6fdd146..000000000 --- a/trunk/slf4j-api/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,8 +0,0 @@ -Implementation-Title: slf4j-api -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: slf4j.api -Bundle-Name: slf4j-api -Bundle-Vendor: SLF4J.ORG -Bundle-RequiredExecutionEnvironment: J2SE-1.3 -Export-Package: org.slf4j;version=${project.version}, org.slf4j.spi;version=${project.version}, org.slf4j.helpers;version=${project.version} -Import-Package: org.slf4j.impl;version=${project.version} diff --git a/trunk/slf4j-api/src/test/java/org/slf4j/BasicMarkerTest.java b/trunk/slf4j-api/src/test/java/org/slf4j/BasicMarkerTest.java deleted file mode 100644 index 380b35e3f..000000000 --- a/trunk/slf4j-api/src/test/java/org/slf4j/BasicMarkerTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j; - -import java.util.Iterator; - -import junit.framework.TestCase; - -import org.slf4j.helpers.BasicMarkerFactory; - -/** - * Unit test BasicMarker - * - * @author Ceki Gülcü - * @author Joern Huxhorn - */ -public class BasicMarkerTest extends TestCase { - static final String BLUE_STR = "BLUE"; - static final String RED_STR = "RED"; - static final String GREEN_STR = "GREEN"; - static final String COMP_STR = "COMP"; - static final String MULTI_COMP_STR = "MULTI_COMP"; - static final String PARENT_MARKER_STR = "PARENT_MARKER"; - static final String CHILD_MARKER_STR = "CHILD_MARKER"; - static final String NOT_CONTAINED_MARKER_STR = "NOT_CONTAINED"; - - final IMarkerFactory factory; - final Marker blue; - final Marker red; - final Marker green; - final Marker comp; - final Marker multiComp; - - short diff = Differentiator.getDiffentiator(); - - public BasicMarkerTest() { - factory = new BasicMarkerFactory(); - - blue = factory.getMarker(BLUE_STR); - red = factory.getMarker(RED_STR); - green = factory.getMarker(GREEN_STR); - comp = factory.getMarker(COMP_STR); - comp.add(blue); - - multiComp = factory.getMarker(MULTI_COMP_STR); - multiComp.add(green); - multiComp.add(comp); - } - - public void testPrimitive() { - assertEquals(BLUE_STR, blue.getName()); - assertTrue(blue.contains(blue)); - - Marker blue2 = factory.getMarker(BLUE_STR); - assertEquals(BLUE_STR, blue2.getName()); - assertEquals(blue, blue2); - assertTrue(blue.contains(blue2)); - assertTrue(blue2.contains(blue)); - } - - public void testPrimitiveByName() { - assertTrue(blue.contains(BLUE_STR)); - } - - public void testComposite() { - assertTrue(comp.contains(comp)); - assertTrue(comp.contains(blue)); - } - - public void testCompositeByName() { - assertTrue(comp.contains(COMP_STR)); - assertTrue(comp.contains(BLUE_STR)); - } - - public void testMultiComposite() { - assertTrue(multiComp.contains(comp)); - assertTrue(multiComp.contains(blue)); - assertTrue(multiComp.contains(green)); - assertFalse(multiComp.contains(red)); - } - - public void testMultiCompositeByName() { - assertTrue(multiComp.contains(COMP_STR)); - assertTrue(multiComp.contains(BLUE_STR)); - assertTrue(multiComp.contains(GREEN_STR)); - assertFalse(multiComp.contains(RED_STR)); - } - - public void testMultiAdd() { - Marker parent = factory.getMarker(PARENT_MARKER_STR); - Marker child = factory.getMarker(CHILD_MARKER_STR); - for (int i = 0; i < 10; i++) { - parent.add(child); - } - - // check that the child was added once and only once - Iterator iterator = parent.iterator(); - assertTrue(iterator.hasNext()); - assertEquals(CHILD_MARKER_STR, iterator.next().toString()); - assertFalse(iterator.hasNext()); - } - - public void testAddRemove() { - final String NEW_PREFIX = "NEW_"; - Marker parent = factory.getMarker(NEW_PREFIX + PARENT_MARKER_STR); - Marker child = factory.getMarker(NEW_PREFIX + CHILD_MARKER_STR); - assertFalse(parent.contains(child)); - assertFalse(parent.contains(NEW_PREFIX + CHILD_MARKER_STR)); - assertFalse(parent.remove(child)); - - parent.add(child); - - assertTrue(parent.contains(child)); - assertTrue(parent.contains(NEW_PREFIX + CHILD_MARKER_STR)); - - assertTrue(parent.remove(child)); - - assertFalse(parent.contains(child)); - assertFalse(parent.contains(NEW_PREFIX + CHILD_MARKER_STR)); - assertFalse(parent.remove(child)); - } - - public void testSelfRecursion() { - final String diffPrefix = "NEW_"+diff; - final String PARENT_NAME = diffPrefix + PARENT_MARKER_STR; - final String NOT_CONTAINED_NAME = diffPrefix + NOT_CONTAINED_MARKER_STR; - Marker parent = factory.getMarker(PARENT_NAME); - Marker notContained = factory.getMarker(NOT_CONTAINED_NAME); - parent.add(parent); - assertTrue(parent.contains(parent)); - assertTrue(parent.contains(PARENT_NAME)); - assertFalse(parent.contains(notContained)); - assertFalse(parent.contains(NOT_CONTAINED_MARKER_STR)); - } - - public void testIndirectRecursion() { - final String diffPrefix = "NEW_"+diff; - final String PARENT_NAME=diffPrefix+PARENT_MARKER_STR; - final String CHILD_NAME=diffPrefix+CHILD_MARKER_STR; - final String NOT_CONTAINED_NAME=diffPrefix+NOT_CONTAINED_MARKER_STR; - - Marker parent = factory.getMarker(PARENT_NAME); - Marker child = factory.getMarker(CHILD_NAME); - Marker notContained = factory.getMarker(NOT_CONTAINED_NAME); - - parent.add(child); - child.add(parent); - assertTrue(parent.contains(parent)); - assertTrue(parent.contains(child)); - assertTrue(parent.contains(PARENT_NAME)); - assertTrue(parent.contains(CHILD_NAME)); - assertFalse(parent.contains(notContained)); - assertFalse(parent.contains(NOT_CONTAINED_MARKER_STR)); - } - -} diff --git a/trunk/slf4j-api/src/test/java/org/slf4j/Differentiator.java b/trunk/slf4j-api/src/test/java/org/slf4j/Differentiator.java deleted file mode 100644 index b77952670..000000000 --- a/trunk/slf4j-api/src/test/java/org/slf4j/Differentiator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -package org.slf4j; - -import java.util.Random; - -public class Differentiator { - - static Random random = new Random(System.currentTimeMillis()); - - static public short getDiffentiator() { - return (short) random.nextInt(Short.MAX_VALUE); - } -} diff --git a/trunk/slf4j-api/src/test/java/org/slf4j/NoBindingTest.java b/trunk/slf4j-api/src/test/java/org/slf4j/NoBindingTest.java deleted file mode 100644 index b51f88337..000000000 --- a/trunk/slf4j-api/src/test/java/org/slf4j/NoBindingTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.slf4j; - -import junit.framework.TestCase; - -public class NoBindingTest extends TestCase { - - public void testLogger() { - try { - Logger logger = LoggerFactory.getLogger(NoBindingTest.class); - logger.debug("hello"); - fail("slf4j-api does not ship with a binding"); - } catch (NoClassDefFoundError e) { - - } - } - - public void testMDC() { - try { - MDC.put("k", "v"); - fail("slf4j-api does not ship with a binding"); - } catch (NoClassDefFoundError e) { - - } - } -} diff --git a/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterTest.java b/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterTest.java deleted file mode 100644 index f1f205be1..000000000 --- a/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.CH - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.helpers; - -import org.slf4j.helpers.MessageFormatter; - -import junit.framework.TestCase; - - -/** - * @author Ceki Gulcu - * - */ -public class MessageFormatterTest extends TestCase { - - Integer i1 = new Integer(1); - Integer i2 = new Integer(2); - Integer i3 = new Integer(3); - - public void testNull() { - String result; - result = MessageFormatter.format(null, i1); - assertEquals(null, result); - } - - public void testNullParam() { - String result; - - result = MessageFormatter.format("Value is {}.", null); - assertEquals("Value is null.", result); - - result = MessageFormatter.format("Val1 is {}, val2 is {}.", null, null); - assertEquals("Val1 is null, val2 is null.", result); - - result = MessageFormatter.format("Val1 is {}, val2 is {}.", i1, null); - assertEquals("Val1 is 1, val2 is null.", result); - - result = MessageFormatter.format("Val1 is {}, val2 is {}.", null, i2); - assertEquals("Val1 is null, val2 is 2.", result); - - result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}", new Integer[]{null, null, null}); - assertEquals("Val1 is null, val2 is null, val3 is null", result); - - result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}", new Integer[]{null, i2, i3}); - assertEquals("Val1 is null, val2 is 2, val3 is 3", result); - - result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}", new Integer[]{null, null, i3}); - assertEquals("Val1 is null, val2 is null, val3 is 3", result); - } - - - public void testOneParameter() { - String result; - - result = MessageFormatter.format("Value is {}.", i3); - assertEquals("Value is 3.", result); - - result = MessageFormatter.format("Value is {", i3); - assertEquals("Value is {", result); - - result = MessageFormatter.format("{} is larger than 2.", i3); - assertEquals("3 is larger than 2.", result); - - result = MessageFormatter.format("No subst", i3); - assertEquals("No subst", result); - - result = MessageFormatter.format("Incorrect {subst", i3); - assertEquals("Incorrect {subst", result); - - result = MessageFormatter.format("Value is \\{bla} {}", i3); - assertEquals("Value is {bla} 3", result); - - result = MessageFormatter.format("Escaped \\{} subst", i3); - assertEquals("Escaped {} subst", result); - - result = MessageFormatter.format("\\{Escaped", i3); - assertEquals("{Escaped", result); - - result = MessageFormatter.format("\\{}Escaped", i3); - assertEquals("{}Escaped", result); - - result = MessageFormatter.format("File name is \\{{}}.", "App folder.zip"); - assertEquals("File name is {App folder.zip}.", result); - - // escaping the escape character - result = MessageFormatter.format("File name is C:\\\\{}.", "App folder.zip"); - assertEquals("File name is C:\\App folder.zip.", result); - } - - public void testTwoParameters() { - String result; - - - result = MessageFormatter.format("Value {} is smaller than {}.", i1, i2); - assertEquals("Value 1 is smaller than 2.", result); - - result = MessageFormatter.format("Value {} is smaller than {}", i1, i2); - assertEquals("Value 1 is smaller than 2", result); - - result = MessageFormatter.format("{}{}", i1, i2); - assertEquals("12", result); - - result = MessageFormatter.format("Val1={}, Val2={", i1, i2); - assertEquals("Val1=1, Val2={", result); - - result = MessageFormatter.format("Value {} is smaller than \\{}", i1, i2); - assertEquals("Value 1 is smaller than {}", result); - - result = MessageFormatter.format("Value {} is smaller than \\{} tail", i1, i2); - assertEquals("Value 1 is smaller than {} tail", result); - - result = MessageFormatter.format("Value {} is smaller than \\{", i1, i2); - assertEquals("Value 1 is smaller than \\{", result); - - result = MessageFormatter.format("Value {} is smaller than \\{tail", i1, i2); - assertEquals("Value 1 is smaller than {tail", result); - - - result = MessageFormatter.format("Value \\{} is smaller than {}", i1, i2); - assertEquals("Value {} is smaller than 1", result); - } - - public void testNullArray() { - String result; - - String msg0 = "msg0"; - String msg1 = "msg1 {}"; - String msg2 = "msg2 {} {}"; - String msg3 = "msg3 {} {} {}"; - - Object[] args = null; - - result = MessageFormatter.arrayFormat(msg0, args); - assertEquals(msg0, result); - - result = MessageFormatter.arrayFormat(msg1, args); - assertEquals(msg1, result); - - result = MessageFormatter.arrayFormat(msg2, args); - assertEquals(msg2, result); - - result = MessageFormatter.arrayFormat(msg3, args); - assertEquals(msg3, result); - } - public void testArray() { - String result; - - Integer[] ia = new Integer[] {i1, i2, i3}; - - result = MessageFormatter.arrayFormat("Value {} is smaller than {} and {}.", ia); - assertEquals("Value 1 is smaller than 2 and 3.", result); - - result = MessageFormatter.arrayFormat("{}{}{}", ia); - assertEquals("123", result); - - result = MessageFormatter.arrayFormat("Value {} is smaller than {}.", ia); - assertEquals("Value 1 is smaller than 2.", result); - - result = MessageFormatter.arrayFormat("Value {} is smaller than {}", ia); - assertEquals("Value 1 is smaller than 2", result); - - result = MessageFormatter.arrayFormat("Val={}, {, Val={}", ia); - assertEquals("Val=1, {, Val={}", result); - - result = MessageFormatter.arrayFormat("Val={}, \\{, Val={}", ia); - assertEquals("Val=1, {, Val=2", result); - - - result = MessageFormatter.arrayFormat("Val1={}, Val2={", ia); - assertEquals("Val1=1, Val2={", result); - - - } - -} diff --git a/trunk/slf4j-jcl/LICENSE.txt b/trunk/slf4j-jcl/LICENSE.txt deleted file mode 100644 index f6e2f31f7..000000000 --- a/trunk/slf4j-jcl/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2004-2007 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - diff --git a/trunk/slf4j-jcl/pom.xml b/trunk/slf4j-jcl/pom.xml deleted file mode 100644 index 70f1059a8..000000000 --- a/trunk/slf4j-jcl/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-jcl - jar - SLF4J JCL Binding - - http://www.slf4j.org - - - The slf4j jcl binding - - - - - org.slf4j - slf4j-api - - - - commons-logging - commons-logging - 1.1.1 - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.version} - ${project.description} - ${project.version} - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerAdapter.java b/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerAdapter.java deleted file mode 100644 index 5dfd15da1..000000000 --- a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerAdapter.java +++ /dev/null @@ -1,538 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -package org.slf4j.impl; - -import org.apache.commons.logging.Log; -import org.slf4j.Logger; -import org.slf4j.helpers.MarkerIgnoringBase; -import org.slf4j.helpers.MessageFormatter; - -/** - * A wrapper over {@link org.apache.commons.logging.Log - * org.apache.commons.logging.Log} in conformance with the {@link Logger} - * interface. - * - * @author Ceki Gülcü - */ -public final class JCLLoggerAdapter extends MarkerIgnoringBase { - final Log log; - final String name; - - // WARN: JCLLoggerAdapter constructor should have only package access so - // that only JCLLoggerFactory be able to create one. - JCLLoggerAdapter(Log log, String name) { - this.log = log; - this.name = name; - } - - public String getName() { - return name; - } - - /** - * Delegates to the {@link Log#isTraceEnabled} method of the underlying - * {@link Log} instance. - */ - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - // - - /** - * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - * @param msg - the message object to be logged - */ - public void trace(String msg) { - log.trace(msg); - } - - /** - * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level TRACE. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void trace(String format, Object arg) { - if (log.isDebugEnabled()) { - String msgStr = MessageFormatter.format(format, arg); - log.trace(msgStr); - } - } - - /** - * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level TRACE. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void trace(String format, Object arg1, Object arg2) { - if (log.isDebugEnabled()) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log.trace(msgStr); - } - } - - - /** - * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level TRACE. - *

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void trace(String format, Object[] argArray) { - if (log.isDebugEnabled()) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log.trace(msgStr); - } - } - - /** - * Delegates to the {@link Log#trace(java.lang.Object, java.lang.Throwable)} method of - * the underlying {@link Log} instance. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void trace(String msg, Throwable t) { - log.trace(msg, t); - } - - - /** - * Delegates to the {@link Log#isDebugEnabled} method of the underlying - * {@link Log} instance. - */ - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - // - - /** - * Delegates to the {@link Log#debug(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - * @param msg - the message object to be logged - */ - public void debug(String msg) { - log.debug(msg); - } - - /** - * Delegates to the {@link Log#debug(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level DEBUG. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void debug(String format, Object arg) { - if (log.isDebugEnabled()) { - String msgStr = MessageFormatter.format(format, arg); - log.debug(msgStr); - } - } - - /** - * Delegates to the {@link Log#debug(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level DEBUG. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void debug(String format, Object arg1, Object arg2) { - if (log.isDebugEnabled()) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log.debug(msgStr); - } - } - - - /** - * Delegates to the {@link Log#debug(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level DEBUG. - *

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void debug(String format, Object[] argArray) { - if (log.isDebugEnabled()) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log.debug(msgStr); - } - } - - /** - * Delegates to the {@link Log#debug(java.lang.Object, java.lang.Throwable)} method of - * the underlying {@link Log} instance. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void debug(String msg, Throwable t) { - log.debug(msg, t); - } - - /** - * Delegates to the {@link Log#isInfoEnabled} method of the underlying - * {@link Log} instance. - */ - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - /** - * Delegates to the {@link Log#debug(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - * @param msg - the message object to be logged - */ - public void info(String msg) { - log.info(msg); - } - - /** - * Delegates to the {@link Log#info(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level INFO. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - - public void info(String format, Object arg) { - if (log.isInfoEnabled()) { - String msgStr = MessageFormatter.format(format, arg); - log.info(msgStr); - } - } - /** - * Delegates to the {@link Log#info(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level INFO. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void info(String format, Object arg1, Object arg2) { - if (log.isInfoEnabled()) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log.info(msgStr); - } - } - - /** - * Delegates to the {@link Log#info(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level INFO. - *

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void info(String format, Object[] argArray) { - if (log.isInfoEnabled()) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log.info(msgStr); - } - } - - - /** - * Delegates to the {@link Log#info(java.lang.Object, java.lang.Throwable)} method of - * the underlying {@link Log} instance. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void info(String msg, Throwable t) { - log.info(msg, t); - } - - /** - * Delegates to the {@link Log#isWarnEnabled} method of the underlying - * {@link Log} instance. - */ - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - /** - * Delegates to the {@link Log#warn(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - * @param msg - the message object to be logged - */ - public void warn(String msg) { - log.warn(msg); - } - - /** - * Delegates to the {@link Log#warn(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level WARN. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void warn(String format, Object arg) { - if (log.isWarnEnabled()) { - String msgStr = MessageFormatter.format(format, arg); - log.warn(msgStr); - } - } - - /** - * Delegates to the {@link Log#warn(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level WARN. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void warn(String format, Object arg1, Object arg2) { - if (log.isWarnEnabled()) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log.warn(msgStr); - } - } - - /** - * Delegates to the {@link Log#warn(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level WARN. - *

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void warn(String format, Object[] argArray) { - if (log.isWarnEnabled()) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log.warn(msgStr); - } - } - - - /** - * Delegates to the {@link Log#warn(java.lang.Object, java.lang.Throwable)} method of - * the underlying {@link Log} instance. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - - public void warn(String msg, Throwable t) { - log.warn(msg, t); - } - - - /** - * Delegates to the {@link Log#isErrorEnabled} method of the underlying - * {@link Log} instance. - */ - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - /** - * Delegates to the {@link Log#error(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - * @param msg - the message object to be logged - */ - public void error(String msg) { - log.error(msg); - } - - /** - * Delegates to the {@link Log#error(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level ERROR. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void error(String format, Object arg) { - if (log.isErrorEnabled()) { - String msgStr = MessageFormatter.format(format, arg); - log.error(msgStr); - } - } - - /** - * Delegates to the {@link Log#error(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level ERROR. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void error(String format, Object arg1, Object arg2) { - if (log.isErrorEnabled()) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log.error(msgStr); - } - } - - /** - * Delegates to the {@link Log#error(java.lang.Object)} method of the underlying - * {@link Log} instance. - * - *

- * However, this form avoids superfluous object creation when the logger is disabled - * for level ERROR. - *

- * - * @param format the format string - * @param argArray an array of arguments - */ - public void error(String format, Object[] argArray) { - if (log.isErrorEnabled()) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log.error(msgStr); - } - } - - - /** - * Delegates to the {@link Log#error(java.lang.Object, java.lang.Throwable)} method of - * the underlying {@link Log} instance. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - - public void error(String msg, Throwable t) { - log.error(msg, t); - } - -} diff --git a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerFactory.java b/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerFactory.java deleted file mode 100644 index e955b53da..000000000 --- a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerFactory.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.logging.LogFactory; -import org.slf4j.ILoggerFactory; -import org.slf4j.Logger; - -/** - * JCLLoggerFactory is an implementation of {@link ILoggerFactory} returning the - * appropriately named {@link JCLLoggerAdapter} instance. - * - * @author Ceki Gülcü - */ -public class JCLLoggerFactory implements ILoggerFactory { - - // key: name (String), value: a JCLLoggerAdapter; - Map loggerMap; - - public JCLLoggerFactory() { - loggerMap = new HashMap(); - } - - /* - * (non-Javadoc) - * - * @see org.slf4j.ILoggerFactory#getLogger(java.lang.String) - */ - public Logger getLogger(String name) { - Logger logger = null; - // protect against concurrent access of loggerMap - synchronized (this) { - logger = (Logger) loggerMap.get(name); - if (logger == null) { - org.apache.commons.logging.Log jclLogger = LogFactory.getLog(name); - logger = new JCLLoggerAdapter(jclLogger, name); - loggerMap.put(name, logger); - } - } - return logger; - } -} diff --git a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java deleted file mode 100644 index f6fdef0fd..000000000 --- a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.ILoggerFactory; -import org.slf4j.LoggerFactory; -import org.slf4j.spi.LoggerFactoryBinder; - -/** - * The binding of {@link LoggerFactory} class with an actual instance of - * {@link ILoggerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticLoggerBinder implements LoggerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - - // Binding specific code: - private static final String loggerFactoryClassStr = JCLLoggerFactory.class.getName(); - - /** The ILoggerFactory instance returned by the {@link #getLoggerFactory} method - * should always be the same object - */ - private final ILoggerFactory loggerFactory; - - private StaticLoggerBinder() { - // Binding specific code: - loggerFactory = new JCLLoggerFactory(); - } - - public ILoggerFactory getLoggerFactory() { - return loggerFactory; - } - - public String getLoggerFactoryClassStr() { - return loggerFactoryClassStr; - } -} diff --git a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticMDCBinder.java deleted file mode 100644 index 62b9f8658..000000000 --- a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticMDCBinder.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.slf4j.impl; - -import org.slf4j.helpers.NOPMakerAdapter; -import org.slf4j.spi.MDCAdapter; - - -/** - * This implementation is bound to {@link NOPMakerAdapter}. - * - * @author Ceki Gülcü - */ -public class StaticMDCBinder { - - - /** - * The unique instance of this class. - */ - public static final StaticMDCBinder SINGLETON = new StaticMDCBinder(); - - private StaticMDCBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link StaticMDCBinder}. - */ - public MDCAdapter getMDCA() { - return new NOPMakerAdapter(); - } - - public String getMDCAdapterClassStr() { - return NOPMakerAdapter.class.getName(); - } -} diff --git a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java deleted file mode 100644 index b37c3640e..000000000 --- a/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.IMarkerFactory; -import org.slf4j.MarkerFactory; -import org.slf4j.helpers.BasicMarkerFactory; -import org.slf4j.spi.MarkerFactoryBinder; - -/** - * - * The binding of {@link MarkerFactory} class with an actual instance of - * {@link IMarkerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticMarkerBinder implements MarkerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder(); - - final IMarkerFactory markerFactory = new BasicMarkerFactory(); - - private StaticMarkerBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link BasicMarkerFactory}. - */ - public IMarkerFactory getMarkerFactory() { - return markerFactory; - } - - /** - * Currently, this method returns the class name of - * {@link BasicMarkerFactory}. - */ - public String getMarkerFactoryClassStr() { - return BasicMarkerFactory.class.getName(); - } - - -} diff --git a/trunk/slf4j-jcl/src/main/resources/META-INF/MANIFEST.MF b/trunk/slf4j-jcl/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index fa431854a..000000000 --- a/trunk/slf4j-jcl/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,10 +0,0 @@ -Implementation-Title: slf4j-jcl -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: slf4j.jcl -Bundle-Name: slf4j-jcl -Bundle-Vendor: SLF4J.ORG -Require-Bundle: slf4j.api -Bundle-RequiredExecutionEnvironment: J2SE-1.3 -Export-Package: org.slf4j.impl;version=${project.version} -Import-Package: org.slf4j.spi;version=${project.version}, org.slf4j.helpers;version=${project.version}, org.apache.commons.logging -Fragment-Host: slf4j.api \ No newline at end of file diff --git a/trunk/slf4j-jcl/src/test/java/org/slf4j/InvocationTest.java b/trunk/slf4j-jcl/src/test/java/org/slf4j/InvocationTest.java deleted file mode 100644 index dc84aa203..000000000 --- a/trunk/slf4j-jcl/src/test/java/org/slf4j/InvocationTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.CH - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j; - -import junit.framework.TestCase; - - -/** - * Test whether invoking the SLF4J API causes problems or not. - * - * @author Ceki Gulcu - * - */ -public class InvocationTest extends TestCase { - - public InvocationTest (String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void test1() { - Logger logger = LoggerFactory.getLogger("test1"); - logger.debug("Hello world."); - } - - public void test2() { - Integer i1 = new Integer(1); - Integer i2 = new Integer(2); - Integer i3 = new Integer(3); - Exception e = new Exception("This is a test exception."); - Logger logger = LoggerFactory.getLogger("test2"); - - logger.debug("Hello world 1."); - logger.debug("Hello world {}", i1); - logger.debug("val={} val={}", i1, i2); - logger.debug("val={} val={} val={}", new Object[]{i1, i2, i3}); - - logger.debug("Hello world 2", e); - logger.info("Hello world 2."); - - - logger.warn("Hello world 3."); - logger.warn("Hello world 3", e); - - - logger.error("Hello world 4."); - logger.error("Hello world {}", new Integer(3)); - logger.error("Hello world 4.", e); - } - - public void testNull() { - Logger logger = LoggerFactory.getLogger("testNull"); - logger.debug(null); - logger.info(null); - logger.warn(null); - logger.error(null); - - Exception e = new Exception("This is a test exception."); - logger.debug(null, e); - logger.info(null, e); - logger.warn(null, e); - logger.error(null, e); - } - - public void testMarker() { - Logger logger = LoggerFactory.getLogger("testMarker"); - Marker blue = MarkerFactory.getMarker("BLUE"); - logger.debug(blue, "hello"); - logger.info(blue, "hello"); - logger.warn(blue, "hello"); - logger.error(blue, "hello"); - - logger.debug(blue, "hello {}", "world"); - logger.info(blue, "hello {}", "world"); - logger.warn(blue, "hello {}", "world"); - logger.error(blue, "hello {}", "world"); - - logger.debug(blue, "hello {} and {} ", "world", "universe"); - logger.info(blue, "hello {} and {} ", "world", "universe"); - logger.warn(blue, "hello {} and {} ", "world", "universe"); - logger.error(blue, "hello {} and {} ", "world", "universe"); - } - - public void testMDC() { - MDC.put("k", "v"); - assertNull(MDC.get("k")); - MDC.remove("k"); - assertNull(MDC.get("k")); - MDC.clear(); - } -} diff --git a/trunk/slf4j-jdk14/LICENSE.txt b/trunk/slf4j-jdk14/LICENSE.txt deleted file mode 100644 index f6e2f31f7..000000000 --- a/trunk/slf4j-jdk14/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2004-2007 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - diff --git a/trunk/slf4j-jdk14/pom.xml b/trunk/slf4j-jdk14/pom.xml deleted file mode 100644 index 7f5fea3a8..000000000 --- a/trunk/slf4j-jdk14/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-jdk14 - - jar - SLF4J JDK14 Binding - - http://www.slf4j.org - - The slf4j JDK14 binding - - - - - org.slf4j - slf4j-api - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.4 - 1.4 - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.version} - ${project.description} - ${project.version} - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java b/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java deleted file mode 100644 index e8be50244..000000000 --- a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java +++ /dev/null @@ -1,655 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import java.util.logging.Level; -import java.util.logging.LogRecord; - -import org.slf4j.Logger; -import org.slf4j.Marker; -import org.slf4j.helpers.MarkerIgnoringBase; -import org.slf4j.helpers.MessageFormatter; -import org.slf4j.spi.LocationAwareLogger; - -/** - * A wrapper over {@link java.util.logging.Logger java.util.logging.Logger} in - * conformity with the {@link Logger} interface. Note that the logging levels - * mentioned in this class refer to those defined in the java.util.logging - * package. - * - * @author Ceki Gülcü - * @author Peter Royal - */ -public final class JDK14LoggerAdapter extends MarkerIgnoringBase implements - LocationAwareLogger { - final java.util.logging.Logger logger; - - // WARN: JDK14LoggerAdapter constructor should have only package access so - // that only JDK14LoggerFactory be able to create one. - JDK14LoggerAdapter(java.util.logging.Logger logger) { - this.logger = logger; - } - - public String getName() { - return logger.getName(); - } - - /** - * Is this logger instance enabled for the FINEST level? - * - * @return True if this Logger is enabled for level FINEST, false otherwise. - */ - public boolean isTraceEnabled() { - return logger.isLoggable(Level.FINEST); - } - - /** - * Log a message object at level FINEST. - * - * @param msg - - * the message object to be logged - */ - public void trace(String msg) { - if (logger.isLoggable(Level.FINEST)) { - log(SELF, Level.FINEST, msg, null); - } - } - - /** - * Log a message at level FINEST according to the specified format and - * argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for level FINEST. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void trace(String format, Object arg) { - if (logger.isLoggable(Level.FINEST)) { - String msgStr = MessageFormatter.format(format, arg); - log(SELF, Level.FINEST, msgStr, null); - } - } - - /** - * Log a message at level FINEST according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the FINEST level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void trace(String format, Object arg1, Object arg2) { - if (logger.isLoggable(Level.FINEST)) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log(SELF, Level.FINEST, msgStr, null); - } - } - - /** - * Log a message at level FINEST according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the FINEST level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void trace(String format, Object[] argArray) { - if (logger.isLoggable(Level.FINEST)) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log(SELF, Level.FINEST, msgStr, null); - } - } - - /** - * Log an exception (throwable) at level FINEST with an accompanying message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void trace(String msg, Throwable t) { - if (logger.isLoggable(Level.FINEST)) { - log(SELF, Level.FINEST, msg, t); - } - } - - /** - * Is this logger instance enabled for the FINE level? - * - * @return True if this Logger is enabled for level FINE, false otherwise. - */ - public boolean isDebugEnabled() { - return logger.isLoggable(Level.FINE); - } - - /** - * Log a message object at level FINE. - * - * @param msg - - * the message object to be logged - */ - public void debug(String msg) { - if (logger.isLoggable(Level.FINE)) { - log(SELF, Level.FINE, msg, null); - } - } - - /** - * Log a message at level FINE according to the specified format and argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for level FINE. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void debug(String format, Object arg) { - if (logger.isLoggable(Level.FINE)) { - String msgStr = MessageFormatter.format(format, arg); - log(SELF, Level.FINE, msgStr, null); - } - } - - /** - * Log a message at level FINE according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the FINE level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void debug(String format, Object arg1, Object arg2) { - if (logger.isLoggable(Level.FINE)) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log(SELF, Level.FINE, msgStr, null); - } - } - - /** - * Log a message at level FINE according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the FINE level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void debug(String format, Object[] argArray) { - if (logger.isLoggable(Level.FINE)) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log(SELF, Level.FINE, msgStr, null); - } - } - - /** - * Log an exception (throwable) at level FINE with an accompanying message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void debug(String msg, Throwable t) { - if (logger.isLoggable(Level.FINE)) { - log(SELF, Level.FINE, msg, t); - } - } - - /** - * Is this logger instance enabled for the INFO level? - * - * @return True if this Logger is enabled for the INFO level, false otherwise. - */ - public boolean isInfoEnabled() { - return logger.isLoggable(Level.INFO); - } - - /** - * Log a message object at the INFO level. - * - * @param msg - - * the message object to be logged - */ - public void info(String msg) { - if (logger.isLoggable(Level.INFO)) { - log(SELF, Level.INFO, msg, null); - } - } - - /** - * Log a message at level INFO according to the specified format and argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void info(String format, Object arg) { - if (logger.isLoggable(Level.INFO)) { - String msgStr = MessageFormatter.format(format, arg); - log(SELF, Level.INFO, msgStr, null); - } - } - - /** - * Log a message at the INFO level according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void info(String format, Object arg1, Object arg2) { - if (logger.isLoggable(Level.INFO)) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log(SELF, Level.INFO, msgStr, null); - } - } - - /** - * Log a message at level INFO according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void info(String format, Object[] argArray) { - if (logger.isLoggable(Level.INFO)) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log(SELF, Level.INFO, msgStr, null); - } - } - - /** - * Log an exception (throwable) at the INFO level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void info(String msg, Throwable t) { - if (logger.isLoggable(Level.INFO)) { - log(SELF, Level.INFO, msg, t); - } - } - - /** - * Is this logger instance enabled for the WARNING level? - * - * @return True if this Logger is enabled for the WARNING level, false - * otherwise. - */ - public boolean isWarnEnabled() { - return logger.isLoggable(Level.WARNING); - } - - /** - * Log a message object at the WARNING level. - * - * @param msg - - * the message object to be logged - */ - public void warn(String msg) { - if (logger.isLoggable(Level.WARNING)) { - log(SELF, Level.WARNING, msg, null); - } - } - - /** - * Log a message at the WARNING level according to the specified format and - * argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the WARNING level. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void warn(String format, Object arg) { - if (logger.isLoggable(Level.WARNING)) { - String msgStr = MessageFormatter.format(format, arg); - log(SELF, Level.WARNING, msgStr, null); - } - } - - /** - * Log a message at the WARNING level according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the WARNING level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void warn(String format, Object arg1, Object arg2) { - if (logger.isLoggable(Level.WARNING)) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log(SELF, Level.WARNING, msgStr, null); - } - } - - /** - * Log a message at level WARNING according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the WARNING level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void warn(String format, Object[] argArray) { - if (logger.isLoggable(Level.WARNING)) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log(SELF, Level.WARNING, msgStr, null); - } - } - - /** - * Log an exception (throwable) at the WARNING level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void warn(String msg, Throwable t) { - if (logger.isLoggable(Level.WARNING)) { - log(SELF, Level.WARNING, msg, t); - } - } - - /** - * Is this logger instance enabled for level SEVERE? - * - * @return True if this Logger is enabled for level SEVERE, false otherwise. - */ - public boolean isErrorEnabled() { - return logger.isLoggable(Level.SEVERE); - } - - /** - * Log a message object at the SEVERE level. - * - * @param msg - - * the message object to be logged - */ - public void error(String msg) { - if (logger.isLoggable(Level.SEVERE)) { - log(SELF, Level.SEVERE, msg, null); - } - } - - /** - * Log a message at the SEVERE level according to the specified format and - * argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the SEVERE level. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void error(String format, Object arg) { - if (logger.isLoggable(Level.SEVERE)) { - String msgStr = MessageFormatter.format(format, arg); - log(SELF, Level.SEVERE, msgStr, null); - } - } - - /** - * Log a message at the SEVERE level according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the SEVERE level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void error(String format, Object arg1, Object arg2) { - if (logger.isLoggable(Level.SEVERE)) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - log(SELF, Level.SEVERE, msgStr, null); - } - } - - /** - * Log a message at level SEVERE according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the SEVERE level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void error(String format, Object[] argArray) { - if (logger.isLoggable(Level.SEVERE)) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - log(SELF, Level.SEVERE, msgStr, null); - } - } - - /** - * Log an exception (throwable) at the SEVERE level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void error(String msg, Throwable t) { - if (logger.isLoggable(Level.SEVERE)) { - log(SELF, Level.SEVERE, msg, t); - } - } - - /** - * Log the message at the specified level with the specified throwable if any. - * This method creates a LogRecord and fills in caller date before calling - * this instance's JDK14 logger. - * - * See bug report #13 for more details. - * - * @param level - * @param msg - * @param t - */ - private void log(String callerFQCN, Level level, String msg, Throwable t) { - // millis and thread are filled by the constructor - LogRecord record = new LogRecord(level, msg); - record.setLoggerName(getName()); - record.setThrown(t); - fillCallerData(callerFQCN, record); - logger.log(record); - - } - - static String SELF = JDK14LoggerAdapter.class.getName(); - static String SUPER = MarkerIgnoringBase.class.getName(); - - /** - * Fill in caller data if possible. - * - * @param record - * The record to update - */ - final private void fillCallerData(String callerFQCN, LogRecord record) { - StackTraceElement[] steArray = new Throwable().getStackTrace(); - - int selfIndex = -1; - for (int i = 0; i < steArray.length; i++) { - final String className = steArray[i].getClassName(); - if (className.equals(callerFQCN) || className.equals(SUPER)) { - selfIndex = i; - break; - } - } - - int found = -1; - for (int i = selfIndex + 1; i < steArray.length; i++) { - final String className = steArray[i].getClassName(); - if (!(className.equals(callerFQCN) || className.equals(SUPER))) { - found = i; - break; - } - } - - if (found != -1) { - StackTraceElement ste = steArray[found]; - // setting the class name has the side effect of setting - // the needToInferCaller variable to false. - record.setSourceClassName(ste.getClassName()); - record.setSourceMethodName(ste.getMethodName()); - } - } - - public void log(Marker marker, String callerFQCN, int level, String message, - Throwable t) { - Level julLevel; - switch (level) { - case LocationAwareLogger.TRACE_INT: - julLevel = Level.FINEST; - break; - case LocationAwareLogger.DEBUG_INT: - julLevel = Level.FINE; - break; - case LocationAwareLogger.INFO_INT: - julLevel = Level.INFO; - break; - case LocationAwareLogger.WARN_INT: - julLevel = Level.WARNING; - break; - case LocationAwareLogger.ERROR_INT: - julLevel = Level.SEVERE; - break; - default: - throw new IllegalStateException("Level number " + level - + " is not recognized."); - } - log(callerFQCN, julLevel, message, t); - } -} diff --git a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerFactory.java b/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerFactory.java deleted file mode 100644 index 5165beb85..000000000 --- a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.Logger; -import org.slf4j.ILoggerFactory; - -import java.util.HashMap; -import java.util.Map; - -/** - * JDK14LoggerFactory is an implementation of {@link ILoggerFactory} returning - * the appropriately named {@link JDK14LoggerAdapter} instance. - * - * @author Ceki Gülcü - */ -public class JDK14LoggerFactory implements ILoggerFactory { - - // key: name (String), value: a JDK14LoggerAdapter; - Map loggerMap; - - public JDK14LoggerFactory() { - loggerMap = new HashMap(); - } - - /* - * (non-Javadoc) - * - * @see org.slf4j.ILoggerFactory#getLogger(java.lang.String) - */ - public synchronized Logger getLogger(String name) { - Logger ulogger = null; - // protect against concurrent access of loggerMap - synchronized (this) { - // the root logger is called "" in JUL - if(name.equalsIgnoreCase(Logger.ROOT_LOGGER_NAME)) { - name = ""; - } - ulogger = (Logger) loggerMap.get(name); - if (ulogger == null) { - java.util.logging.Logger logger = java.util.logging.Logger - .getLogger(name); - ulogger = new JDK14LoggerAdapter(logger); - loggerMap.put(name, ulogger); - } - } - return ulogger; - } -} diff --git a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticLoggerBinder.java deleted file mode 100644 index b3bab57e1..000000000 --- a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.ILoggerFactory; -import org.slf4j.LoggerFactory; -import org.slf4j.spi.LoggerFactoryBinder; - -/** - * The binding of {@link LoggerFactory} class with an actual instance of - * {@link ILoggerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticLoggerBinder implements LoggerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - // Note: JCL gets substituted at build time by an appropriate Ant task - private static final String loggerFactoryClassStr = org.slf4j.impl.JDK14LoggerFactory.class.getName(); - - /** The ILoggerFactory instance returned by the {@link #getLoggerFactory} method - * should always be the same object - */ - private final ILoggerFactory loggerFactory; - - private StaticLoggerBinder() { -// Note: JCL gets substituted at build time by an appropriate Ant task - loggerFactory = new org.slf4j.impl.JDK14LoggerFactory(); - } - - public ILoggerFactory getLoggerFactory() { - return loggerFactory; - } - - public String getLoggerFactoryClassStr() { - return loggerFactoryClassStr; - } -} diff --git a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticMDCBinder.java deleted file mode 100644 index 09b3a03ff..000000000 --- a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticMDCBinder.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.slf4j.impl; - -import org.slf4j.helpers.BasicMDCAdapter; -import org.slf4j.spi.MDCAdapter; - - -/** - * This implementation is bound to {@link BasicMDCAdapter}. - * - * @author Ceki Gülcü - */ -public class StaticMDCBinder { - - - /** - * The unique instance of this class. - */ - public static final StaticMDCBinder SINGLETON = new StaticMDCBinder(); - - private StaticMDCBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link BasicMDCAdapter}. - */ - public MDCAdapter getMDCA() { - // note that this method is invoked only from within the static initializer of - // the org.slf4j.MDC class. - return new BasicMDCAdapter(); - } - - public String getMDCAdapterClassStr() { - return BasicMDCAdapter.class.getName(); - } -} diff --git a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticMarkerBinder.java deleted file mode 100644 index b37c3640e..000000000 --- a/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticMarkerBinder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.IMarkerFactory; -import org.slf4j.MarkerFactory; -import org.slf4j.helpers.BasicMarkerFactory; -import org.slf4j.spi.MarkerFactoryBinder; - -/** - * - * The binding of {@link MarkerFactory} class with an actual instance of - * {@link IMarkerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticMarkerBinder implements MarkerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder(); - - final IMarkerFactory markerFactory = new BasicMarkerFactory(); - - private StaticMarkerBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link BasicMarkerFactory}. - */ - public IMarkerFactory getMarkerFactory() { - return markerFactory; - } - - /** - * Currently, this method returns the class name of - * {@link BasicMarkerFactory}. - */ - public String getMarkerFactoryClassStr() { - return BasicMarkerFactory.class.getName(); - } - - -} diff --git a/trunk/slf4j-jdk14/src/main/resources/META-INF/MANIFEST.MF b/trunk/slf4j-jdk14/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 5bb3ad9cd..000000000 --- a/trunk/slf4j-jdk14/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,9 +0,0 @@ -Implementation-Title: slf4j-jdk14 -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: slf4j.jdk14 -Bundle-Name: slf4j-jdk14 -Bundle-Vendor: SLF4J.ORG -Bundle-RequiredExecutionEnvironment: J2SE-1.3 -Export-Package: org.slf4j.impl;version=${project.version} -Import-Package: org.slf4j;version=${project.version}, org.slf4j.spi;version=${project.version}, org.slf4j.helpers;version=${project.version} -Fragment-Host: slf4j.api \ No newline at end of file diff --git a/trunk/slf4j-jdk14/src/test/java/org/slf4j/InvocationTest.java b/trunk/slf4j-jdk14/src/test/java/org/slf4j/InvocationTest.java deleted file mode 100644 index 2b4d63165..000000000 --- a/trunk/slf4j-jdk14/src/test/java/org/slf4j/InvocationTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.CH - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j; - -import junit.framework.TestCase; - - -/** - * Test whether invoking the SLF4J API causes problems or not. - * - * @author Ceki Gulcu - * - */ -public class InvocationTest extends TestCase { - - public InvocationTest (String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void test1() { - Logger logger = LoggerFactory.getLogger("test1"); - logger.debug("Hello world."); - } - - public void test2() { - Integer i1 = new Integer(1); - Integer i2 = new Integer(2); - Integer i3 = new Integer(3); - Exception e = new Exception("This is a test exception."); - Logger logger = LoggerFactory.getLogger("test2"); - - logger.debug("Hello world 1."); - logger.debug("Hello world {}", i1); - logger.debug("val={} val={}", i1, i2); - logger.debug("val={} val={} val={}", new Object[]{i1, i2, i3}); - - logger.debug("Hello world 2", e); - logger.info("Hello world 2."); - - - logger.warn("Hello world 3."); - logger.warn("Hello world 3", e); - - - logger.error("Hello world 4."); - logger.error("Hello world {}", new Integer(3)); - logger.error("Hello world 4.", e); - } - - public void testNull() { - Logger logger = LoggerFactory.getLogger("testNull"); - logger.debug(null); - logger.info(null); - logger.warn(null); - logger.error(null); - - Exception e = new Exception("This is a test exception."); - logger.debug(null, e); - logger.info(null, e); - logger.warn(null, e); - logger.error(null, e); - } - - public void testMarker() { - Logger logger = LoggerFactory.getLogger("testMarker"); - Marker blue = MarkerFactory.getMarker("BLUE"); - logger.debug(blue, "hello"); - logger.info(blue, "hello"); - logger.warn(blue, "hello"); - logger.error(blue, "hello"); - - logger.debug(blue, "hello {}", "world"); - logger.info(blue, "hello {}", "world"); - logger.warn(blue, "hello {}", "world"); - logger.error(blue, "hello {}", "world"); - - logger.debug(blue, "hello {} and {} ", "world", "universe"); - logger.info(blue, "hello {} and {} ", "world", "universe"); - logger.warn(blue, "hello {} and {} ", "world", "universe"); - logger.error(blue, "hello {} and {} ", "world", "universe"); - } - - public void testMDC() { - MDC.put("k", "v"); - assertNotNull(MDC.get("k")); - assertEquals("v", MDC.get("k")); - - MDC.remove("k"); - assertNull(MDC.get("k")); - - MDC.put("k1", "v1"); - assertEquals("v1", MDC.get("k1")); - MDC.clear(); - assertNull(MDC.get("k1")); - - try { - MDC.put(null, "x"); - fail("null keys are invalid"); - } catch (IllegalArgumentException e) { - } - } -} diff --git a/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/JDK14AdapterLoggerNameTest.java b/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/JDK14AdapterLoggerNameTest.java deleted file mode 100644 index cc511adb0..000000000 --- a/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/JDK14AdapterLoggerNameTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import java.util.logging.Handler; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import junit.framework.TestCase; - -public class JDK14AdapterLoggerNameTest extends TestCase { - private MockHandler mockHandler; - - protected void setUp() throws Exception { - super.setUp(); - Logger logger = Logger.getLogger("TEST"); - mockHandler = new MockHandler(); - removeHandlers(logger); - logger.addHandler(mockHandler); - } - - protected void tearDown() throws Exception { - removeHandlers(Logger.getLogger("TEST")); - super.tearDown(); - } - - public void testLoggerNameusingJdkLogging() throws Exception { - Logger.getLogger("TEST").info("test message"); - assertCorrectLoggerName(); - - } - - public void testLoggerNameUsingSlf4j() throws Exception { - JDK14LoggerFactory factory = new JDK14LoggerFactory(); - org.slf4j.Logger logger = factory.getLogger("TEST"); - logger.info("test message"); - assertCorrectLoggerName(); - } - - private void removeHandlers(Logger logger) { - logger.setUseParentHandlers(false); - Handler[] handlers = logger.getHandlers(); - for (int i = 0; i < handlers.length; i++) { - logger.removeHandler(handlers[i]); - } - } - - private void assertCorrectLoggerName() { - assertNotNull("no log record", mockHandler.record); - assertNotNull("missing logger name", mockHandler.record.getLoggerName()); - } - - private class MockHandler extends java.util.logging.Handler { - public LogRecord record; - - public void close() throws SecurityException { - } - - public void flush() { - } - - public void publish(LogRecord record) { - this.record = record; - } - - } -} \ No newline at end of file diff --git a/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java b/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java deleted file mode 100644 index 9e44f3131..000000000 --- a/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.slf4j.impl; - -import junit.framework.TestCase; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PerfTest extends TestCase { - - public PerfTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testBug72() { - Logger logger = LoggerFactory.getLogger(PerfTest.class); - int len = 2000; - for (int i = 0; i < len; i++) { - logger.debug("hello"); - } - - long start = System.currentTimeMillis(); - for (int i = 0; i < len; i++) { - logger.debug("hello"); - } - - long end = System.currentTimeMillis(); - - long duration = end-start; - // when the code is guarded by a logger.isLoggable condition, - // duration is about 16 *micro*seconds for 1000 iterations - // when it is not guarded the figure is 90 milliseconds, - // i.e a ration of 1 to 5000 - assertTrue(duration <= 5); - } - -} diff --git a/trunk/slf4j-log4j12/LICENSE.txt b/trunk/slf4j-log4j12/LICENSE.txt deleted file mode 100644 index f6e2f31f7..000000000 --- a/trunk/slf4j-log4j12/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2004-2007 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - diff --git a/trunk/slf4j-log4j12/pom.xml b/trunk/slf4j-log4j12/pom.xml deleted file mode 100644 index 4f485930d..000000000 --- a/trunk/slf4j-log4j12/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-log4j12 - jar - SLF4J LOG4J-12 Binding - - http://www.slf4j.org - - - The slf4j log4j-12 binding - - - - - org.slf4j - slf4j-api - - - - log4j - log4j - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.version} - ${project.description} - ${project.version} - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java b/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java deleted file mode 100644 index 11a81b533..000000000 --- a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java +++ /dev/null @@ -1,605 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.apache.log4j.Level; -import org.slf4j.Logger; -import org.slf4j.Marker; -import org.slf4j.helpers.MarkerIgnoringBase; -import org.slf4j.helpers.MessageFormatter; -import org.slf4j.spi.LocationAwareLogger; - -/** - * A wrapper over {@link org.apache.log4j.Logger org.apache.log4j.Logger} in - * conforming to the {@link Logger} interface. - * - *

Note that the logging levels mentioned in this class refer to those defined in the org.apache.log4j.Level - * class. - * - *

- * The TRACE level was introduced in log4j version 1.2.12. In order to avoid - * crashing the host application, in the case the log4j version in use predates - * 1.2.12, the TRACE level will be mapped as DEBUG. See also bug 68. - * - * @author Ceki Gülcü - */ -public final class Log4jLoggerAdapter extends MarkerIgnoringBase implements - LocationAwareLogger { - final org.apache.log4j.Logger logger; - - /** - * Following the pattern discussed in pages 162 through 168 of "The complete - * log4j manual". - */ - final static String FQCN = Log4jLoggerAdapter.class.getName(); - - // Does the log4j version in use recognize the TRACE level? - // The trace level was introduced in log4j 1.2.12. - final boolean traceCapable; - - // WARN: Log4jLoggerAdapter constructor should have only package access so - // that - // only Log4jLoggerFactory be able to create one. - Log4jLoggerAdapter(org.apache.log4j.Logger logger) { - this.logger = logger; - traceCapable = isTraceCapable(); - } - - private boolean isTraceCapable() { - try { - logger.isTraceEnabled(); - return true; - } catch (NoSuchMethodError e) { - return false; - } - } - - public String getName() { - return logger.getName(); - } - - /** - * Is this logger instance enabled for the TRACE level? - * - * @return True if this Logger is enabled for level TRACE, false otherwise. - */ - public boolean isTraceEnabled() { - if (traceCapable) { - return logger.isTraceEnabled(); - } else { - return logger.isDebugEnabled(); - } - } - - /** - * Log a message object at level TRACE. - * - * @param msg - - * the message object to be logged - */ - public void trace(String msg) { - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msg, null); - } - - /** - * Log a message at level TRACE according to the specified format and - * argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for level TRACE. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void trace(String format, Object arg) { - if (logger.isTraceEnabled()) { - String msgStr = MessageFormatter.format(format, arg); - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msgStr, null); - } - } - - /** - * Log a message at level TRACE according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the TRACE level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void trace(String format, Object arg1, Object arg2) { - if (logger.isTraceEnabled()) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msgStr, null); - } - } - - /** - * Log a message at level TRACE according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the TRACE level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void trace(String format, Object[] argArray) { - if (logger.isTraceEnabled()) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msgStr, null); - } - } - - /** - * Log an exception (throwable) at level TRACE with an accompanying message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void trace(String msg, Throwable t) { - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msg, t); - } - - /** - * Is this logger instance enabled for the DEBUG level? - * - * @return True if this Logger is enabled for level DEBUG, false otherwise. - */ - public boolean isDebugEnabled() { - return logger.isDebugEnabled(); - } - - /** - * Log a message object at level DEBUG. - * - * @param msg - - * the message object to be logged - */ - public void debug(String msg) { - logger.log(FQCN, Level.DEBUG, msg, null); - } - - /** - * Log a message at level DEBUG according to the specified format and - * argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for level DEBUG. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void debug(String format, Object arg) { - if (logger.isDebugEnabled()) { - String msgStr = MessageFormatter.format(format, arg); - logger.log(FQCN, Level.DEBUG, msgStr, null); - } - } - - /** - * Log a message at level DEBUG according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the DEBUG level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void debug(String format, Object arg1, Object arg2) { - if (logger.isDebugEnabled()) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - logger.log(FQCN, Level.DEBUG, msgStr, null); - } - } - - /** - * Log a message at level DEBUG according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the DEBUG level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void debug(String format, Object[] argArray) { - if (logger.isDebugEnabled()) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - logger.log(FQCN, Level.DEBUG, msgStr, null); - } - } - - /** - * Log an exception (throwable) at level DEBUG with an accompanying message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void debug(String msg, Throwable t) { - logger.log(FQCN, Level.DEBUG, msg, t); - } - - /** - * Is this logger instance enabled for the INFO level? - * - * @return True if this Logger is enabled for the INFO level, false otherwise. - */ - public boolean isInfoEnabled() { - return logger.isInfoEnabled(); - } - - /** - * Log a message object at the INFO level. - * - * @param msg - - * the message object to be logged - */ - public void info(String msg) { - logger.log(FQCN, Level.INFO, msg, null); - } - - /** - * Log a message at level INFO according to the specified format and argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void info(String format, Object arg) { - if (logger.isInfoEnabled()) { - String msgStr = MessageFormatter.format(format, arg); - logger.log(FQCN, Level.INFO, msgStr, null); - } - } - - /** - * Log a message at the INFO level according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void info(String format, Object arg1, Object arg2) { - if (logger.isInfoEnabled()) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - logger.log(FQCN, Level.INFO, msgStr, null); - } - } - - /** - * Log a message at level INFO according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void info(String format, Object[] argArray) { - if (logger.isInfoEnabled()) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - logger.log(FQCN, Level.INFO, msgStr, null); - } - } - - /** - * Log an exception (throwable) at the INFO level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void info(String msg, Throwable t) { - logger.log(FQCN, Level.INFO, msg, t); - } - - /** - * Is this logger instance enabled for the WARN level? - * - * @return True if this Logger is enabled for the WARN level, false otherwise. - */ - public boolean isWarnEnabled() { - return logger.isEnabledFor(Level.WARN); - } - - /** - * Log a message object at the WARN level. - * - * @param msg - - * the message object to be logged - */ - public void warn(String msg) { - logger.log(FQCN, Level.WARN, msg, null); - } - - /** - * Log a message at the WARN level according to the specified format and - * argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the WARN level. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void warn(String format, Object arg) { - if (logger.isEnabledFor(Level.WARN)) { - String msgStr = MessageFormatter.format(format, arg); - logger.log(FQCN, Level.WARN, msgStr, null); - } - } - - /** - * Log a message at the WARN level according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the WARN level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void warn(String format, Object arg1, Object arg2) { - if (logger.isEnabledFor(Level.WARN)) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - logger.log(FQCN, Level.WARN, msgStr, null); - } - } - - /** - * Log a message at level WARN according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the WARN level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void warn(String format, Object[] argArray) { - if (logger.isEnabledFor(Level.WARN)) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - logger.log(FQCN, Level.WARN, msgStr, null); - } - } - - /** - * Log an exception (throwable) at the WARN level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void warn(String msg, Throwable t) { - logger.log(FQCN, Level.WARN, msg, t); - } - - /** - * Is this logger instance enabled for level ERROR? - * - * @return True if this Logger is enabled for level ERROR, false otherwise. - */ - public boolean isErrorEnabled() { - return logger.isEnabledFor(Level.ERROR); - } - - /** - * Log a message object at the ERROR level. - * - * @param msg - - * the message object to be logged - */ - public void error(String msg) { - logger.log(FQCN, Level.ERROR, msg, null); - } - - /** - * Log a message at the ERROR level according to the specified format and - * argument. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the ERROR level. - *

- * - * @param format - * the format string - * @param arg - * the argument - */ - public void error(String format, Object arg) { - if (logger.isEnabledFor(Level.ERROR)) { - String msgStr = MessageFormatter.format(format, arg); - logger.log(FQCN, Level.ERROR, msgStr, null); - } - } - - /** - * Log a message at the ERROR level according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the ERROR level. - *

- * - * @param format - * the format string - * @param arg1 - * the first argument - * @param arg2 - * the second argument - */ - public void error(String format, Object arg1, Object arg2) { - if (logger.isEnabledFor(Level.ERROR)) { - String msgStr = MessageFormatter.format(format, arg1, arg2); - logger.log(FQCN, Level.ERROR, msgStr, null); - } - } - - /** - * Log a message at level ERROR according to the specified format and - * arguments. - * - *

- * This form avoids superfluous object creation when the logger is disabled - * for the ERROR level. - *

- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - public void error(String format, Object[] argArray) { - if (logger.isEnabledFor(Level.ERROR)) { - String msgStr = MessageFormatter.arrayFormat(format, argArray); - logger.log(FQCN, Level.ERROR, msgStr, null); - } - } - - /** - * Log an exception (throwable) at the ERROR level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - public void error(String msg, Throwable t) { - logger.log(FQCN, Level.ERROR, msg, t); - } - - public void log(Marker marker, String callerFQCN, int level, String msg, - Throwable t) { - Level log4jLevel; - switch (level) { - case LocationAwareLogger.TRACE_INT: - log4jLevel = traceCapable ? Level.TRACE : Level.DEBUG; - break; - case LocationAwareLogger.DEBUG_INT: - log4jLevel = Level.DEBUG; - break; - case LocationAwareLogger.INFO_INT: - log4jLevel = Level.INFO; - break; - case LocationAwareLogger.WARN_INT: - log4jLevel = Level.WARN; - break; - case LocationAwareLogger.ERROR_INT: - log4jLevel = Level.ERROR; - break; - default: - throw new IllegalStateException("Level number " + level - + " is not recognized."); - } - logger.log(callerFQCN, log4jLevel, msg, t); - } -} diff --git a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerFactory.java b/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerFactory.java deleted file mode 100644 index 627ee514d..000000000 --- a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerFactory.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.LogManager; -import org.slf4j.ILoggerFactory; -import org.slf4j.Logger; - -/** - * Log4jLoggerFactory is an implementation of {@link ILoggerFactory} returning - * the appropriate named {@link Log4jLoggerAdapter} instance. - * - * @author Ceki Gülcü - */ -public class Log4jLoggerFactory implements ILoggerFactory { - - // key: name (String), value: a Log4jLoggerAdapter; - Map loggerMap; - - public Log4jLoggerFactory() { - loggerMap = new HashMap(); - } - - /* - * (non-Javadoc) - * - * @see org.slf4j.ILoggerFactory#getLogger(java.lang.String) - */ - public Logger getLogger(String name) { - Logger slf4jLogger = null; - // protect against concurrent access of loggerMap - synchronized (this) { - slf4jLogger = (Logger) loggerMap.get(name); - if (slf4jLogger == null) { - org.apache.log4j.Logger log4jLogger; - if(name.equalsIgnoreCase(Logger.ROOT_LOGGER_NAME)) { - log4jLogger = LogManager.getRootLogger(); - } else { - log4jLogger = LogManager.getLogger(name); - } - slf4jLogger = new Log4jLoggerAdapter(log4jLogger); - loggerMap.put(name, slf4jLogger); - } - } - return slf4jLogger; - } -} diff --git a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jMDCAdapter.java b/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jMDCAdapter.java deleted file mode 100644 index f68355ff8..000000000 --- a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jMDCAdapter.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.slf4j.impl; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.slf4j.spi.MDCAdapter; - -public class Log4jMDCAdapter implements MDCAdapter { - - public void clear() { - Map map = org.apache.log4j.MDC.getContext(); - if (map != null) { - map.clear(); - } - } - - public String get(String key) { - return (String) org.apache.log4j.MDC.get(key); - } - - /** - * Put a context value (the val parameter) as identified with - * the key parameter into the current thread's context map. The - * key parameter cannot be null. Log4j does not - * support null for the val parameter. - * - *

- * This method delegates all work to log4j's MDC. - * - * @throws IllegalArgumentException - * in case the "key" or "val" parameter is null - */ - public void put(String key, String val) { - org.apache.log4j.MDC.put(key, val); - } - - public void remove(String key) { - org.apache.log4j.MDC.remove(key); - } - - public Map getCopyOfContextMap() { - Map old = org.apache.log4j.MDC.getContext(); - if(old != null) { - return new HashMap(old); - } else { - return null; - } - } - - public void setContextMap(Map contextMap) { - Map old = org.apache.log4j.MDC.getContext(); - if(old == null) { - Iterator entrySetIterator = contextMap.entrySet().iterator(); - while(entrySetIterator.hasNext()) { - Map.Entry mapEntry = (Map.Entry) entrySetIterator.next(); - org.apache.log4j.MDC.put((String) mapEntry.getKey(), mapEntry.getValue()); - } - } else { - old.clear(); - old.putAll(contextMap); - } - } -} diff --git a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java deleted file mode 100644 index 0565aa66d..000000000 --- a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.apache.log4j.Level; -import org.slf4j.ILoggerFactory; -import org.slf4j.LoggerFactory; -import org.slf4j.helpers.Util; -import org.slf4j.spi.LoggerFactoryBinder; - -/** - * The binding of {@link LoggerFactory} class with an actual instance of - * {@link ILoggerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticLoggerBinder implements LoggerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - // Note: JCL gets substituted at build time by an appropriate Ant task - private static final String loggerFactoryClassStr = Log4jLoggerFactory.class.getName(); - - /** The ILoggerFactory instance returned by the {@link #getLoggerFactory} method - * should always be the same object - */ - private final ILoggerFactory loggerFactory; - - private StaticLoggerBinder() { - loggerFactory = new Log4jLoggerFactory(); - try { - Level level = Level.TRACE; - } catch(NoSuchFieldError nsfe) { - Util.reportFailure("This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version"); - } - } - - public ILoggerFactory getLoggerFactory() { - return loggerFactory; - } - - public String getLoggerFactoryClassStr() { - return loggerFactoryClassStr; - } -} diff --git a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMDCBinder.java deleted file mode 100644 index 897fda15d..000000000 --- a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMDCBinder.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.slf4j.impl; - -import org.slf4j.spi.MDCAdapter; - - -/** - * This implementation is bound to {@link Log4jMDCAdapter}. - * - * @author Ceki Gülcü - */ -public class StaticMDCBinder { - - - /** - * The unique instance of this class. - */ - public static final StaticMDCBinder SINGLETON = new StaticMDCBinder(); - - private StaticMDCBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link StaticMDCBinder}. - */ - public MDCAdapter getMDCA() { - return new Log4jMDCAdapter(); - } - - public String getMDCAdapterClassStr() { - return Log4jMDCAdapter.class.getName(); - } -} diff --git a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMarkerBinder.java deleted file mode 100644 index b37c3640e..000000000 --- a/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMarkerBinder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.IMarkerFactory; -import org.slf4j.MarkerFactory; -import org.slf4j.helpers.BasicMarkerFactory; -import org.slf4j.spi.MarkerFactoryBinder; - -/** - * - * The binding of {@link MarkerFactory} class with an actual instance of - * {@link IMarkerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticMarkerBinder implements MarkerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder(); - - final IMarkerFactory markerFactory = new BasicMarkerFactory(); - - private StaticMarkerBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link BasicMarkerFactory}. - */ - public IMarkerFactory getMarkerFactory() { - return markerFactory; - } - - /** - * Currently, this method returns the class name of - * {@link BasicMarkerFactory}. - */ - public String getMarkerFactoryClassStr() { - return BasicMarkerFactory.class.getName(); - } - - -} diff --git a/trunk/slf4j-log4j12/src/main/resources/META-INF/MANIFEST.MF b/trunk/slf4j-log4j12/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 1de0956ad..000000000 --- a/trunk/slf4j-log4j12/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,9 +0,0 @@ -Implementation-Title: slf4j-log4j12 -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: slf4j.log4j12 -Bundle-Name: slf4j-log4j12 -Bundle-Vendor: SLF4J.ORG -Bundle-RequiredExecutionEnvironment: J2SE-1.3 -Export-Package: org.slf4j.impl;version=${project.version} -Import-Package: org.slf4j;version=${project.version}, org.slf4j.spi;version=${project.version}, org.slf4j.helpers;version=${project.version}, org.apache.log4j -Fragment-Host: slf4j.api \ No newline at end of file diff --git a/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvocationTest.java b/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvocationTest.java deleted file mode 100644 index 9d6dc682d..000000000 --- a/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvocationTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.CH - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.spi.LoggingEvent; - -import junit.framework.TestCase; - -/** - * Test whether invoking the SLF4J API causes problems or not. - * - * @author Ceki Gulcu - * - */ -public class InvocationTest extends TestCase { - - ListAppender listAppender = new ListAppender(); - org.apache.log4j.Logger root; - public InvocationTest(String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); - root = org.apache.log4j.Logger.getRootLogger(); - root.addAppender(listAppender); - - } - - protected void tearDown() throws Exception { - super.tearDown(); - root.getLoggerRepository().resetConfiguration(); - } - - public void test1() { - Logger logger = LoggerFactory.getLogger("test1"); - logger.debug("Hello world."); - assertEquals(1, listAppender.list.size()); - } - - public void test2() { - Integer i1 = new Integer(1); - Integer i2 = new Integer(2); - Integer i3 = new Integer(3); - Exception e = new Exception("This is a test exception."); - Logger logger = LoggerFactory.getLogger("test2"); - - logger.trace("Hello trace."); - - logger.debug("Hello world 1."); - logger.debug("Hello world {}", i1); - logger.debug("val={} val={}", i1, i2); - logger.debug("val={} val={} val={}", new Object[] { i1, i2, i3 }); - - logger.debug("Hello world 2", e); - logger.info("Hello world 2."); - - logger.warn("Hello world 3."); - logger.warn("Hello world 3", e); - - logger.error("Hello world 4."); - logger.error("Hello world {}", new Integer(3)); - logger.error("Hello world 4.", e); - assertEquals(11, listAppender.list.size()); - } - - public void testNull() { - Logger logger = LoggerFactory.getLogger("testNull"); - logger.trace(null); - logger.debug(null); - logger.info(null); - logger.warn(null); - logger.error(null); - - Exception e = new Exception("This is a test exception."); - logger.debug(null, e); - logger.info(null, e); - logger.warn(null, e); - logger.error(null, e); - assertEquals(8, listAppender.list.size()); - } - - // http://bugzilla.slf4j.org/show_bug.cgi?id=78 - public void testNullParameter_BUG78() { - Logger logger = LoggerFactory.getLogger("testNullParameter_BUG78"); - String[] parameters = null; - String msg = "hello {}"; - - logger.debug(msg, parameters); - assertEquals(1, listAppender.list.size()); - LoggingEvent e = (LoggingEvent) listAppender.list.get(0); - assertEquals(msg, e.getMessage()); - } - - public void testMarker() { - Logger logger = LoggerFactory.getLogger("testMarker"); - Marker blue = MarkerFactory.getMarker("BLUE"); - logger.trace(blue, "hello"); - logger.debug(blue, "hello"); - logger.info(blue, "hello"); - logger.warn(blue, "hello"); - logger.error(blue, "hello"); - - logger.debug(blue, "hello {}", "world"); - logger.info(blue, "hello {}", "world"); - logger.warn(blue, "hello {}", "world"); - logger.error(blue, "hello {}", "world"); - - logger.debug(blue, "hello {} and {} ", "world", "universe"); - logger.info(blue, "hello {} and {} ", "world", "universe"); - logger.warn(blue, "hello {} and {} ", "world", "universe"); - logger.error(blue, "hello {} and {} ", "world", "universe"); - assertEquals(12, listAppender.list.size()); - } - - public void testMDC() { - MDC.put("k", "v"); - assertNotNull(MDC.get("k")); - assertEquals("v", MDC.get("k")); - - MDC.remove("k"); - assertNull(MDC.get("k")); - - MDC.put("k1", "v1"); - assertEquals("v1", MDC.get("k1")); - MDC.clear(); - assertNull(MDC.get("k1")); - - try { - MDC.put(null, "x"); - fail("null keys are invalid"); - } catch (IllegalArgumentException e) { - } - } - - public void testMDCContextMapValues() { - Map map = new HashMap(); - map.put("ka", "va"); - map.put("kb", "vb"); - - MDC.put("k", "v"); - assertEquals("v", MDC.get("k")); - MDC.setContextMap(map); - assertNull(MDC.get("k")); - assertEquals("va", MDC.get("ka")); - assertEquals("vb", MDC.get("kb")); - } - -} diff --git a/trunk/slf4j-log4j12/src/test/java/org/slf4j/ListAppender.java b/trunk/slf4j-log4j12/src/test/java/org/slf4j/ListAppender.java deleted file mode 100644 index 87c4d836c..000000000 --- a/trunk/slf4j-log4j12/src/test/java/org/slf4j/ListAppender.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.slf4j; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LoggingEvent; - -public class ListAppender extends AppenderSkeleton { - - public List list = new ArrayList(); - - public boolean extractLocationInfo = false; - - protected void append(LoggingEvent event) { - list.add(event); - if(extractLocationInfo) { - event.getLocationInformation(); - } - } - - public void close() { - } - - public boolean requiresLayout() { - return false; - } - -} diff --git a/trunk/slf4j-migrator/LIMITATIONS.txt b/trunk/slf4j-migrator/LIMITATIONS.txt deleted file mode 100644 index dcba5dc92..000000000 --- a/trunk/slf4j-migrator/LIMITATIONS.txt +++ /dev/null @@ -1,35 +0,0 @@ - -The slf4j-migrator aims to - -General limitations -=================== - -- the FATAL level is not supported. - - This is limitation is not deemed serious because there are usually - very few log statements bearing the FATAL level. - - -- if a method declares multipe loggers on the same line, the conversion will not be complete. Example: - - - public void someMethod(Log l1, Log l2) { - ... - } - - will be converted as - - public void someMethod(Log l1, Logger l2) { - ... - } - - -When migrating from log4j -========================= - -- Since NDC is not supported by SLF4J, the migrator cannot properly handle - NDC statements. - -- Calls to PropertyConfigurator or DomConfigurator cannot be migrated since - SLF4J the equivalents. - \ No newline at end of file diff --git a/trunk/slf4j-migrator/jcl/jclcontent.java b/trunk/slf4j-migrator/jcl/jclcontent.java deleted file mode 100644 index 68ffd5058..000000000 --- a/trunk/slf4j-migrator/jcl/jclcontent.java +++ /dev/null @@ -1,22 +0,0 @@ -/** -*This is not a class, just a sample of some jcl source code to convert -*/ -import org.apache.commons.logging.LogFactory; -import org.apache.commons.logging.Log; - - -Log l = LogFactory.getLog(MyClass.class); -Log mylog=LogFactory.getLog(MyClass.class); -Log mylog1 = LogFactory.getLog(MyClass.class); -Log mylog2 = LogFactory.getLog(MyClass.class); - -Log log3=LogFactory.getFactory().getInstance(MyClass.class); -Log mylog4 = LogFactory.getFactory().getInstance(MyClass.class); -Log mylog5 = LogFactory.getLog(MyClass.class); - -Log myLog6; - -log7=LogFactory.getFactory().getInstance(MyClass.class); -log8 =LogFactory.getFactory().getInstance(MyClass.class); -myLog9 = LogFactory.getLog(MyClass.class); - diff --git a/trunk/slf4j-migrator/pom.xml b/trunk/slf4j-migrator/pom.xml deleted file mode 100644 index e9a3d0bf7..000000000 --- a/trunk/slf4j-migrator/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-migrator - jar - SLF4J Migrator - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - org.apache.maven.plugins - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/Constant.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/Constant.java deleted file mode 100644 index 0741da7f2..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/Constant.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.slf4j.migrator; - -public class Constant { - - public final static int JCL_TO_SLF4J = 0; - public final static int LOG4J_TO_SLF4J = 1; - public final static int JUL_TO_SLF4J = 2; - public final static int NOP_TO_SLF4J = 3; - - public final static int NB_FILES_MAX = 1; - -} \ No newline at end of file diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/ConversionException.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/ConversionException.java deleted file mode 100644 index ca760f26b..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/ConversionException.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.slf4j.migrator; - -public class ConversionException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 498961799888576668L; - - private String detail; - - public static final String NOT_IMPLEMENTED = "Conversion mode not implemented yet"; - public static final String INVALID_DIRECTORY = "Invalid source directory"; - public static final String FILE_COPY = "Error during file copy"; - - public ConversionException(String message) { - super(message); - } - - public ConversionException(String message, String detail) { - super(message); - this.detail = detail; - } - - public String getDetail() { - return detail; - } - - public void setDetail(String detail) { - this.detail = detail; - } - - public void print() { - if (getMessage() != null) { - System.out.println(getMessage()); - } - } - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/FileSelector.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/FileSelector.java deleted file mode 100644 index 7875e96c1..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/FileSelector.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.slf4j.migrator; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.slf4j.migrator.internal.ProgressListener; - -public class FileSelector { - - private List javaFileList = new ArrayList(); - - ProgressListener pl; - - FileSelector(ProgressListener pl) { - this.pl = pl; - } - - public List selectJavaFilesInFolder(File folder) { - if (folder.isDirectory()) { - selectFiles(folder); - return javaFileList; - } else { - throw new IllegalArgumentException("[" + folder + "] is not a directory"); - } - } - - private void selectFiles(File file) { - if (file.isDirectory()) { - pl.onDirectory(file); - File[] files = file.listFiles(); - if (files != null) { - for (int i = 0; i < files.length; i++) { - selectFiles(files[i]); - } - } - } else { - if (file.getName().endsWith(".java")) { - pl.onFileAddition(file); - javaFileList.add(file); - } - - } - } -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/InplaceFileConverter.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/InplaceFileConverter.java deleted file mode 100644 index b3a013c6b..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/InplaceFileConverter.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.slf4j.migrator; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; - -import org.slf4j.migrator.internal.ProgressListener; -import org.slf4j.migrator.line.LineConverter; -import org.slf4j.migrator.line.RuleSet; - -public class InplaceFileConverter { - - final static int BUFFER_LEN = 8 * 1024; - final LineConverter lineConverter; - final String lineTerminator; - final ProgressListener pl; - - InplaceFileConverter(RuleSet ruleSet, ProgressListener pl) { - this.lineConverter = new LineConverter(ruleSet); - lineTerminator = System.getProperty("line.separator"); - this.pl = pl; - } - - private byte[] readIntoByteArray(File file) throws IOException { - FileInputStream fis = new FileInputStream(file); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int n = 0; - byte[] buffer = new byte[BUFFER_LEN]; - while ((n = fis.read(buffer)) != -1) { - // System.out.println("ba="+new String(buffer, "UTF-8")); - baos.write(buffer, 0, n); - } - fis.close(); - return baos.toByteArray(); - } - - void convert(File file) throws IOException { - byte[] originalBytes = readIntoByteArray(file); - byte[] convertedBytes = convertIntoTempByteArray(originalBytes); - if (lineConverter.atLeastOneMatchOccured()) { - //System.out.println("Converting ["+file+"]"); - writeConvertedBytesIntoFile(file, convertedBytes); - pl.onInplaceConversion(file); - } else { - //System.out.println("Not touching ["+file+"]"); - } - } - - private void writeConvertedBytesIntoFile(File file, byte[] convertedBytes) throws IOException { - FileOutputStream fos = new FileOutputStream(file); - fos.write(convertedBytes); - fos.flush(); - fos.close(); - } - - private byte[] convertIntoTempByteArray(byte[] input) throws IOException { - ByteArrayInputStream bais = new ByteArrayInputStream(input); - Reader reader = new InputStreamReader(bais); - BufferedReader breader = new BufferedReader(reader); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - while (true) { - String line = breader.readLine(); - if (line != null) { - String[] replacement = lineConverter.getReplacement(line); - writeReplacement(baos, replacement); - } else { - break; - } - } - return baos.toByteArray(); - } - - private void writeReplacement(OutputStream os, String[] replacement) - throws IOException { - for (int i = 0; i < replacement.length; i++) { - os.write(replacement[i].getBytes()); - os.write(lineTerminator.getBytes()); - } - } -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/Main.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/Main.java deleted file mode 100644 index 9e4a06cb3..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/Main.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -package org.slf4j.migrator; - -import javax.swing.SwingUtilities; - -import org.slf4j.migrator.internal.MigratorFrame; - -/** - * Main entry point to the migrator. - * - * @author Ceki Gülcü - */ -public class Main { - - public static void main(String[] args) { - System.out.println("Starting SLF4J Migrator"); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - MigratorFrame inst = new MigratorFrame(); - inst.setLocationRelativeTo(null); - inst.setVisible(true); - } - }); - } - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java deleted file mode 100644 index c31301a2a..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.swing.SwingUtilities; - -import org.slf4j.migrator.internal.MigratorFrame; -import org.slf4j.migrator.internal.ProgressListener; -import org.slf4j.migrator.line.RuleSet; - -public class ProjectConverter { - - private RuleSet ruleSet; - private List exception; - - ProgressListener progressListener; - - public static void main(String[] args) throws IOException { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - MigratorFrame inst = new MigratorFrame(); - inst.setLocationRelativeTo(null); - inst.setVisible(true); - } - }); - } - - /** - * Ask for concrete matcher implementation depending on the conversion mode - * Ask for user confirmation to convert the selected source directory if valid - * Ask for user confirmation in case of number of files to convert > 1000 - * - * @return true if init operation complete - * @throws IOException - */ - public ProjectConverter(int conversionType, ProgressListener progressListener) { - this.progressListener = progressListener; - ruleSet = RuleSetFactory.getMatcherImpl(conversionType); - if (ruleSet == null) { - addException(new ConversionException(ConversionException.NOT_IMPLEMENTED)); - } - } - - public void convertProject(File folder) { - FileSelector fs = new FileSelector(progressListener); - List fileList = fs.selectJavaFilesInFolder(folder); - scanFileList(fileList); - progressListener.onDone(); - } - - /** - * Convert a list of files - * - * @param lstFiles - */ - private void scanFileList(List lstFiles) { - progressListener.onFileScanBegin(); - Iterator itFile = lstFiles.iterator(); - while (itFile.hasNext()) { - File currentFile = itFile.next(); - progressListener.onFileScan(currentFile); - scanFile(currentFile); - } - } - - /** - * Convert the specified file Read each line and ask matcher implementation - * for conversion Rewrite the line returned by matcher - * - * @param file - */ - private void scanFile(File file) { - try { - InplaceFileConverter fc = new InplaceFileConverter(ruleSet, - progressListener); - fc.convert(file); - } catch (IOException exc) { - addException(new ConversionException(exc.toString())); - } - } - - public void addException(ConversionException exc) { - if (exception == null) { - exception = new ArrayList(); - } - exception.add(exc); - } - - public void printException() { - if (exception != null) { - Iterator iterator = exception.iterator(); - while (iterator.hasNext()) { - ConversionException exc = (ConversionException) iterator.next(); - exc.print(); - } - exception = null; - } - } -} \ No newline at end of file diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/RuleSetFactory.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/RuleSetFactory.java deleted file mode 100644 index 0fbd62aed..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/RuleSetFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.slf4j.migrator; - -import org.slf4j.migrator.line.EmptyRuleSet; -import org.slf4j.migrator.line.JCLRuleSet; -import org.slf4j.migrator.line.JULRuleSet; -import org.slf4j.migrator.line.Log4jRuleSet; -import org.slf4j.migrator.line.RuleSet; - -/** - * This class runs Pattern matching with java.util.regex using Patterns defined - * in concrete implementations - * - * @author jean-noelcharpin - * - */ -public abstract class RuleSetFactory { - - /** - * Return matcher implementation depending on the conversion mode - * - * @param conversionType - * @return AbstractMatcher implementation - */ - public static RuleSet getMatcherImpl(int conversionType) { - switch (conversionType) { - case Constant.JCL_TO_SLF4J: - return new JCLRuleSet(); - case Constant.LOG4J_TO_SLF4J: - return new Log4jRuleSet(); - case Constant.JUL_TO_SLF4J: - return new JULRuleSet(); - case Constant.NOP_TO_SLF4J: - return new EmptyRuleSet(); - default: - return null; - } - } -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/Abbreviator.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/Abbreviator.java deleted file mode 100644 index d22b6b8b8..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/Abbreviator.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.slf4j.migrator.helper; - -public class Abbreviator { - static final String FILLER = "..."; - - final char folderSeparator; - final int invariantPrefixLength; - final int desiredLength; - - public Abbreviator(int invariantPrefixLength, int desiredLength, - char folderSeparator) { - this.invariantPrefixLength = invariantPrefixLength; - this.desiredLength = desiredLength; - this.folderSeparator = folderSeparator; - } - - public String abbreviate(String filename) { - if (filename.length() <= desiredLength) { - return filename; - } else { - - int firstIndex = filename.indexOf(folderSeparator, invariantPrefixLength); - if (firstIndex == -1) { - // we cant't process this string - return filename; - } - StringBuffer buf = new StringBuffer(desiredLength); - buf.append(filename.substring(0, firstIndex + 1)); - buf.append(FILLER); - int nextIndex = computeNextIndex(filename, firstIndex); - if (nextIndex != -1) { - buf.append(filename.substring(nextIndex)); - } else { - // better long than wrong - return filename; - } - - if (buf.length() < filename.length()) { - return buf.toString(); - } else { - // we tried our best but we are still could not shorten the input - return filename; - } - } - } - - int computeNextIndex(String filename, int firstIndex) { - int nextIndex = firstIndex + 1; - int hitCount = 0; - int minToRemove = filename.length() - desiredLength + FILLER.length(); - while (nextIndex < firstIndex + minToRemove) { - int tmpIndex = filename.indexOf(folderSeparator, nextIndex + 1); - if (tmpIndex == -1) { - if (hitCount == 0) { - return -1; - } else { - return nextIndex; - } - } else { - hitCount++; - nextIndex = tmpIndex; - } - } - return nextIndex; - } -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/SpringLayoutHelper.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/SpringLayoutHelper.java deleted file mode 100644 index 6f0316740..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/helper/SpringLayoutHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.slf4j.migrator.helper; - -import java.awt.Component; - -import javax.swing.SpringLayout; - -public class SpringLayoutHelper { - - - final SpringLayout sl; - final int basicPadding; - - public SpringLayoutHelper(SpringLayout springLayout, int basicPadding) { - sl = springLayout; - this.basicPadding = basicPadding; - } - - public void placeToTheRight(Component relativeTo, Component componentToPlace, int horizontalPadding, int verticalPadding) { - sl.putConstraint(SpringLayout.WEST, componentToPlace, horizontalPadding, - SpringLayout.EAST, relativeTo); - - sl.putConstraint(SpringLayout.NORTH, componentToPlace, verticalPadding, - SpringLayout.NORTH, relativeTo); - } - - public void placeToTheRight(Component relativeTo, Component componentToPlace) { - placeToTheRight(relativeTo, componentToPlace, basicPadding, 0); - } - - public void placeBelow(Component relativeTo, Component componentToPlace) { - placeBelow(relativeTo, componentToPlace, 0, basicPadding); - } - - public void placeBelow(Component relativeTo, Component componentToPlace, int horizontalPadding, int verticalPadding) { - sl.putConstraint(SpringLayout.WEST, componentToPlace, horizontalPadding, - SpringLayout.WEST, relativeTo); - - sl.putConstraint(SpringLayout.NORTH, componentToPlace, verticalPadding, - SpringLayout.SOUTH, relativeTo); - } - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ConversionTask.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ConversionTask.java deleted file mode 100644 index e16347f00..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ConversionTask.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.internal; - -import java.io.File; - -import org.slf4j.migrator.ProjectConverter; - -public class ConversionTask implements Runnable { - - final File folder; - final MigratorFrame frame; - final int conversionType; - - - ConversionTask(File folder, MigratorFrame frame, int conversionType) { - this.folder = folder; - this.frame = frame; - this.conversionType = conversionType; - } - - public void run() { - ProgressListener pl = new ProgressListenerImpl(folder, frame); - pl.onMigrationBegin(); - ProjectConverter converter = new ProjectConverter(conversionType, pl); - converter.convertProject(folder); - } - - public void launch() { - Thread t = new Thread(this); - t.setDaemon(true); - t.start(); - } - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/MigratorFrame.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/MigratorFrame.java deleted file mode 100644 index 87b2838cd..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/MigratorFrame.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.internal; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JProgressBar; -import javax.swing.JRadioButton; -import javax.swing.JTextField; -import javax.swing.SpringLayout; -import javax.swing.WindowConstants; - -import org.slf4j.migrator.Constant; -import org.slf4j.migrator.helper.SpringLayoutHelper; - -/** - * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI - * Builder, which is free for non-commercial use. If Jigloo is being used - * commercially (ie, by a corporation, company or business for any purpose - * whatever) then you should purchase a license for each developer using Jigloo. - * Please visit www.cloudgarden.com for details. Use of Jigloo implies - * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN - * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR - * ANY CORPORATE OR COMMERCIAL PURPOSE. - */ -public class MigratorFrame extends JFrame implements ActionListener { - private static final long serialVersionUID = 1L; - - private static final int BASIC_PADDING = 10; - private static final int FOLDER_COLUMNS = 40; - private static final String MIGRATE_COMMAND = "MIGRATE_COMMAND"; - private static final String BROWSE_COMMAND = "BROWSE_COMMAND"; - static final String EXIT_COMMAND = "EXIT_COMMAND"; - - static final int X_SIZE = 700; - static final int Y_SIZE = 400; - - private SpringLayout layoutManager = new SpringLayout(); - private SpringLayoutHelper slh = new SpringLayoutHelper(layoutManager, - BASIC_PADDING); - - private JLabel migrationLabel; - - private JRadioButton radioLog4j; - private JRadioButton radioJCL; - private JRadioButton radioJUL; - private ButtonGroup buttonGroup; - - private JTextField folderTextField; - private JLabel warningLabel; - JButton migrateButton; - private JButton browseButton; - private JLabel folderLabel; - - private JCheckBox awareCheckBox; - private JLabel awareLabel; - - JLabel otherLabel; - JProgressBar progressBar; - private JFileChooser fileChooser; - - public MigratorFrame() { - super(); - initGUI(); - } - - private void initGUI() { - try { - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - getContentPane().setLayout(layoutManager); - this.setTitle("SLF4J migrator"); - - createComponents(); - constrainAll(); - addAllComponentsToContextPane(); - pack(); - this.setSize(700, 400); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void createComponents() { - createMigrationLabel(); - createRadioJCL(); - createRadioLog4j(); - createRadioJUL(); - createButtonGroup(); - createFolderLabel(); - createFolderTextField(); - createBrowseButton(); - createMigrateButton(); - createAwareCheckbox(); - createAwareLabel(); - createWarningLabel(); - createFileChooser(); - - otherLabel = new JLabel(); - otherLabel.setText(""); - createProgressBar(); - - } - - /** - * - */ - private void constrainAll() { - - // contrain migration label - layoutManager.putConstraint(SpringLayout.WEST, migrationLabel, - BASIC_PADDING, SpringLayout.EAST, this); - - layoutManager.putConstraint(SpringLayout.NORTH, migrationLabel, - BASIC_PADDING, SpringLayout.NORTH, this); - - slh.placeToTheRight(migrationLabel, radioJCL, BASIC_PADDING, - -BASIC_PADDING / 2); - slh.placeBelow(radioJCL, radioLog4j, 0, 0); - - slh.placeBelow(radioLog4j, radioJUL, 0, 0); - - - slh.placeBelow(migrationLabel, folderLabel, 0, BASIC_PADDING * 6); - slh.placeToTheRight(folderLabel, folderTextField); - slh.placeToTheRight(folderTextField, browseButton, BASIC_PADDING, - -BASIC_PADDING / 2); - - slh.placeBelow(folderLabel, warningLabel, 0, BASIC_PADDING * 3); - - slh.placeBelow(warningLabel, awareCheckBox, 0, (int) (BASIC_PADDING * 1.5)); - slh.placeToTheRight(awareCheckBox, awareLabel); - - slh.placeBelow(awareCheckBox, migrateButton, 0, BASIC_PADDING * 3); - - slh.placeBelow(migrateButton, otherLabel, 0, BASIC_PADDING * 2); - - slh.placeBelow(otherLabel, progressBar, 0, BASIC_PADDING); - } - - private void addAllComponentsToContextPane() { - getContentPane().add(migrationLabel); - getContentPane().add(radioJCL); - getContentPane().add(radioLog4j); - getContentPane().add(radioJUL); - - getContentPane().add(folderLabel); - getContentPane().add(folderTextField); - getContentPane().add(browseButton); - getContentPane().add(migrateButton); - - getContentPane().add(awareCheckBox); - getContentPane().add(awareLabel); - - getContentPane().add(warningLabel); - - getContentPane().add(otherLabel); - getContentPane().add(progressBar); - } - - private void createButtonGroup() { - buttonGroup = new ButtonGroup(); - buttonGroup.add(radioJCL); - buttonGroup.add(radioLog4j); - buttonGroup.add(radioJUL); - } - - private void createMigrationLabel() { - migrationLabel = new JLabel(); - migrationLabel.setText("Migration Type"); - } - - private void createRadioJCL() { - radioJCL = new JRadioButton(); - radioJCL.setText("from Jakarta Commons Logging to SLF4J"); - radioJCL - .setToolTipText("Select this button if you wish to migrate a Java project using Jakarta Commons Logging to use SLF4J."); - } - - private void createRadioLog4j() { - radioLog4j = new JRadioButton(); - radioLog4j.setText("from log4j to SLF4J "); - radioLog4j - .setToolTipText("Select this button if you wish to migrate a Java project using log4j to use SLF4J."); - } - - private void createRadioJUL() { - radioJUL = new JRadioButton(); - radioJUL.setText("from JUL to SLF4J "); - radioJUL - .setToolTipText("Select this button if you wish to migrate a Java project using java.utl.logging (JUL) to use SLF4J."); - } - private void createFolderLabel() { - folderLabel = new JLabel(); - folderLabel.setText("Project Directory"); - } - - private void createFolderTextField() { - folderTextField = new JTextField(); - folderTextField.setColumns(FOLDER_COLUMNS); - } - - private void createBrowseButton() { - browseButton = new JButton(); - browseButton.setText("Browse"); - browseButton.addActionListener(this); - browseButton.setActionCommand(BROWSE_COMMAND); - browseButton - .setToolTipText("Click this button to browse the file systems on your computer."); - } - - private void createAwareCheckbox() { - awareCheckBox = new JCheckBox(); - awareCheckBox - .setToolTipText("

Check this box of you understand that the migration tool

will not backup your Java source files."); - } - - private void createAwareLabel() { - awareLabel = new JLabel(); - awareLabel - .setText("" - + "

I am aware that this tool will directly modify all Java source files

" - + "

in the selected folder without creating backup files.

" - + ""); - } - - private void createWarningLabel() { - warningLabel = new JLabel(); - warningLabel - .setText("" - + "

WARNING: This SLF4J migration tool will directly modify all Java source files

" - + "

in the selected project folder without creating a backup of the original files.

" - + ""); - } - - private void createMigrateButton() { - migrateButton = new JButton(); - migrateButton.setText("Migrate Project to SLF4J"); - migrateButton - .setToolTipText("Click this button to initiate migration of your project."); - migrateButton.addActionListener(this); - migrateButton.setActionCommand(MIGRATE_COMMAND); - } - - private void createFileChooser() { - fileChooser = new JFileChooser(); - fileChooser.setDialogTitle("Source folder selector"); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - } - - private void createProgressBar() { - progressBar = new JProgressBar(0, 1); - progressBar - .setPreferredSize(new java.awt.Dimension((int) (X_SIZE * 0.8), 5)); - progressBar.setVisible(false); - } - - public void disableInput() { - radioJCL.setEnabled(false); - radioLog4j.setEnabled(false); - - browseButton.setEnabled(false); - - folderTextField.setEnabled(false); - awareCheckBox.setEnabled(false); - migrateButton.setText("Migration in progress"); - migrateButton.setEnabled(false); - - } - - public void actionPerformed(ActionEvent e) { - - if (MIGRATE_COMMAND.equals(e.getActionCommand())) { - - List errorList = doSanityAnalysis(); - if (errorList.size() > 0) { - showDialogBox(errorList); - } else { - - File projectFolder = new File(folderTextField.getText()); - int conversionType; - if(radioJCL.isSelected()) { - conversionType = Constant.JCL_TO_SLF4J; - } else if (radioLog4j.isSelected()) { - conversionType = Constant.LOG4J_TO_SLF4J; - } else if (radioJUL.isSelected()) { - conversionType = Constant.JUL_TO_SLF4J; - } else { - // we cannot possibly reach here - throw new IllegalStateException("One of JCL or log4j project must have been previously chosen."); - } - ConversionTask task = new ConversionTask(projectFolder, this, - conversionType); - task.launch(); - } - } else if (BROWSE_COMMAND.equals(e.getActionCommand())) { - showFileChooser(); - } else if (EXIT_COMMAND.equals(e.getActionCommand())) { - this.dispose(); - } - } - - void showFileChooser() { - int returnVal = fileChooser.showOpenDialog(this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File selectedFile = fileChooser.getSelectedFile(); - folderTextField.setText(selectedFile.getAbsolutePath()); - } - } - - List doSanityAnalysis() { - - List errorList = new ArrayList(); - if (!radioJCL.isSelected() && !radioLog4j.isSelected() && !radioJUL.isSelected()) { - errorList - .add("Please select the migration type: JCL, log4j, or JUL to SLF4J."); - } - - String folder = folderTextField.getText(); - - if (folder == null || folder.length() == 0) { - errorList.add("Please select the folder of the project to migrate"); - } else if (!isDirectory(folder)) { - errorList.add("[" + folder + "] does not look like a valid folder"); - } - - if (!awareCheckBox.isSelected()) { - errorList - .add("Cannot initiate migration unless you acknowledge

that files will be modified without creating backup files"); - } - return errorList; - } - - void showDialogBox(List errorList) { - StringBuffer buf = new StringBuffer(); - buf.append(""); - int i = 1; - for (String msg : errorList) { - buf.append("

"); - buf.append(i); - buf.append(". "); - buf.append(msg); - buf.append("

"); - i++; - } - buf.append(""); - - JOptionPane.showMessageDialog(this, buf.toString(), "", - JOptionPane.ERROR_MESSAGE); - } - - boolean isDirectory(String filename) { - if (filename == null) { - return false; - } - File file = new File(filename); - if (file.exists() && file.isDirectory()) { - return true; - } else { - return false; - } - } -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListener.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListener.java deleted file mode 100644 index 39f96b1db..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListener.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.internal; - -import java.io.File; - -public interface ProgressListener { - - public void onMigrationBegin(); - public void onDirectory(File file); - public void onFileAddition(File file); - public void onFileScanBegin(); - public void onFileScan(File file); - public void onInplaceConversion(File file); - public void onDone(); - -} - diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListenerImpl.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListenerImpl.java deleted file mode 100644 index 3048a4b5c..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListenerImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2004-2008 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.internal; - -import java.io.File; -import java.io.IOException; - -import org.slf4j.migrator.helper.Abbreviator; - -public class ProgressListenerImpl implements ProgressListener { - - static final int TARGET_FILE_LENGTH = 85; - static final int UPDATE_THRESHOLD = 100; - - int addFileCount = 0; - int scanFileCount = 0; - int inplaceConversionCount = 0; - final MigratorFrame frame; - - Abbreviator abbr; - - long lastUpdate = 0; - - - - public ProgressListenerImpl(File projectFolder, MigratorFrame frame) { - this.frame = frame; - this.abbr = new Abbreviator((int) projectFolder.length(), - TARGET_FILE_LENGTH, File.separatorChar); - } - - public void onMigrationBegin() { - frame.disableInput(); - } - - boolean isTooSoon() { - long now = System.currentTimeMillis(); - if(now-lastUpdate < UPDATE_THRESHOLD) { - return true; - } else { - lastUpdate = now; - return false; - } - } - - public void onDirectory(File file) { - if(isTooSoon()) return; - - String abbreviatedName = getShortName(file); - frame.otherLabel.setText("

Searching folder [" + abbreviatedName - + "]

Found " + addFileCount + " java files to scan."); - } - - public void onDone() { - frame.progressBar.setVisible(false); - frame.otherLabel.setText("Scanned " + addFileCount - + " java files, " + inplaceConversionCount - + " files were modified."); - - frame.migrateButton.setActionCommand(MigratorFrame.EXIT_COMMAND); - frame.migrateButton.setText("Exit"); - frame.migrateButton - .setToolTipText("Click on this button to exit this application."); - frame.migrateButton.setEnabled(true); - - } - - public void onFileAddition(File file) { - addFileCount++; - } - - public void onFileScan(File file) { - - scanFileCount++; - if(isTooSoon()) return; - String abbreviatedName = getShortName(file); - - frame.otherLabel.setText("

Scanning file [" + abbreviatedName - + "]

"); - // File + scanFileCount + " out of "+ addFileCount+" files to scan."+ - // inplaceConversionCount+ " files converted." + - - frame.progressBar.setValue(scanFileCount); - } - - public void onInplaceConversion(File file) { - inplaceConversionCount++; - } - - String getShortName(File file) { - try { - return abbr.abbreviate(file.getCanonicalPath()); - } catch (IOException e) { - return file.toString(); - } - } - - public void onFileScanBegin() { - frame.progressBar.setMaximum(addFileCount); - frame.progressBar.setValue(0); - frame.progressBar.setVisible(true); - } - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/ConversionRule.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/ConversionRule.java deleted file mode 100644 index 6b88c36a1..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/ConversionRule.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.line; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public interface ConversionRule { - - public Pattern getPattern(); - - /** - * Given replacement rules, replace each capturing group in matcher's pattern - * - * @param matcher - * @return String - */ - public String replace(Matcher matcher); - - /** - * Returns a non-null value if there should be an additional line - * following a match of this rule. In most cases this method - * returns null. - * - * @return String - */ - public String getAdditionalLine(); - -} \ No newline at end of file diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/EmptyRuleSet.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/EmptyRuleSet.java deleted file mode 100644 index 311d01701..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/EmptyRuleSet.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.slf4j.migrator.line; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class EmptyRuleSet implements RuleSet { - - List list = new ArrayList(); - - public Iterator iterator() { - return list.iterator(); - } - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JCLRuleSet.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JCLRuleSet.java deleted file mode 100644 index 983d40f38..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JCLRuleSet.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.slf4j.migrator.line; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.regex.Pattern; - - -/** - * This class represents JCL to SLF4J conversion rules - * - * @author Jean-Noel Charpin - * - */ -public class JCLRuleSet implements RuleSet { - - private ArrayList conversionRuleList; - - public JCLRuleSet() { - // matching : import org.apache.commons.logging.LogFactory; - SingleConversionRule cr0 = new SingleConversionRule(Pattern - .compile("import\\s*+org.apache.commons.logging.LogFactory;"), - "import org.slf4j.LoggerFactory;"); - - // matching : import org.apache.commons.logging.Log; - SingleConversionRule cr1 = new SingleConversionRule(Pattern - .compile("import\\s*+org.apache.commons.logging.Log;"), - "import org.slf4j.Logger;"); - - SingleConversionRule cr2 = new SingleConversionRule(Pattern - .compile("(\\sLog\\b)")," Logger"); - - SingleConversionRule cr3 = new SingleConversionRule(Pattern - .compile("(^Log\\b)"),"Logger"); - - SingleConversionRule cr4 = new SingleConversionRule(Pattern - .compile("LogFactory.getFactory\\(\\).getInstance\\("), - "LoggerFactory.getLogger("); - - SingleConversionRule cr5 = new SingleConversionRule(Pattern - .compile("LogFactory.getLog\\("),"LoggerFactory.getLogger("); - - - conversionRuleList = new ArrayList(); - conversionRuleList.add(cr0); - conversionRuleList.add(cr1); - conversionRuleList.add(cr2); - conversionRuleList.add(cr3); - conversionRuleList.add(cr4); - conversionRuleList.add(cr5); - } - - - public Iterator iterator() { - return conversionRuleList.iterator(); - } -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java deleted file mode 100644 index 9d13b6593..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.slf4j.migrator.line; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.regex.Pattern; - -/** - * This class represents java.util.logging (JUL) to SLF4J conversion rules - * - * @author Jean-Noel Charpin - * @author Ceki Gulcu - */ -public class JULRuleSet implements RuleSet { - - private ArrayList conversionRuleList; - - public JULRuleSet() { - - - SingleConversionRule crImport0 = new SingleConversionRule(Pattern - .compile("import\\s*+java.util.logging.Logger;"), - "import org.slf4j.Logger;", - "import org.slf4j.LoggerFactory;"); - - SingleConversionRule crImport1 = new SingleConversionRule(Pattern - .compile("import\\s*+org.apache.log4j.LogManager;"), - "import org.slf4j.LoggerFactory;"); - - SingleConversionRule crImport2 = new SingleConversionRule(Pattern - .compile("import\\s*+java.util.logging.*;"), - "import org.slf4j.Logger;", - "import org.slf4j.LoggerFactory;"); - - - SingleConversionRule crFactory0 = new SingleConversionRule(Pattern - .compile("Logger.getLogger\\("), "LoggerFactory.getLogger("); - - SingleConversionRule crFactory1 = new SingleConversionRule(Pattern - .compile("LogManager.getLogger\\("), "LoggerFactory.getLogger("); - - SingleConversionRule crWarning = new SingleConversionRule(Pattern - .compile("\\.warning\\("), ".warn("); - SingleConversionRule crSevere = new SingleConversionRule(Pattern - .compile("\\.severe\\("), ".error("); - - - conversionRuleList = new ArrayList(); - conversionRuleList.add(crImport0); - conversionRuleList.add(crImport1); - conversionRuleList.add(crImport2); - conversionRuleList.add(crFactory0); - conversionRuleList.add(crFactory1); - conversionRuleList.add(crWarning); - conversionRuleList.add(crSevere); - } - - public Iterator iterator() { - return conversionRuleList.iterator(); - } - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/LineConverter.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/LineConverter.java deleted file mode 100644 index 4749a64ee..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/LineConverter.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.slf4j.migrator.line; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -public class LineConverter { - - final RuleSet ruleSet; - boolean atLeastOneMatchOccured = false; - - public LineConverter(RuleSet ruleSet) { - this.ruleSet = ruleSet; - } - - /** - * Check if the specified text is matching some conversions rules. - * If a rule matches, ask for line replacement. - * - *

In case no rule can be applied, then the input text is - * returned without change. - * - * @param text - * @return String - */ - public String[] getReplacement(String text) { - ConversionRule conversionRule; - Pattern pattern; - Matcher matcher; - Iterator conversionRuleIterator = ruleSet.iterator(); - String additionalLine = null; - while (conversionRuleIterator.hasNext()) { - conversionRule = conversionRuleIterator.next(); - pattern = conversionRule.getPattern(); - matcher = pattern.matcher(text); - if (matcher.find()) { - // System.out.println("matching " + text); - atLeastOneMatchOccured = true; - String replacementText = conversionRule.replace(matcher); - text = matcher.replaceAll(replacementText); - if(conversionRule.getAdditionalLine() != null) { - additionalLine = conversionRule.getAdditionalLine(); - } - } - } - - if(additionalLine == null) { - return new String[] {text}; - } else { - return new String[] {text, additionalLine}; - } - } - - public String getOneLineReplacement(String text) { - String[] r = getReplacement(text); - if(r.length != 1) { - throw new IllegalStateException("Expecting a single string but got "+Arrays.toString(r)); - } else { - return r[0]; - } - } - public boolean atLeastOneMatchOccured() { - return atLeastOneMatchOccured; - } -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/Log4jRuleSet.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/Log4jRuleSet.java deleted file mode 100644 index 64586e4f1..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/Log4jRuleSet.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.slf4j.migrator.line; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.regex.Pattern; - - -public class Log4jRuleSet implements RuleSet { - - private ArrayList conversionRuleList; - - public Log4jRuleSet() { - - - SingleConversionRule crImport0 = new SingleConversionRule(Pattern - .compile("import\\s*+org.apache.log4j.Logger;"), - "import org.slf4j.Logger;", - "import org.slf4j.LoggerFactory;"); - - SingleConversionRule crImport1 = new SingleConversionRule(Pattern - .compile("import\\s*+org.apache.log4j.LogManager;"), - "import org.slf4j.LoggerFactory;"); - - SingleConversionRule crImport2 = new SingleConversionRule(Pattern - .compile("import\\s*+org.apache.log4j.*;"), - "import org.slf4j.Logger;", - "import org.slf4j.LoggerFactory;"); - - SingleConversionRule crImportMDC = new SingleConversionRule(Pattern - .compile("import\\s*+org.apache.log4j.MDC;"), - "import org.slf4j.MDC;"); - - - SingleConversionRule crFactory0 = new SingleConversionRule(Pattern - .compile("Logger.getLogger\\("), "LoggerFactory.getLogger("); - - SingleConversionRule crFactory1 = new SingleConversionRule(Pattern - .compile("LogManager.getLogger\\("), "LoggerFactory.getLogger("); - - conversionRuleList = new ArrayList(); - conversionRuleList.add(crImport0); - conversionRuleList.add(crImport1); - conversionRuleList.add(crImport2); - conversionRuleList.add(crImportMDC); - conversionRuleList.add(crFactory0); - conversionRuleList.add(crFactory1); - } - - public Iterator iterator() { - return conversionRuleList.iterator(); - } - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/MultiGroupConversionRule.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/MultiGroupConversionRule.java deleted file mode 100644 index 7a115f730..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/MultiGroupConversionRule.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.line; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -/** - * This class represents a conversion rule It uses a Pattern and defines for - * each capturing group of this Pattern a replacement text - * - * @author jean-noelcharpin - * - */ -public class MultiGroupConversionRule implements ConversionRule { - - // It is extremely unlikely to encounter more than 10 groups in one of - // our conversion reg-expressions - final private static int MAX_GROUPS = 10; - - private Pattern pattern; - private String[] replacementTable = new String[MAX_GROUPS]; - - public MultiGroupConversionRule(Pattern pattern) { - this.pattern = pattern; - } - - /* (non-Javadoc) - * @see org.slf4j.converter.ConversionRule#getPattern() - */ - public Pattern getPattern() { - return pattern; - } - - public void addReplacement(int groupIndex, String replacement) { - if(groupIndex == 0) { - throw new IllegalArgumentException("regex groups start at 1, not zero"); - } - replacementTable[groupIndex] = replacement; - } - - /* (non-Javadoc) - * @see org.slf4j.converter.ConversionRule#getReplacement(java.lang.Integer) - */ - public String getReplacement(int groupIndex) { - return replacementTable[groupIndex]; - } - - /* (non-Javadoc) - * @see org.slf4j.converter.ConversionRule#replace(java.util.regex.Matcher) - */ - public String replace(Matcher matcher) { - StringBuffer replacementBuffer = new StringBuffer(); - String replacementText; - - for (int group = 1; group <= matcher.groupCount(); group++) { - replacementText = getReplacement(group); - if (replacementText != null) { - //System.out.println("replacing group " + group + " : " - // + matcher.group(group) + " with " + replacementText); - replacementBuffer.append(replacementText); - } else { - replacementBuffer.append(matcher.group(group)); - } - } - return replacementBuffer.toString(); - } - - public String getAdditionalLine() { - return null; - } -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/RuleSet.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/RuleSet.java deleted file mode 100644 index be11f294f..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/RuleSet.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.slf4j.migrator.line; - -import java.util.Iterator; - - -public interface RuleSet { - - Iterator iterator(); - -} diff --git a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/SingleConversionRule.java b/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/SingleConversionRule.java deleted file mode 100644 index 492a92d70..000000000 --- a/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/SingleConversionRule.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.line; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -/** - * This class represents a conversion rule It uses a Pattern and defines for - * each capturing group of this Pattern a replacement text - * - * @author jean-noelcharpin - * - */ -public class SingleConversionRule implements ConversionRule { - - final private Pattern pattern; - final private String replacementText ; - final private String additionalLine; - - public SingleConversionRule(Pattern pattern, String replacementText) { - this(pattern, replacementText, null); - } - - public SingleConversionRule(Pattern pattern, String replacementText, String additionalLine) { - this.pattern = pattern; - this.replacementText = replacementText; - this.additionalLine = additionalLine; - } - - /* (non-Javadoc) - * @see org.slf4j.converter.ConversionRule#getPattern() - */ - public Pattern getPattern() { - return pattern; - } - - - - /* (non-Javadoc) - * @see org.slf4j.converter.ConversionRule#replace(java.util.regex.Matcher) - */ - public String replace(Matcher matcher) { - return replacementText; - } - - public String getAdditionalLine() { - return additionalLine; - } - -} diff --git a/trunk/slf4j-migrator/src/main/resources/META-INF/MANIFEST.MF b/trunk/slf4j-migrator/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 10f5bdf34..000000000 --- a/trunk/slf4j-migrator/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1 +0,0 @@ -Main-Class: org.slf4j.migrator.Main \ No newline at end of file diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/AllTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/AllTest.java deleted file mode 100644 index 320435453..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/AllTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class AllTest extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(org.slf4j.migrator.PackageTest.suite()); - suite.addTest(org.slf4j.migrator.line.PackageTest.suite()); - suite.addTest(org.slf4j.migrator.helper.PackageTest.suite()); - - return suite; - } -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java deleted file mode 100644 index 5c99edda3..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.slf4j.migrator; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.slf4j.migrator.line.MultiGroupConversionRule; - -import junit.framework.TestCase; - -public class AternativeApproach extends TestCase { - - /** - * In this test we see that we cans use more simple Pattern to do the - * conversion - * - */ - public void test() { - MultiGroupConversionRule cr2 = new MultiGroupConversionRule(Pattern - .compile("(.*)(Log)")); - cr2.addReplacement(2, "LOGGER"); - - String s = "abcd Log"; - Pattern pat = cr2.getPattern(); - Matcher m = pat.matcher(s); - - assertTrue(m.matches()); - String r = cr2.replace(m); - assertEquals("abcd LOGGER", r); - - System.out.println(r); - } - - /** - * In this test we replace, using the simple Pattern (Log), the full Log - * declaration and instanciation. This is not convenient because we will also - * replace all String containing "Log". - */ - public void test2() { - Pattern pat = Pattern.compile("(Log)"); - String s = "abcd Log ="; - Matcher m = pat.matcher(s); - assertTrue(m.find()); - String r = m.replaceAll("Logger"); - assertEquals("abcd Logger =", r); - - String s1 = "Log l = LogFactory.getLog(MyClass.class);"; - m = pat.matcher(s1); - assertTrue(m.find()); - r = m.replaceAll("Logger"); - assertEquals("Logger l = LoggerFactory.getLogger(MyClass.class);", r); - - String s2 = "Logabc "; - m = pat.matcher(s2); - assertTrue(m.find()); - - String s3 = "abcLog"; - m = pat.matcher(s3); - assertTrue(m.find()); - } - - /** - * In this test we use a simple Pattern to replace the log instanciation - * without influence on Log declaration. - * - */ - public void test3() { - Pattern pat = Pattern.compile("LogFactory.getFactory\\(\\).getInstance\\("); - String s = "Log log = LogFactory.getFactory().getInstance(\"x\");"; - Matcher m = pat.matcher(s); - assertTrue(m.find()); - String r = m.replaceAll("LoggerFactory.getLogger("); - assertEquals("Log log = LoggerFactory.getLogger(\"x\");", r); - - String nonMatching = "Log log = xxx;"; - pat.matcher(nonMatching); - assertFalse(m.find()); - } - - /** - * In this test we try to replace keyword Log without influence on String - * containg Log We see that we have to use two differents Patterns - */ - public void test4() { - Pattern pat = Pattern.compile("(\\sLog\\b)"); - String s = "abcd Log ="; - Matcher m = pat.matcher(s); - assertTrue(m.find()); - String r = m.replaceAll(" Logger"); - assertEquals("abcd Logger =", r); - - String s2 = "Logabcd "; - m = pat.matcher(s2); - assertFalse(m.find()); - - String s3 = "abcdLogabcd "; - m = pat.matcher(s3); - assertFalse(m.find()); - - String s4 = "abcdLog"; - m = pat.matcher(s4); - assertFalse(m.find()); - - String s5 = "Log myLog"; - m = pat.matcher(s5); - assertFalse(m.find()); - - Pattern pat2 = Pattern.compile("^Log\\b"); - Matcher m2 = pat2.matcher(s5); - assertTrue(m2.find()); - r = m2.replaceAll("Logger"); - assertEquals("Logger myLog", r); - } - - /** - * In this test we combine two Pattern to achieve the intended conversion - */ - public void test5() { - Pattern pat = Pattern.compile("(\\sLog\\b)"); - String s = "public Log myLog =LogFactory.getFactory().getInstance(myClass.class);"; - Matcher m = pat.matcher(s); - assertTrue(m.find()); - String r = m.replaceAll(" Logger"); - assertEquals("public Logger myLog =LogFactory.getFactory().getInstance(myClass.class);", r); - - Pattern pat2 = Pattern.compile("LogFactory.getFactory\\(\\).getInstance\\("); - m = pat2.matcher(r); - assertTrue(m.find()); - r = m.replaceAll("LoggerFactory.getLogger("); - assertEquals("public Logger myLog =LoggerFactory.getLogger(myClass.class);", r); - } -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/FileConverterTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/FileConverterTest.java deleted file mode 100644 index 7b76bdf87..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/FileConverterTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.slf4j.migrator; - -import java.io.File; -import java.io.IOException; - -import junit.framework.TestCase; - -import org.slf4j.migrator.InplaceFileConverter; -import org.slf4j.migrator.internal.NopProgressListener; -import org.slf4j.migrator.line.EmptyRuleSet; - -public class FileConverterTest extends TestCase { - - public FileConverterTest(String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void test() { - } - - - public void XtestNOP() throws IOException { - InplaceFileConverter fc = new InplaceFileConverter(new EmptyRuleSet(), new NopProgressListener()); - fc.convert(new File("c:/varargs.txt")); - } -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/PackageTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/PackageTest.java deleted file mode 100644 index 080c69364..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/PackageTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class PackageTest extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTestSuite(AternativeApproach.class); - return suite; - } -} \ No newline at end of file diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/ProjectConverterTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/ProjectConverterTest.java deleted file mode 100644 index 47128f9e5..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/ProjectConverterTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.slf4j.migrator; - -import java.io.File; - -import org.slf4j.migrator.Constant; -import org.slf4j.migrator.ProjectConverter; -import org.slf4j.migrator.internal.NopProgressListener; - -import junit.framework.TestCase; - -public class ProjectConverterTest extends TestCase { - - public void test() { - } - - public void XtestBarracuda() { - ProjectConverter pc = new ProjectConverter(Constant.LOG4J_TO_SLF4J, - new NopProgressListener()); - File projectFolder = new File("c:/home/ceki//Varia/Barracuda"); - pc.convertProject(projectFolder); - } -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/AbbreviatorTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/AbbreviatorTest.java deleted file mode 100644 index d485b5762..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/AbbreviatorTest.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.slf4j.migrator.helper; - -import org.slf4j.migrator.helper.Abbreviator; - -import junit.framework.TestCase; - -public class AbbreviatorTest extends TestCase { - - static final char FS = '/'; - static final String INPUT_0 = "/abc/123456/ABC"; - static final String INPUT_1 = "/abc/123456/xxxxx/ABC"; - - RandomHelper rh = new RandomHelper(FS); - - public AbbreviatorTest(String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testSmoke() { - { - Abbreviator abb = new Abbreviator(2, 100, FS); - String r = abb.abbreviate(INPUT_0); - assertEquals(INPUT_0, r); - } - - { - Abbreviator abb = new Abbreviator(3, 8, FS); - String r = abb.abbreviate(INPUT_0); - assertEquals("/abc/.../ABC", r); - } - { - Abbreviator abb = new Abbreviator(3, 8, FS); - String r = abb.abbreviate(INPUT_0); - assertEquals("/abc/.../ABC", r); - } - } - - public void testImpossibleToAbbreviate() { - Abbreviator abb = new Abbreviator(2, 20, FS); - String in = "iczldqwivpgm/mgrmvbjdxrwmqgprdjusth"; - String r = abb.abbreviate(in); - assertEquals(in, r); - } - - public void testNoFS() { - Abbreviator abb = new Abbreviator(2, 100, FS); - String r = abb.abbreviate("hello"); - assertEquals("hello", r); - - } - - public void testZeroPrefix() { - { - Abbreviator abb = new Abbreviator(0, 100, FS); - String r = abb.abbreviate(INPUT_0); - assertEquals(INPUT_0, r); - } - } - - public void testTheories() { - int MAX_RANDOM_FIXED_LEN = 20; - int MAX_RANDOM_AVG_LEN = 20; - int MAX_RANDOM_MAX_LEN = 100; - for (int i = 0; i < 10000; i++) { - - //System.out.println("Test number " + i); - - // 0 <= fixedLen < MAX_RANDOM_FIXED_LEN - int fixedLen = rh.nextInt(MAX_RANDOM_FIXED_LEN); - // 5 <= averageLen < MAX_RANDOM_AVG_LEN - int averageLen = rh.nextInt(MAX_RANDOM_AVG_LEN) + 3; - // System.out.println("fixedLen="+fixedLen+", averageLen="+averageLen); - - int maxLen = rh.nextInt(MAX_RANDOM_MAX_LEN) + fixedLen; - if (maxLen <= 1) { - continue; - } - // System.out.println("maxLen="+maxLen); - int targetLen = (maxLen / 2) + rh.nextInt(maxLen / 2) + 1; - - if (targetLen > maxLen) { - targetLen = maxLen; - } - String filename = rh.buildRandomFileName(averageLen, maxLen); - - Abbreviator abb = new Abbreviator(fixedLen, targetLen, FS); - String result = abb.abbreviate(filename); - assertTheory0(averageLen, filename, result, fixedLen, targetLen); - assertUsefulness(averageLen, filename, result, fixedLen, targetLen); - assertTheory1(filename, result, fixedLen, targetLen); - assertTheory2(filename, result, fixedLen, targetLen); - } - } - - // result length is smaller than original length - void assertTheory0(int averageLen, String filename, String result, - int fixedLen, int targetLength) { - assertTrue("filename=[" + filename + "] result=[" + result + "]", result - .length() <= filename.length()); - } - - // if conditions allow, result length should be to target length - void assertUsefulness(int averageLen, String filename, String result, - int fixedLen, int targetLength) { - int resLen = result.length(); - - int margin = averageLen * 4; - if (targetLength > fixedLen + margin) { - assertTrue("filename=[" + filename + "], result=[" + result - + "] resultLength=" + resLen + " fixedLength=" + fixedLen - + ", targetLength=" + targetLength + ", avgLen=" + averageLen, result - .length() <= targetLength + averageLen); - } - } - - // result start with prefix found in filename - void assertTheory1(String filename, String result, int fixedLen, - int targetLength) { - String prefix = filename.substring(0, fixedLen); - assertTrue(result.startsWith(prefix)); - } - - // The string /.../ is found in the result once at a position higher - // than fixedLen - void assertTheory2(String filename, String result, int fixedLen, - int targetLength) { - if (filename == result) { - return; - } - int fillerIndex = result.indexOf(Abbreviator.FILLER); - assertTrue(fillerIndex >= fixedLen); - } -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/PackageTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/PackageTest.java deleted file mode 100644 index 79b5dc2cf..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/PackageTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.helper; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class PackageTest extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTestSuite(AbbreviatorTest.class); - return suite; - } -} \ No newline at end of file diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/RandomHelper.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/RandomHelper.java deleted file mode 100644 index 7da5faedb..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/helper/RandomHelper.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.slf4j.migrator.helper; - -import java.util.Random; - -public class RandomHelper { - - private Random random = new Random(100); - final char folderSeparator; - - RandomHelper(char folderSeparator) { - this.folderSeparator = folderSeparator; - } - - private String randomString(int len) { - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < len; i++) { - int offset = random.nextInt(26); - char c = (char) ('a' + offset); - buf.append(c); - } - return buf.toString(); - } - - int nextInt(int n) { - return random.nextInt(n); - } - - String buildRandomFileName(int averageNodeLength, int totalLength) { - StringBuffer buf = new StringBuffer(); - int MAX_NODE_LENGTH = averageNodeLength * 2; - while (buf.length() < totalLength) { - int remaining = totalLength - buf.length(); - int currentNodeLength; - if (remaining > MAX_NODE_LENGTH) { - currentNodeLength = random.nextInt(MAX_NODE_LENGTH) + 1; - buf.append(randomString(currentNodeLength)); - buf.append('/'); - } else { - currentNodeLength = remaining; - buf.append(randomString(currentNodeLength)); - } - } - return buf.toString(); - } - -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/internal/NopProgressListener.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/internal/NopProgressListener.java deleted file mode 100644 index 51a239a65..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/internal/NopProgressListener.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.slf4j.migrator.internal; - -import java.io.File; - -import org.slf4j.migrator.internal.ProgressListener; - -public class NopProgressListener implements ProgressListener { - - public void onDirectory(File file) { - } - - public void onDone() { - } - - public void onFileAddition(File file) { - } - - public void onFileScan(File file) { - } - - public void onInplaceConversion(File file) { - } - - public void onFileScanBegin() { - } - - public void onMigrationBegin() { - } - -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/JCLRuleSetTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/JCLRuleSetTest.java deleted file mode 100644 index 45c951be8..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/JCLRuleSetTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.slf4j.migrator.line; - -import org.slf4j.migrator.line.JCLRuleSet; -import org.slf4j.migrator.line.LineConverter; - -import junit.framework.TestCase; - -public class JCLRuleSetTest extends TestCase { - - LineConverter jclConverter = new LineConverter(new JCLRuleSet()); - - public void testImportReplacement() { - // LogFactory import replacement - assertEquals("import org.slf4j.LoggerFactory;", jclConverter - .getOneLineReplacement("import org.apache.commons.logging.LogFactory;")); - // Log import replacement - assertEquals("import org.slf4j.Logger;", jclConverter - .getOneLineReplacement("import org.apache.commons.logging.Log;")); - } - - public void testLogFactoryGetLogReplacement() { - // Logger declaration and instanciation without modifier - assertEquals(" Logger l = LoggerFactory.getLogger(MyClass.class);", - jclConverter - .getOneLineReplacement(" Log l = LogFactory.getLog(MyClass.class);")); - // Logger declaration and instanciation with one modifier - assertEquals( - "public Logger mylog=LoggerFactory.getLogger(MyClass.class);", - jclConverter - .getOneLineReplacement("public Log mylog=LogFactory.getLog(MyClass.class);")); - // Logger declaration and instanciation with two modifier - assertEquals( - "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);", - jclConverter - .getOneLineReplacement("public static Log mylog1 = LogFactory.getLog(MyClass.class);")); - // Logger declaration and instanciation with two modifier and comment at the - // end of line - assertEquals( - "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class); //logger instanciation and declaration", - jclConverter - .getOneLineReplacement("public static Log mylog1 = LogFactory.getLog(MyClass.class); //logger instanciation and declaration")); - // Logger instanciation without declaration and comment at the end of line - assertEquals( - " myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation", - jclConverter - .getOneLineReplacement(" myLog = LogFactory.getLog(MyClass.class);//logger instanciation")); - // commented Logger declaration and instanciation with two modifier - assertEquals( - "//public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);", - jclConverter - .getOneLineReplacement("//public static Log mylog1 = LogFactory.getLog(MyClass.class);")); - // commented Logger instanciation without declaration - assertEquals( - "// myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation", - jclConverter - .getOneLineReplacement("// myLog = LogFactory.getLog(MyClass.class);//logger instanciation")); - } - - public void testLogFactoryGetFactoryReplacement() { - - // Logger declaration and instanciation without modifier - assertEquals( - "Logger l = LoggerFactory.getLogger(MyClass.class);", - jclConverter - .getOneLineReplacement("Log l = LogFactory.getFactory().getInstance(MyClass.class);")); - // Logger declaration and instanciation with one modifier - assertEquals( - "public Logger mylog=LoggerFactory.getLogger(MyClass.class);", - jclConverter - .getOneLineReplacement("public Log mylog=LogFactory.getFactory().getInstance(MyClass.class);")); - // Logger declaration and instanciation with modifiers - assertEquals( - "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);", - jclConverter - .getOneLineReplacement("public static Log mylog1 = LogFactory.getFactory().getInstance(MyClass.class);")); - // Logger declaration and instanciation with two modifier and comment at the - // end of line - assertEquals( - "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class); //logger instanciation and declaration", - jclConverter - .getOneLineReplacement("public static Log mylog1 = LogFactory.getFactory().getInstance(MyClass.class); //logger instanciation and declaration")); - // Logger instanciation without declaration and comment at the end of line - assertEquals( - " myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation", - jclConverter - .getOneLineReplacement(" myLog = LogFactory.getFactory().getInstance(MyClass.class);//logger instanciation")); - // commented Logger declaration and instanciation with two modifier - assertEquals( - "//public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);", - jclConverter - .getOneLineReplacement("//public static Log mylog1 = LogFactory.getFactory().getInstance(MyClass.class);")); - // commented Logger instanciation without declaration - assertEquals( - "// myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation", - jclConverter - .getOneLineReplacement("// myLog = LogFactory.getFactory().getInstance(MyClass.class);//logger instanciation")); - } - - public void testLogDeclarationReplacement() { - - // simple Logger declaration - assertEquals("Logger mylog;", jclConverter.getOneLineReplacement("Log mylog;")); - // Logger declaration with a modifier - assertEquals("private Logger mylog;", jclConverter - .getOneLineReplacement("private Log mylog;")); - - // Logger declaration with modifiers - assertEquals("public static final Logger myLog;", jclConverter - .getOneLineReplacement("public static final Log myLog;")); - // Logger declaration with modifiers and comment at the end of line - assertEquals("public Logger myLog;//logger declaration", jclConverter - .getOneLineReplacement("public Log myLog;//logger declaration")); - // commented Logger declaration - assertEquals("//private Logger myLog;", jclConverter - .getOneLineReplacement("//private Log myLog;")); - } - - public void testMultiLineReplacement() { - // Logger declaration on a line - assertEquals("protected Logger log =", jclConverter - .getOneLineReplacement("protected Log log =")); - - // Logger instanciation on the next line - assertEquals(" LoggerFactory.getLogger(MyComponent.class);", jclConverter - .getOneLineReplacement(" LogFactory.getLog(MyComponent.class);")); - // Logger declaration on a line - assertEquals("protected Logger log ", jclConverter - .getOneLineReplacement("protected Log log ")); - // Logger instanciation on the next line - assertEquals( - " = LoggerFactory.getLogger(MyComponent.class);", - jclConverter - .getOneLineReplacement(" = LogFactory.getFactory().getInstance(MyComponent.class);")); - } -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/Log4jRuleSetTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/Log4jRuleSetTest.java deleted file mode 100644 index 0979380c8..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/Log4jRuleSetTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.slf4j.migrator.line; - -import java.util.Arrays; - -import org.slf4j.migrator.line.LineConverter; -import org.slf4j.migrator.line.Log4jRuleSet; - -import junit.framework.TestCase; - -public class Log4jRuleSetTest extends TestCase { - - LineConverter log4jConverter = new LineConverter(new Log4jRuleSet()); - - public void testImportReplacement() { - // LogFactory import replacement - assertEquals("import org.slf4j.LoggerFactory;", log4jConverter - .getOneLineReplacement("import org.apache.log4j.LogManager;")); - // Log import replacement - assertTrue(Arrays.equals( - new String[] {"import org.slf4j.Logger;", "import org.slf4j.LoggerFactory;" }, - log4jConverter.getReplacement("import org.apache.log4j.Logger;"))); - } - - public void testLogManagerGetLoggerReplacement() { - // Logger declaration and instanciation without modifier - assertEquals(" Logger l = LoggerFactory.getLogger(MyClass.class);", - log4jConverter - .getOneLineReplacement(" Logger l = LogManager.getLogger(MyClass.class);")); - // Logger declaration and instanciation with one modifier - assertEquals( - "public Logger mylog=LoggerFactory.getLogger(MyClass.class);", - log4jConverter - .getOneLineReplacement("public Logger mylog=LogManager.getLogger(MyClass.class);")); - // Logger declaration and instanciation with two modifier - assertEquals( - "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);", - log4jConverter - .getOneLineReplacement("public static Logger mylog1 = LogManager.getLogger(MyClass.class);")); - // Logger declaration and instanciation with two modifier and comment at the - // end of line - assertEquals( - "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);//logger instanciation and declaration", - log4jConverter - .getOneLineReplacement("public static Logger mylog1 = LogManager.getLogger(MyClass.class);//logger instanciation and declaration")); - // Logger instanciation without declaration and comment at the end of line - assertEquals( - " myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation", - log4jConverter - .getOneLineReplacement(" myLog = LogManager.getLogger(MyClass.class);//logger instanciation")); - // commented Logger declaration and instanciation with two modifier - assertEquals( - "//public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);", - log4jConverter - .getOneLineReplacement("//public static Logger mylog1 = LogManager.getLogger(MyClass.class);")); - // commented Logger instanciation without declaration - assertEquals( - "// myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation", - log4jConverter - .getOneLineReplacement("// myLog = LogManager.getLogger(MyClass.class);//logger instanciation")); - } - - public void testLoggerGetLoggerReplacement() { - // Logger declaration and instanciation without modifier - assertEquals("Logger l = LoggerFactory.getLogger(MyClass.class);", - log4jConverter - .getOneLineReplacement("Logger l = Logger.getLogger(MyClass.class);")); - // Logger declaration and instanciation with one modifier - assertEquals( - "public Logger mylog=LoggerFactory.getLogger(MyClass.class);", - log4jConverter - .getOneLineReplacement("public Logger mylog=Logger.getLogger(MyClass.class);")); - // Logger declaration and instanciation with modifiers - assertEquals( - "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);", - log4jConverter - .getOneLineReplacement("public static Logger mylog1 = Logger.getLogger(MyClass.class);")); - // Logger declaration and instanciation with two modifier and comment at the - // end of line - assertEquals( - "public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class); // logger instanciation and declaration", - log4jConverter - .getOneLineReplacement("public static Logger mylog1 = Logger.getLogger(MyClass.class); // logger instanciation and declaration")); - // Logger instanciation without declaration and comment at the end of line - assertEquals( - " myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation", - log4jConverter - .getOneLineReplacement(" myLog = Logger.getLogger(MyClass.class);//logger instanciation")); - // commented Logger declaration and instanciation with two modifier - assertEquals( - "//public static Logger mylog1 = LoggerFactory.getLogger(MyClass.class);", - log4jConverter - .getOneLineReplacement("//public static Logger mylog1 = Logger.getLogger(MyClass.class);")); - // commented Logger instanciation without declaration - assertEquals( - "// myLog = LoggerFactory.getLogger(MyClass.class);//logger instanciation", - log4jConverter - .getOneLineReplacement("// myLog = Logger.getLogger(MyClass.class);//logger instanciation")); - } - - public void testLogDeclarationReplacement() { - // simple Logger declaration - assertEquals("Logger mylog;", log4jConverter.getOneLineReplacement("Logger mylog;")); - // Logger declaration with a modifier - assertEquals("private Logger mylog;", log4jConverter - .getOneLineReplacement("private Logger mylog;")); - - // Logger declaration with modifiers - assertEquals("public static final Logger myLog;", log4jConverter - .getOneLineReplacement("public static final Logger myLog;")); - // Logger declaration with modifiers and comment at the end of line - assertEquals("public Logger myLog;//logger declaration", log4jConverter - .getOneLineReplacement("public Logger myLog;//logger declaration")); - // commented Logger declaration - assertEquals("//private Logger myLog;", log4jConverter - .getOneLineReplacement("//private Logger myLog;")); - } - - public void testMultiLineReplacement() { - // Logger declaration on a line - assertEquals("protected Logger log =", log4jConverter - .getOneLineReplacement("protected Logger log =")); - - // Logger instanciation on the next line - assertEquals(" LoggerFactory.getLogger(MyComponent.class);", log4jConverter - .getOneLineReplacement(" LogManager.getLogger(MyComponent.class);")); - // Logger declaration on a line - assertEquals("protected Logger log ", log4jConverter - .getOneLineReplacement("protected Logger log ")); - // Logger instanciation on the next line - assertEquals( - " = LoggerFactory.getLogger(MyComponent.class);", - log4jConverter - .getOneLineReplacement(" = LogManager.getLogger(MyComponent.class);")); - } -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/NoConversionTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/NoConversionTest.java deleted file mode 100644 index 1e6f6de42..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/NoConversionTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.slf4j.migrator.line; - -import org.slf4j.migrator.line.JCLRuleSet; -import org.slf4j.migrator.line.LineConverter; -import org.slf4j.migrator.line.Log4jRuleSet; - -import junit.framework.TestCase; - -public class NoConversionTest extends TestCase { - - /** - * This test shows that performing JCL to SLF4J conversion has no impact on - * Log4j implementation - */ - public void testJclOverLog4jConversion() { - // running jcl to slf4j conversion - //JCLMatcher jclMatcher = - LineConverter jclLineConverter = new LineConverter(new JCLRuleSet()); - // no changes on log4j.LogManager import - assertEquals("import org.apache.log4j.LogManager;", jclLineConverter - .getOneLineReplacement("import org.apache.log4j.LogManager;")); - // no changes on log4j.Logger import - assertEquals("import org.apache.log4j.Logger;", jclLineConverter - .getOneLineReplacement("import org.apache.log4j.Logger;")); - // no changes on Logger instanciation using LogManager - assertEquals( - "Logger log = LogManager.getLogger(MyClass.class);", - jclLineConverter - .getOneLineReplacement("Logger log = LogManager.getLogger(MyClass.class);")); - // no changes on Logger instanciation using Logger.getLogger - assertEquals( - "public static Logger mylog1 = Logger.getLogger(MyClass.class);", - jclLineConverter - .getOneLineReplacement("public static Logger mylog1 = Logger.getLogger(MyClass.class);")); - } - - /** - * This test shows that performing Log4j to SLF4J conversion has no impact on - * JCL implementation - */ - public void testLog4jOverJclConversion() { - // running log4j to slf4j conversion - LineConverter log4jConverter = new LineConverter(new Log4jRuleSet()); - - // no changes on LogFactory import - assertEquals("import org.apache.commons.logging.LogFactory;", log4jConverter - .getOneLineReplacement("import org.apache.commons.logging.LogFactory;")); - // no changes on Log import - assertEquals("import org.apache.commons.logging.Log;", log4jConverter - .getOneLineReplacement("import org.apache.commons.logging.Log;")); - // no changes on Log instanciation using Logfactory.getLog - assertEquals( - "public static Log mylog1 = LogFactory.getLog(MyClass.class);", - log4jConverter - .getOneLineReplacement("public static Log mylog1 = LogFactory.getLog(MyClass.class);")); - // no changes on log instanciation using LogFactory.getFactory().getInstance - assertEquals( - "public Log mylog=LogFactory.getFactory().getInstance(MyClass.class);", - log4jConverter - .getOneLineReplacement("public Log mylog=LogFactory.getFactory().getInstance(MyClass.class);")); - - } -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/PackageTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/PackageTest.java deleted file mode 100644 index 84cfd3781..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/PackageTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.line; - -import org.slf4j.migrator.line.JCLRuleSetTest; -import org.slf4j.migrator.line.Log4jRuleSetTest; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class PackageTest extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTestSuite(TrivialMatcherTest.class); - suite.addTestSuite(JCLRuleSetTest.class); - suite.addTestSuite(Log4jRuleSetTest.class); - suite.addTestSuite(NoConversionTest.class); - return suite; - } -} \ No newline at end of file diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/TrivialMatcherTest.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/TrivialMatcherTest.java deleted file mode 100644 index a57246154..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/TrivialMatcherTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.slf4j.migrator.line; - -import org.slf4j.migrator.line.LineConverter; - -import junit.framework.TestCase; - -public class TrivialMatcherTest extends TestCase { - - public void testSimpleReplacement() { - LineConverter trivialLC = new LineConverter(new TrivialMatcher()); - - - // "import org.slf4j.converter" -- > simple replacement with an unique - // capturing group - assertEquals("simple replacement with an unique capturing group", - trivialLC.getOneLineReplacement("import org.slf4j.converter")); - - assertEquals("1st group second group 4th group", trivialLC - .getOneLineReplacement("first group second group third group 4th group")); - - } - -} diff --git a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/TriviialMatcher.java b/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/TriviialMatcher.java deleted file mode 100644 index cb4d359ec..000000000 --- a/trunk/slf4j-migrator/src/test/java/org/slf4j/migrator/line/TriviialMatcher.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.migrator.line; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.regex.Pattern; - -import org.slf4j.migrator.line.ConversionRule; -import org.slf4j.migrator.line.MultiGroupConversionRule; -import org.slf4j.migrator.line.RuleSet; -import org.slf4j.migrator.line.SingleConversionRule; - -class TrivialMatcher implements RuleSet { - - private ArrayList conversionRuleList; - - public TrivialMatcher() { - //simple rule no capturing group is defined, we use default capturing group which is group zero - SingleConversionRule cr = new SingleConversionRule(Pattern.compile("import org.slf4j.converter"), - "simple replacement with an unique capturing group"); - - //we define 4 differents capturing groups - MultiGroupConversionRule cr1 = new MultiGroupConversionRule(Pattern.compile("(first group)( second group)( third group)( 4th group)")); - //group zero is ignored during treatment - //replacement for the first - cr1.addReplacement(1, "1st group"); - //no replacement for the second group it will remains the same - //empty string for the third group it will be deleted - cr1.addReplacement(3, ""); - //no replacement for the third group it will remains the same - - conversionRuleList = new ArrayList(); - conversionRuleList.add(cr); - conversionRuleList.add(cr1); - } - - public Iterator iterator() { - return conversionRuleList.iterator(); - } - - -} \ No newline at end of file diff --git a/trunk/slf4j-nop/LICENSE.txt b/trunk/slf4j-nop/LICENSE.txt deleted file mode 100644 index f6e2f31f7..000000000 --- a/trunk/slf4j-nop/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2004-2007 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - diff --git a/trunk/slf4j-nop/pom.xml b/trunk/slf4j-nop/pom.xml deleted file mode 100644 index d41a99218..000000000 --- a/trunk/slf4j-nop/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-nop - jar - SLF4J NOP Binding - - http://www.slf4j.org - - The slf4j NOP binding - - - - - org.slf4j - slf4j-api - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.version} - ${project.description} - ${project.version} - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLogger.java b/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLogger.java deleted file mode 100644 index b065013e0..000000000 --- a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLogger.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.Logger; -import org.slf4j.helpers.MarkerIgnoringBase; - - -/** - * A direct NOP (no operation) implementation of {@link Logger}. - * - * @author Ceki Gülcü - */ -public class NOPLogger extends MarkerIgnoringBase { - /** - * The unique instance of NOPLogger. - */ - public static final NOPLogger NOP_LOGGER = new NOPLogger(); - - /** - * There is no point in creating multiple instances of NOPLOgger, - * except by derived classes, hence the protected access for the constructor. - */ - protected NOPLogger() { - } - - /** - * Always returns the string value "NOP". - */ - public String getName() { - return "NOP"; - } - - /** - * Always returns false. - * @return always false - */ - final public boolean isTraceEnabled() { - return false; - } - - /** A NOP implementation. */ - final public void trace(String msg) { - // NOP - } - - /** A NOP implementation. */ - final public void trace(String format, Object arg) { - // NOP - } - - /** A NOP implementation. */ - public final void trace(String format, Object arg1, Object arg2) { - // NOP - } - - /** A NOP implementation. */ - public final void trace(String format, Object[] argArray) { - // NOP - } - - /** A NOP implementation. */ - final public void trace(String msg, Throwable t) { - // NOP - } - - /** - * Always returns false. - * @return always false - */ - final public boolean isDebugEnabled() { - return false; - } - - /** A NOP implementation. */ - final public void debug(String msg) { - // NOP - } - - /** A NOP implementation. */ - final public void debug(String format, Object arg) { - // NOP - } - - /** A NOP implementation. */ - public final void debug(String format, Object arg1, Object arg2) { - // NOP - } - - /** A NOP implementation. */ - public final void debug(String format, Object[] argArray) { - // NOP - } - - - - /** A NOP implementation. */ - final public void debug(String msg, Throwable t) { - // NOP - } - - /** - * Always returns false. - * @return always false - */ - final public boolean isInfoEnabled() { - // NOP - return false; - } - - - /** A NOP implementation. */ - final public void info(String msg) { - // NOP - } - - /** A NOP implementation. */ - final public void info(String format, Object arg1) { - // NOP - } - - /** A NOP implementation. */ - final public void info(String format, Object arg1, Object arg2) { - // NOP - } - - /** A NOP implementation. */ - public final void info(String format, Object[] argArray) { - // NOP - } - - - /** A NOP implementation. */ - final public void info(String msg, Throwable t) { - // NOP - } - - - /** - * Always returns false. - * @return always false - */ - final public boolean isWarnEnabled() { - return false; - } - - /** A NOP implementation. */ - final public void warn(String msg) { - // NOP - } - - /** A NOP implementation. */ - final public void warn(String format, Object arg1) { - // NOP - } - - /** A NOP implementation. */ - final public void warn(String format, Object arg1, Object arg2) { - // NOP - } - - /** A NOP implementation. */ - public final void warn(String format, Object[] argArray) { - // NOP - } - - - /** A NOP implementation. */ - final public void warn(String msg, Throwable t) { - // NOP - } - - - /** A NOP implementation. */ - final public boolean isErrorEnabled() { - return false; - } - - /** A NOP implementation. */ - final public void error(String msg) { - // NOP - } - - /** A NOP implementation. */ - final public void error(String format, Object arg1) { - // NOP - } - - /** A NOP implementation. */ - final public void error(String format, Object arg1, Object arg2) { - // NOP - } - - /** A NOP implementation. */ - public final void error(String format, Object[] argArray) { - // NOP - } - - - /** A NOP implementation. */ - final public void error(String msg, Throwable t) { - // NOP - } -} diff --git a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLoggerFactory.java b/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLoggerFactory.java deleted file mode 100644 index 614a352e4..000000000 --- a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLoggerFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.Logger; -import org.slf4j.ILoggerFactory; - - -/** - * NOPLoggerFactory is an trivial implementation of {@link - * ILoggerFactory} which always returns the unique instance of - * NOPLogger. - * - * @author Ceki Gülcü - */ -public class NOPLoggerFactory implements ILoggerFactory { - - public NOPLoggerFactory() { - // nothing to do - } - - public Logger getLogger(String name) { - return NOPLogger.NOP_LOGGER; - } - -} diff --git a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticLoggerBinder.java deleted file mode 100644 index caf855c2f..000000000 --- a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.ILoggerFactory; -import org.slf4j.LoggerFactory; -import org.slf4j.spi.LoggerFactoryBinder; - -/** - * The binding of {@link LoggerFactory} class with an actual instance of - * {@link ILoggerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticLoggerBinder implements LoggerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - // Note: JCL gets substituted at build time by an appropriate Ant task - private static final String loggerFactoryClassStr = NOPLoggerFactory.class.getName(); - - /** The ILoggerFactory instance returned by the {@link #getLoggerFactory} method - * should always be the same object - */ - private final ILoggerFactory loggerFactory; - - private StaticLoggerBinder() { -// Note: JCL gets substituted at build time by an appropriate Ant task - loggerFactory = new NOPLoggerFactory(); - } - - public ILoggerFactory getLoggerFactory() { - return loggerFactory; - } - - public String getLoggerFactoryClassStr() { - return loggerFactoryClassStr; - } -} diff --git a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticMDCBinder.java deleted file mode 100644 index 62b9f8658..000000000 --- a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticMDCBinder.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.slf4j.impl; - -import org.slf4j.helpers.NOPMakerAdapter; -import org.slf4j.spi.MDCAdapter; - - -/** - * This implementation is bound to {@link NOPMakerAdapter}. - * - * @author Ceki Gülcü - */ -public class StaticMDCBinder { - - - /** - * The unique instance of this class. - */ - public static final StaticMDCBinder SINGLETON = new StaticMDCBinder(); - - private StaticMDCBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link StaticMDCBinder}. - */ - public MDCAdapter getMDCA() { - return new NOPMakerAdapter(); - } - - public String getMDCAdapterClassStr() { - return NOPMakerAdapter.class.getName(); - } -} diff --git a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticMarkerBinder.java deleted file mode 100644 index b37c3640e..000000000 --- a/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticMarkerBinder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.IMarkerFactory; -import org.slf4j.MarkerFactory; -import org.slf4j.helpers.BasicMarkerFactory; -import org.slf4j.spi.MarkerFactoryBinder; - -/** - * - * The binding of {@link MarkerFactory} class with an actual instance of - * {@link IMarkerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticMarkerBinder implements MarkerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder(); - - final IMarkerFactory markerFactory = new BasicMarkerFactory(); - - private StaticMarkerBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link BasicMarkerFactory}. - */ - public IMarkerFactory getMarkerFactory() { - return markerFactory; - } - - /** - * Currently, this method returns the class name of - * {@link BasicMarkerFactory}. - */ - public String getMarkerFactoryClassStr() { - return BasicMarkerFactory.class.getName(); - } - - -} diff --git a/trunk/slf4j-nop/src/main/resources/META-INF/MANIFEST.MF b/trunk/slf4j-nop/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 970f28ee6..000000000 --- a/trunk/slf4j-nop/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,9 +0,0 @@ -Implementation-Title: slf4j-nop -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: slf4j.nop -Bundle-Name: slf4j-nop -Bundle-Vendor: SLF4J.ORG -Bundle-RequiredExecutionEnvironment: J2SE-1.3 -Export-Package: org.slf4j.impl;version=${project.version} -Import-Package: org.slf4j;version=${project.version}, org.slf4j.spi;version=${project.version}, org.slf4j.helpers;version=${project.version} -Fragment-Host: slf4j.api \ No newline at end of file diff --git a/trunk/slf4j-nop/src/test/java/org/slf4j/InvocationTest.java b/trunk/slf4j-nop/src/test/java/org/slf4j/InvocationTest.java deleted file mode 100644 index dc84aa203..000000000 --- a/trunk/slf4j-nop/src/test/java/org/slf4j/InvocationTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.CH - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j; - -import junit.framework.TestCase; - - -/** - * Test whether invoking the SLF4J API causes problems or not. - * - * @author Ceki Gulcu - * - */ -public class InvocationTest extends TestCase { - - public InvocationTest (String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void test1() { - Logger logger = LoggerFactory.getLogger("test1"); - logger.debug("Hello world."); - } - - public void test2() { - Integer i1 = new Integer(1); - Integer i2 = new Integer(2); - Integer i3 = new Integer(3); - Exception e = new Exception("This is a test exception."); - Logger logger = LoggerFactory.getLogger("test2"); - - logger.debug("Hello world 1."); - logger.debug("Hello world {}", i1); - logger.debug("val={} val={}", i1, i2); - logger.debug("val={} val={} val={}", new Object[]{i1, i2, i3}); - - logger.debug("Hello world 2", e); - logger.info("Hello world 2."); - - - logger.warn("Hello world 3."); - logger.warn("Hello world 3", e); - - - logger.error("Hello world 4."); - logger.error("Hello world {}", new Integer(3)); - logger.error("Hello world 4.", e); - } - - public void testNull() { - Logger logger = LoggerFactory.getLogger("testNull"); - logger.debug(null); - logger.info(null); - logger.warn(null); - logger.error(null); - - Exception e = new Exception("This is a test exception."); - logger.debug(null, e); - logger.info(null, e); - logger.warn(null, e); - logger.error(null, e); - } - - public void testMarker() { - Logger logger = LoggerFactory.getLogger("testMarker"); - Marker blue = MarkerFactory.getMarker("BLUE"); - logger.debug(blue, "hello"); - logger.info(blue, "hello"); - logger.warn(blue, "hello"); - logger.error(blue, "hello"); - - logger.debug(blue, "hello {}", "world"); - logger.info(blue, "hello {}", "world"); - logger.warn(blue, "hello {}", "world"); - logger.error(blue, "hello {}", "world"); - - logger.debug(blue, "hello {} and {} ", "world", "universe"); - logger.info(blue, "hello {} and {} ", "world", "universe"); - logger.warn(blue, "hello {} and {} ", "world", "universe"); - logger.error(blue, "hello {} and {} ", "world", "universe"); - } - - public void testMDC() { - MDC.put("k", "v"); - assertNull(MDC.get("k")); - MDC.remove("k"); - assertNull(MDC.get("k")); - MDC.clear(); - } -} diff --git a/trunk/slf4j-osgi-integration-test/pom.xml b/trunk/slf4j-osgi-integration-test/pom.xml deleted file mode 100644 index 5cc867908..000000000 --- a/trunk/slf4j-osgi-integration-test/pom.xml +++ /dev/null @@ -1,240 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-osgi-integration-test - jar - SLF4J OSGi Integration Test - - http://www.slf4j.org - - OSGi integration tests for the slf4j. - - - - - - org.apache.felix - javax.servlet - 0.8.0-SNAPSHOT - test - - - - org.osgi - org.osgi.compendium - 4.0 - provided - - - - junit - junit - 3.8.1 - test - - - org.slf4j - slf4j-osgi-test-bundle - ${parent.version} - test - - - org.springframework.osgi - org.springframework.osgi.test - 1.0-SNAPSHOT - provided - - - org.springframework.osgi - spring-core - 2.1-SNAPSHOT - provided - - - org.springframework.osgi - spring-context - 2.1-SNAPSHOT - provided - - - org.springframework.osgi - spring-beans - 2.1-SNAPSHOT - provided - - - - - org.springframework.osgi - spring-mock - 2.1-SNAPSHOT - jar - test - - - org.springframework.osgi - jcl104-over-slf4j.osgi - 1.1.0 - provided - - - org.slf4j - slf4j-log4j-full - 1.1.0 - provided - - - org.springframework.osgi - log4j.osgi - 1.2.13-SNAPSHOT - test - - - org.springframework.osgi - backport-util-concurrent - 3.0-SNAPSHOT - test - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - org.springframework.osgi.test.framework - ${osgi.test.platform} - - - org.osgi.framework.system.packages - ${osgi.test.system.packages} - - - - - - - default - test - - - - integration-test - integration-test - - test - - - false - pertest - - - - - - - - - equinox - - true - - - - org.eclipse.equinox - org.eclipse.osgi - 3.2.0 - jar - provided - - - - org.xml.sax, org.w3c.dom, javax.xml.parsers, javax.naming, javax.management - equinox - - - - knopflerfish - - - org.knopflerfish - framework - 2.0.1 - jar - provided - - - - - org.xml.sax, org.w3c.dom, javax.xml.parsers, javax.naming, javax.management - knopflerfish - - - - felix - - - org.apache.felix - org.apache.felix.framework - 0.8.0-SNAPSHOT - jar - provided - - - org.apache.felix - org.apache.felix.main - 0.8.0-SNAPSHOT - jar - provided - - - org.apache.felix - org.osgi.core - 0.8.0-SNAPSHOT - jar - runtime - - - - felix - - - - - \ No newline at end of file diff --git a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/IntegrationTestConstants.java b/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/IntegrationTestConstants.java deleted file mode 100644 index 072189e7d..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/IntegrationTestConstants.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ -package org.slf4j.osgi.integration; - -public interface IntegrationTestConstants { - - /** - * Versions of this release. - */ - public static final String SLF4J_VERSION_UNDER_TEST = "1.3.1-SNAPSHOT"; - - public static final String SLF4J_GROUP_ID = "org.slf4j"; - - public static final String SPRINGFRAMEWORK_OSGI_GROUP_NAME = "org.springframework.osgi"; - - public static final String API_BUNDLE_ARTIFACT_ID = "slf4j-api"; - - public static final String JCL104_ADAPTER_BUNDLE_ARTIFACT_ID = "jcl104-over-slf4j"; - - public static final String LOGSERVICE_ADAPTER_BUNDLE_ARTIFACT_ID = "osgi-over-slf4j"; - - public static final String JDK14_BINDING_BUNDLE_ARTIFACT_ID = "slf4j-jdk14"; - - public static final String SIMPLE_BINDING_BUNDLE_ARTIFACT_ID = "slf4j-simple"; - - public static final String LOG4J12_BINDING_BUNDLE_ARTIFACT_ID = "slf4j-log4j12"; - - public static final String NOP_BINDING_BUNDLE_ARTIFACT_ID = "slf4j-nop"; - - public static final String TEST_BUNDLE_ARTIFACT_ID = "slf4j-osgi-test-bundle"; - - - public static final String TEST_BUNDLE_SYM_NAME = SLF4J_GROUP_ID+'.'+TEST_BUNDLE_ARTIFACT_ID; - - public static final String NOP_BINDING_BUNDLE_SYM_NAME = "slf4j.nop"; - - public static final String LOG4J_BINDING_BUNDLE_SYM_NAME = "slf4j.log4j12"; - - public static final String SIMPLE_BINDING_BUNDLE_SYM_NAME ="slf4j.simple"; - - public static final String JDK_BINDING_BUNDLE_SYM_NAME = "slf4j.jdk14"; - - public static final String JCL_ADAPTER_BUNDLE_SYM_NAME = "jcl104.over.slf4j"; - - public static final String LOGSERVICE_ADAPTER_BUNDLE_SYM_NAME = SLF4J_GROUP_ID+'.'+LOGSERVICE_ADAPTER_BUNDLE_ARTIFACT_ID; - - - -} diff --git a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/jdk/test/JdkBundleTest.java b/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/jdk/test/JdkBundleTest.java deleted file mode 100644 index a146fe1a5..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/jdk/test/JdkBundleTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.integration.jdk.test; - -import java.util.ArrayList; -import java.util.List; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.osgi.integration.IntegrationTestConstants; -import org.slf4j.osgi.test.service.Probe; -import org.springframework.osgi.test.ConfigurableBundleCreatorTests; - -/** - * - * JdkBundleTest starts up an OSGi environment (equinox, - * knopflerfish, or felix according to the profile selected) and installs the - * slf4j.osgi.test.bundle, the slf4j.jdk bundle and the bundles they depend on. - * - * The test classes in this project will be turned into a virtual bundle which is - * also installed and the tests are then run inside the OSGi runtime. - * - * The tests have access to a BundleContext, which we use to test that all bundles have - * been started. - * - * - * @author John Conlon - */ -public class JdkBundleTest extends ConfigurableBundleCreatorTests implements IntegrationTestConstants{ - - - - - - /** - * The manifest to use for the "virtual bundle" created out of the test - * classes and resources in this project - * - * This is actually the boilerplate manifest with one additional - * import-package added. We should provide a simpler customization point for - * such use cases that doesn't require duplication of the entire manifest... - */ - protected String getManifestLocation() { - return "classpath:org/slf4j/osgi/integration/jdk/test/MANIFEST.MF"; - } - - /** - * The location of the packaged OSGi bundles to be installed for this test. - * Values are Spring resource paths. The bundles we want to use are part of - * the same multi-project maven build as this project is. Hence we use the - * localMavenArtifact helper method to find the bundles produced by the - * package phase of the maven build (these tests will run after the - * packaging phase, in the integration-test phase). - * - * JUnit, commons-logging, spring-core and the spring OSGi test bundle are - * automatically included so they do not need to be specified here. - * - * Our test bundles are using package import and export versions to keep - * these other logging bundles from getting mixed up with our test bundles. - */ - protected String[] getBundleLocations() { - return new String[] { - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "aopalliance.osgi", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-context", "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-beans", - "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-osgi-core", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-aop", - "2.1-SNAPSHOT"), - localMavenArtifact(SLF4J_GROUP_ID, API_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, JDK14_BINDING_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, TEST_BUNDLE_ARTIFACT_ID, - SLF4J_VERSION_UNDER_TEST) }; - } - - /** - * The superclass provides us access to the root bundle context via the - * 'getBundleContext' operation. Make sure it is not null. - */ - public void testOSGiStartedOk() { - BundleContext bundleContext = getBundleContext(); - assertNotNull(bundleContext); - - } - - /** - * Makes sure our bundles are in the OSGi runtime and their state is Active. - * - */ - public void testSlf4jNopBundleIntegration() { - Logger log = LoggerFactory.getLogger(JdkBundleTest.class); - assertNotNull(log); - BundleContext context = getBundleContext(); - List symNames = new ArrayList(); - - Bundle[] bundles = context.getBundles(); - log.info("Loaded bundles:"); - for (int i = 0; i < bundles.length; i++) { - Bundle bundle = bundles[i]; - assertEquals("Bundle " + bundle.getSymbolicName() - + " is not active.", Bundle.ACTIVE, bundle.getState()); - symNames.add(bundle.getSymbolicName()); - if (bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR) != null) { - log.info("Symbolic Name:" + bundle.getSymbolicName() - + ", Activator:" - + bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR)); - } else { - log.info("Symbolic Name:" + bundle.getSymbolicName()); - } - } - - assertTrue(symNames.contains(JDK_BINDING_BUNDLE_SYM_NAME)); - assertTrue(symNames.contains(TEST_BUNDLE_SYM_NAME)); - - } - - public void testProbeService(){ - Logger log = LoggerFactory.getLogger(JdkBundleTest.class); - log.debug("Testing probe"); - BundleContext context = getBundleContext(); - ServiceReference ref = context.getServiceReference( Probe.class.getName() ); - assertNotNull( "Service Reference is null", ref ); - Probe probe = ( Probe ) context.getService( ref ); - assertNotNull( "Cannot find the probe service", probe ); - - try { - probe.testCommonslogging(); - fail("Expected exception while testing commons logging."); - } catch (Throwable t){ - log.debug("Failed to execute the probe.testCommonsLogging. "+t); - - } - - context.ungetService( ref ); - - log.debug("Tested probe."); - } - -} diff --git a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/log4j/test/Log4JBundleTest.java b/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/log4j/test/Log4JBundleTest.java deleted file mode 100644 index 43a960e6d..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/log4j/test/Log4JBundleTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.integration.log4j.test; - -import java.util.ArrayList; -import java.util.List; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.osgi.integration.IntegrationTestConstants; -import org.slf4j.osgi.test.service.Probe; -import org.springframework.osgi.test.ConfigurableBundleCreatorTests; - -/** - * - * Log4JBundleTest starts up an OSGi environment (equinox, - * knopflerfish, or felix according to the profile selected) and installs the - * slf4j.osgi.test.bundle, the slf4j.log4j12 bundle and the bundles they depend - * on. - * - * The slf4j.log4j12 will use the log4j bundle associated with the Spring-OSGi - * testing framework. - * - * The test classes in this project will be turned into a virtual bundle which - * is also installed and the tests are then run inside the OSGi runtime. - * - * The tests have access to a BundleContext, which we use to test that all - * bundles have been started. - * - * - * @author John Conlon - */ -public class Log4JBundleTest extends ConfigurableBundleCreatorTests implements IntegrationTestConstants { - - - - - - - /** - * The manifest to use for the "virtual bundle" created out of the test - * classes and resources in this project - * - * This is actually the boilerplate manifest with one additional - * import-package added. We should provide a simpler customization point for - * such use cases that doesn't require duplication of the entire manifest... - */ - protected String getManifestLocation() { - return "classpath:org/slf4j/osgi/integration/log4j/test/MANIFEST.MF"; - } - - /** - * The location of the packaged OSGi bundles to be installed for this test. - * Values are Spring resource paths. The bundles we want to use are part of - * the same multi-project maven build as this project is. Hence we use the - * localMavenArtifact helper method to find the bundles produced by the - * package phase of the maven build (these tests will run after the - * packaging phase, in the integration-test phase). - * - * JUnit, commons-logging, spring-core and the spring OSGi test bundle are - * automatically included so they do not need to be specified here. - * - * Except in the case of slf4j.log4j12 using the log4j bundle associated - * with the Spring-OSGi testing framework our test bundles are using package - * import and export versions to keep these other logging bundles from - * getting mixed up with our test bundles. - */ - protected String[] getBundleLocations() { - return new String[] { - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "aopalliance.osgi", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-context", "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-beans", - "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-osgi-core", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-aop", - "2.1-SNAPSHOT"), - localMavenArtifact(SLF4J_GROUP_ID, API_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, LOG4J12_BINDING_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, TEST_BUNDLE_ARTIFACT_ID, - SLF4J_VERSION_UNDER_TEST) }; - } - - /** - * The superclass provides us access to the root bundle context via the - * 'getBundleContext' operation. Make sure it is not null. - */ - public void testOSGiStartedOk() { - BundleContext bundleContext = getBundleContext(); - assertNotNull(bundleContext); - - } - - /** - * Makes sure our bundles are in the OSGi runtime and their state is Active. - * - */ - public void testSlf4jLog4j12BundleIntegration() { - Logger log = LoggerFactory.getLogger(Log4JBundleTest.class); - assertNotNull(log); - BundleContext context = getBundleContext(); - List symNames = new ArrayList(); - - Bundle[] bundles = context.getBundles(); - log.info("Loaded bundles:"); - for (int i = 0; i < bundles.length; i++) { - Bundle bundle = bundles[i]; - assertEquals("Bundle " + bundle.getSymbolicName() - + " is not active.", Bundle.ACTIVE, bundle.getState()); - symNames.add(bundle.getSymbolicName()); - if (bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR) != null) { - log.info("Symbolic Name:" + bundle.getSymbolicName() - + ", Activator:" - + bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR)); - } else { - log.info("Symbolic Name:" + bundle.getSymbolicName()); - } - } - - assertTrue(symNames.contains(LOG4J_BINDING_BUNDLE_SYM_NAME)); - assertTrue(symNames.contains(TEST_BUNDLE_SYM_NAME)); - - } - - public void testProbeService() { - BundleContext context = getBundleContext(); - ServiceReference ref = context.getServiceReference(Probe.class - .getName()); - assertNotNull("Service Reference is null", ref); - Probe probe = null; - - probe = (Probe) context.getService(ref); - assertNotNull("Cannot find the probe service", probe); - - try { - probe.testCommonslogging(); - fail("The commons logging package should not be found. Instead an exception should be thrown."); - } catch (Throwable t) { - // "Expect.",t); - } - - context.ungetService(ref); - - } -} diff --git a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/logservice/test/LogServiceBundleTest.java b/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/logservice/test/LogServiceBundleTest.java deleted file mode 100644 index fa6a847e2..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/logservice/test/LogServiceBundleTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.integration.logservice.test; - -import java.util.ArrayList; -import java.util.List; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceReference; -import org.osgi.service.log.LogService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.osgi.integration.IntegrationTestConstants; -import org.slf4j.osgi.integration.nop.test.NopBundleTest; -import org.springframework.osgi.test.ConfigurableBundleCreatorTests; - -/** - * - * LogServiceBundleTest starts up an OSGi environment (equinox, - * knopflerfish, or felix according to the profile selected) and installs the - * slf4j.osgi.test.bundle, the slf4j.simple bundle and the bundles they depend - * on. - * - * The test classes in this project will be turned into a virtual bundle which - * is also installed and the tests are then run inside the OSGi runtime. - * - * The tests have access to a BundleContext, which we use to test that all - * bundles have been started. - * - * - * @author John Conlon - */ -public class LogServiceBundleTest extends ConfigurableBundleCreatorTests implements IntegrationTestConstants{ - - - - - /** - * The manifest to use for the "virtual bundle" created out of the test - * classes and resources in this project - * - * This is actually the boilerplate manifest with one additional - * import-package added. We should provide a simpler customization point for - * such use cases that doesn't require duplication of the entire manifest... - */ - protected String getManifestLocation() { - return "classpath:org/slf4j/osgi/integration/logservice/test/MANIFEST.MF"; - } - - /** - * The location of the packaged OSGi bundles to be installed for this test. - * Values are Spring resource paths. The bundles we want to use are part of - * the same multi-project maven build as this project is. Hence we use the - * localMavenArtifact helper method to find the bundles produced by the - * package phase of the maven build (these tests will run after the - * packaging phase, in the integration-test phase). - * - * JUnit, commons-logging, spring-core and the spring OSGi test bundle are - * automatically included so they do not need to be specified here. - * - * Our test bundles are using package import and export versions to keep - * these other logging bundles from getting mixed up with our test bundles. - */ - protected String[] getBundleLocations() { - return new String[] { - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "aopalliance.osgi", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-context", "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-beans", - "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-osgi-core", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-aop", - "2.1-SNAPSHOT"), - localMavenArtifact( "org.osgi", "org.osgi.compendium", "4.0" ), - localMavenArtifact(SLF4J_GROUP_ID, API_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, - SIMPLE_BINDING_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, - LOGSERVICE_ADAPTER_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST) }; - } - - /** - * The superclass provides us access to the root bundle context via the - * 'getBundleContext' operation. Make sure it is not null. - */ - public void testOSGiStartedOk() { - BundleContext bundleContext = getBundleContext(); - assertNotNull(bundleContext); - - } - - /** - * Makes sure our bundles are in the OSGi runtime and their state is Active. - * - */ - public void testSlf4jLogServiceBundles() { - Logger log = LoggerFactory.getLogger(LogServiceBundleTest.class); - assertNotNull(log); - BundleContext context = getBundleContext(); - List symNames = new ArrayList(); - - Bundle[] bundles = context.getBundles(); - log.info("Loaded bundles:"); - for (int i = 0; i < bundles.length; i++) { - Bundle bundle = bundles[i]; - assertEquals("Bundle " + bundle.getSymbolicName() - + " is not active.", Bundle.ACTIVE, bundle.getState()); - symNames.add(bundle.getSymbolicName()); - if (bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR) != null) { - log.info("Symbolic Name:" + bundle.getSymbolicName() - + ", Activator:" - + bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR)); - } else { - log.info("Symbolic Name:" + bundle.getSymbolicName()); - } - } - - assertTrue(symNames.contains(SIMPLE_BINDING_BUNDLE_SYM_NAME)); - assertTrue(symNames.contains(LOGSERVICE_ADAPTER_BUNDLE_SYM_NAME)); - - } - - public void testLogService() { - Logger log = LoggerFactory.getLogger(NopBundleTest.class); - log.debug("Testing LogSerivce"); - BundleContext context = getBundleContext(); - ServiceReference ref = context.getServiceReference(LogService.class.getName()); - assertNotNull("Service Reference is null", ref); - LogService logService = null; - - logService = (LogService) context.getService(ref); - assertNotNull("Cannot find the probe service", logService); - - exerciseLogService( logService); - exerciseLogService( logService,ref); - - context.ungetService(ref); - } - - private void exerciseLogService(LogService logService, ServiceReference ref){ - logService.log(ref, LogService.LOG_DEBUG, "Loaded bundles" ); - logService.log(ref, LogService.LOG_INFO, "Found LogService. " ); - logService.log(ref, LogService.LOG_WARNING, "Found LogService. " ); - logService.log(ref, LogService.LOG_ERROR, "Found LogService. ", new Exception("just a test.") ); - } - - private void exerciseLogService(LogService logService){ - logService.log(LogService.LOG_DEBUG, "Loaded bundles" ); - logService.log(LogService.LOG_INFO, "Found LogService. " ); - logService.log(LogService.LOG_WARNING, "Found LogService. " ); - logService.log(LogService.LOG_ERROR, "Found LogService. ", new Exception("just a test.") ); - } - -} diff --git a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/nop/test/NopBundleTest.java b/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/nop/test/NopBundleTest.java deleted file mode 100644 index d9956615b..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/nop/test/NopBundleTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.integration.nop.test; - -import java.util.ArrayList; -import java.util.List; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.osgi.integration.IntegrationTestConstants; -import org.slf4j.osgi.test.service.Probe; -import org.springframework.osgi.test.ConfigurableBundleCreatorTests; - -/** - * - * JdkBundleTest starts up an OSGi environment (equinox, - * knopflerfish, or felix according to the profile selected) and installs the - * slf4j.osgi.test.bundle, the slf4j.nop bundle and the bundles they depend on. - * - * The test classes in this project will be turned into a virtual bundle which is - * also installed and the tests are then run inside the OSGi runtime. - * - * The tests have access to a BundleContext, which we use to test that all bundles have - * been started. - * - * - * @author John Conlon - */ -public class NopBundleTest extends ConfigurableBundleCreatorTests implements IntegrationTestConstants{ - - - - /** - * The manifest to use for the "virtual bundle" created out of the test - * classes and resources in this project - * - * This is actually the boilerplate manifest with one additional - * import-package added. We should provide a simpler customization point for - * such use cases that doesn't require duplication of the entire manifest... - */ - protected String getManifestLocation() { - return "classpath:org/slf4j/osgi/integration/nop/test/MANIFEST.MF"; - } - - /** - * The location of the packaged OSGi bundles to be installed for this test. - * Values are Spring resource paths. The bundles we want to use are part of - * the same multi-project maven build as this project is. Hence we use the - * localMavenArtifact helper method to find the bundles produced by the - * package phase of the maven build (these tests will run after the - * packaging phase, in the integration-test phase). - * - * JUnit, commons-logging, spring-core and the spring OSGi test bundle are - * automatically included so they do not need to be specified here. - * - * Our test bundles are using package import and export versions to keep - * these other logging bundles from getting mixed up with our test bundles. - */ - protected String[] getBundleLocations() { - return new String[] { - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "aopalliance.osgi", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-context", "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-beans", - "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-osgi-core", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-aop", - "2.1-SNAPSHOT"), - localMavenArtifact(SLF4J_GROUP_ID, API_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, NOP_BINDING_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, TEST_BUNDLE_ARTIFACT_ID, - SLF4J_VERSION_UNDER_TEST) }; - } - - /** - * The superclass provides us access to the root bundle context via the - * 'getBundleContext' operation. Make sure it is not null. - */ - public void testOSGiStartedOk() { - BundleContext bundleContext = getBundleContext(); - assertNotNull(bundleContext); - - } - - /** - * Makes sure our bundles are in the OSGi runtime and their state is Active. - * - */ - public void testSlf4jNopBundleIntegration() { - Logger log = LoggerFactory.getLogger(NopBundleTest.class); - assertNotNull(log); - BundleContext context = getBundleContext(); - List symNames = new ArrayList(); - - Bundle[] bundles = context.getBundles(); - log.info("Loaded bundles:"); - for (int i = 0; i < bundles.length; i++) { - Bundle bundle = bundles[i]; - assertEquals("Bundle " + bundle.getSymbolicName() - + " is not active.", Bundle.ACTIVE, bundle.getState()); - symNames.add(bundle.getSymbolicName()); - if (bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR) != null) { - log.info("Symbolic Name:" + bundle.getSymbolicName() - + ", Activator:" - + bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR)); - } else { - log.info("Symbolic Name:" + bundle.getSymbolicName()); - } - } - - assertTrue("Could not find "+NOP_BINDING_BUNDLE_SYM_NAME, symNames.contains(NOP_BINDING_BUNDLE_SYM_NAME)); - assertTrue(symNames.contains(TEST_BUNDLE_SYM_NAME)); - - } - - public void testProbeService(){ - Logger log = LoggerFactory.getLogger(NopBundleTest.class); - log.debug("Testing probe"); - BundleContext context = getBundleContext(); - ServiceReference ref = context.getServiceReference( Probe.class.getName() ); - assertNotNull( "Service Reference is null", ref ); - Probe probe = ( Probe ) context.getService( ref ); - assertNotNull( "Cannot find the probe service", probe ); - - try { - probe.testCommonslogging(); - fail("Expected exception while testing commons logging."); - } catch (Throwable t){ - log.debug("Failed to execute the probe.testCommonsLogging. "+t); - - } - - context.ungetService( ref ); - - log.debug("Tested probe."); - } - -} diff --git a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/simple/test/SimpleBundleTest.java b/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/simple/test/SimpleBundleTest.java deleted file mode 100644 index 22bcee955..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/java/org/slf4j/osgi/integration/simple/test/SimpleBundleTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.integration.simple.test; - -import java.util.ArrayList; -import java.util.List; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.osgi.integration.IntegrationTestConstants; -import org.slf4j.osgi.integration.nop.test.NopBundleTest; -import org.slf4j.osgi.test.service.Probe; -import org.springframework.osgi.test.ConfigurableBundleCreatorTests; - -/** - * - * LogServiceBundleTest starts up an OSGi environment (equinox, - * knopflerfish, or felix according to the profile selected) and installs the - * slf4j.osgi.test.bundle, the slf4j.simple bundle and the bundles they depend - * on. - * - * The test classes in this project will be turned into a virtual bundle which - * is also installed and the tests are then run inside the OSGi runtime. - * - * The tests have access to a BundleContext, which we use to test that all - * bundles have been started. - * - * - * @author John Conlon - */ -public class SimpleBundleTest extends ConfigurableBundleCreatorTests implements IntegrationTestConstants{ - - - - - /** - * The manifest to use for the "virtual bundle" created out of the test - * classes and resources in this project - * - * This is actually the boilerplate manifest with one additional - * import-package added. We should provide a simpler customization point for - * such use cases that doesn't require duplication of the entire manifest... - */ - protected String getManifestLocation() { - return "classpath:org/slf4j/osgi/integration/simple/test/MANIFEST.MF"; - } - - /** - * The location of the packaged OSGi bundles to be installed for this test. - * Values are Spring resource paths. The bundles we want to use are part of - * the same multi-project maven build as this project is. Hence we use the - * localMavenArtifact helper method to find the bundles produced by the - * package phase of the maven build (these tests will run after the - * packaging phase, in the integration-test phase). - * - * JUnit, commons-logging, spring-core and the spring OSGi test bundle are - * automatically included so they do not need to be specified here. - * - * Our test bundles are using package import and export versions to keep - * these other logging bundles from getting mixed up with our test bundles. - */ - protected String[] getBundleLocations() { - return new String[] { - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "aopalliance.osgi", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-context", "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-beans", - "2.1-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, - "spring-osgi-core", "1.0-SNAPSHOT"), - localMavenArtifact(SPRINGFRAMEWORK_OSGI_GROUP_NAME, "spring-aop", - "2.1-SNAPSHOT"), - localMavenArtifact(SLF4J_GROUP_ID, API_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, SIMPLE_BINDING_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, JCL104_ADAPTER_BUNDLE_ARTIFACT_ID, SLF4J_VERSION_UNDER_TEST), - localMavenArtifact(SLF4J_GROUP_ID, TEST_BUNDLE_ARTIFACT_ID, - SLF4J_VERSION_UNDER_TEST) }; - } - - /** - * The superclass provides us access to the root bundle context via the - * 'getBundleContext' operation. Make sure it is not null. - */ - public void testOSGiStartedOk() { - BundleContext bundleContext = getBundleContext(); - assertNotNull(bundleContext); - - } - - /** - * Makes sure our bundles are in the OSGi runtime and their state is Active. - * - */ - public void testSlf4jNopBundles() { - Logger log = LoggerFactory.getLogger(SimpleBundleTest.class); - assertNotNull(log); - BundleContext context = getBundleContext(); - List symNames = new ArrayList(); - - Bundle[] bundles = context.getBundles(); - log.info("Loaded bundles:"); - for (int i = 0; i < bundles.length; i++) { - Bundle bundle = bundles[i]; - assertEquals("Bundle " + bundle.getSymbolicName() - + " is not active.", Bundle.ACTIVE, bundle.getState()); - symNames.add(bundle.getSymbolicName()); - if (bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR) != null) { - log.info("Symbolic Name:" + bundle.getSymbolicName() - + ", Activator:" - + bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR)); - } else { - log.info("Symbolic Name:" + bundle.getSymbolicName()); - } - } - - assertTrue(symNames.contains(SIMPLE_BINDING_BUNDLE_SYM_NAME)); - assertTrue(symNames.contains(TEST_BUNDLE_SYM_NAME)); - assertTrue(symNames.contains(JCL_ADAPTER_BUNDLE_SYM_NAME)); - - } - - public void testProbeService() { - Logger log = LoggerFactory.getLogger(NopBundleTest.class); - log.debug("Testing probe"); - BundleContext context = getBundleContext(); - ServiceReference ref = context.getServiceReference(Probe.class.getName()); - assertNotNull("Service Reference is null", ref); - Probe probe = null; - - probe = (Probe) context.getService(ref); - assertNotNull("Cannot find the probe service", probe); - - try { - probe.testCommonslogging(); - - } catch (Throwable t) { - fail("Failed to execute the probe.testCommonsLogging. "+t); - } - context.ungetService(ref); - } - -} diff --git a/trunk/slf4j-osgi-integration-test/src/test/resources/log4j.properties b/trunk/slf4j-osgi-integration-test/src/test/resources/log4j.properties deleted file mode 100644 index 24c9317ad..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/resources/log4j.properties +++ /dev/null @@ -1,9 +0,0 @@ -log4j.rootCategory=DEBUG,console - -# Console Appender -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.target=System.out -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%-5p %l - %m%n - -log4j.logger.org.springframework.osgi=DEBUG \ No newline at end of file diff --git a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/jdk/test/MANIFEST.MF b/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/jdk/test/MANIFEST.MF deleted file mode 100644 index a0bf3b82d..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/jdk/test/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: simple-service-integration-tests -Bundle-SymbolicName: org.slf4j.osgi.integration.jdk.test -Bundle-Vendor: SLF4J ORG -Bundle-Activator: org.springframework.osgi.test.JUnitTestActivator -Import-Package: junit.framework, - org.osgi.framework;specification-version="1.3.0", - org.springframework.core.io;specification-version="2.1.0", - org.springframework.osgi.test, - org.slf4j, - org.slf4j.osgi.test.service - - - diff --git a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/log4j/test/MANIFEST.MF b/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/log4j/test/MANIFEST.MF deleted file mode 100644 index 1c2ca1530..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/log4j/test/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: simple-service-integration-tests -Bundle-SymbolicName: org.slf4j.osgi.integration.log4j.test -Bundle-Vendor: SLF4J ORG -Bundle-Activator: org.springframework.osgi.test.JUnitTestActivator -Import-Package: junit.framework, - org.osgi.framework;specification-version="1.3.0", - org.springframework.core.io;specification-version="2.1.0", - org.springframework.osgi.test, - org.slf4j, - org.slf4j.osgi.test.service - - - diff --git a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/logservice/test/MANIFEST.MF b/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/logservice/test/MANIFEST.MF deleted file mode 100644 index 22255fcc4..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/logservice/test/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: simple-service-integration-tests -Bundle-SymbolicName: org.slf4j.osgi.integration.logservice.test -Bundle-Version: 1.3.0 -Bundle-Vendor: SLF4J ORG -Bundle-Activator: org.springframework.osgi.test.JUnitTestActivator -Import-Package: junit.framework, - org.osgi.framework;specification-version="1.3.0", - org.springframework.core.io;specification-version="2.1.0", - org.springframework.osgi.test, - org.slf4j, - org.osgi.service.log - - - diff --git a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/nop/test/MANIFEST.MF b/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/nop/test/MANIFEST.MF deleted file mode 100644 index eebfd6bd7..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/nop/test/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: simple-service-integration-tests -Bundle-SymbolicName: org.slf4j.osgi.integration.nop.test -Bundle-Vendor: SLF4J ORG -Bundle-Activator: org.springframework.osgi.test.JUnitTestActivator -Import-Package: junit.framework, - org.osgi.framework;specification-version="1.3.0", - org.springframework.core.io;specification-version="2.1.0", - org.springframework.osgi.test, - org.slf4j, - org.slf4j.osgi.test.service - - - diff --git a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/simple/test/MANIFEST.MF b/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/simple/test/MANIFEST.MF deleted file mode 100644 index 2f03e1a85..000000000 --- a/trunk/slf4j-osgi-integration-test/src/test/resources/org/slf4j/osgi/integration/simple/test/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: simple-service-integration-tests -Bundle-SymbolicName: org.slf4j.osgi.integration.simple.test -Bundle-Vendor: SLF4J ORG -Bundle-Activator: org.springframework.osgi.test.JUnitTestActivator -Import-Package: junit.framework, - org.osgi.framework;specification-version="1.3.0", - org.springframework.core.io;specification-version="2.1.0", - org.springframework.osgi.test, - org.slf4j, - org.slf4j.osgi.test.service - - - diff --git a/trunk/slf4j-osgi-test-bundle/pom.xml b/trunk/slf4j-osgi-test-bundle/pom.xml deleted file mode 100644 index ad6e22879..000000000 --- a/trunk/slf4j-osgi-test-bundle/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-osgi-test-bundle - bundle - SLF4J Testing Bundle - - http://www.slf4j.org - - The slf4j OSGi testing bundle. - - - - - org.slf4j - slf4j-api - provided - - - - org.slf4j - slf4j-nop - ${project.version} - provided - - - - - org.slf4j - jcl-over-slf4j - ${project.version} - provided - - - - org.apache.felix - org.osgi.core - 0.8.0-SNAPSHOT - provided - - - - - - - org.apache.felix - maven-bundle-plugin - 0.9.0-incubator-SNAPSHOT - true - - - - org.slf4j.osgi.test.service - - org.slf4j.osgi.test - - org.osgi.framework,org.slf4j;version="[1.3,1.4)" - - org.slf4j.osgi.test.Activator - org.apache.commons.logging - - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/Activator.java b/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/Activator.java deleted file mode 100644 index cd95f2822..000000000 --- a/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/Activator.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.test; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceEvent; -import org.osgi.framework.ServiceListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.Marker; -import org.slf4j.MarkerFactory; -import org.slf4j.osgi.test.service.Probe; - -import java.util.Hashtable; - -/** - * Activator implements a simple bundle to test OSGi slf4j - * logging components. - * - * Upon startup, shutdown, and receiving a service event, it logs event - * details. - * - * On startup it logs a series of messages. - * - * @author John Conlon - */ -public class Activator implements BundleActivator, ServiceListener { - - private final Logger log = LoggerFactory.getLogger(Activator.class); - - /** - * Implements BundleActivator.start(). Logs a message adds - * itself to the bundle context as a service listener, and exercises the - * logger. - * - * @param bundleContext - * the framework context for the bundle - * @throws Exception - */ - public void start(BundleContext bundleContext) throws Exception { - log.info("Starting to listen for service events."); - bundleContext.addServiceListener(this); - - Probe probe = new ProbeImpl(); - Hashtable props = new Hashtable(); - props.put("description", "Service for testing slf4j components."); - bundleContext.registerService(Probe.class.getName(),probe, props); - - test1(); - test2(); - testNull(); - testMarker(); - } - - /** - * Implements BundleActivator.stop(). Prints a message and - * removes itself from the bundle context as a service listener. - * - * @param bundleContext - * the framework context for the bundle - * @throws Exception - */ - public void stop(BundleContext bundleContext) throws Exception { - bundleContext.removeServiceListener(this); - log.info("Stopped listening for service events."); - - // Note: It is not required that we remove the listener here, since - // the framework will do it automatically anyway. - } - - /** - * Implements ServiceListener.serviceChanges(). Logs the - * details of any service event from the framework. - * - * @param event - * the fired service event - */ - public void serviceChanged(ServiceEvent event) { - String[] objectClass = (String[]) event.getServiceReference() - .getProperty("objectClass"); - if (event.getType() == ServiceEvent.REGISTERED) { - log.info("SimpleBundle: Service of type {} registered.", - objectClass[0]); - } else if (event.getType() == ServiceEvent.UNREGISTERING) { - log.info("SimpleBundle: Service of type {} unregistered.", - objectClass[0]); - } else if (event.getType() == ServiceEvent.MODIFIED) { - log.info("SimpleBundle: Service of type {} modified.", - objectClass[0]); - } - } - - public void test1() { - Logger logger = LoggerFactory.getLogger("test1"); - logger.debug("Hello world."); - } - - public void test2() { - Integer i1 = new Integer(1); - Integer i2 = new Integer(2); - Integer i3 = new Integer(3); - Exception e = new Exception("This is a test exception."); - Logger logger = LoggerFactory.getLogger("test2"); - - logger.debug("Hello world 1."); - logger.debug("Hello world {}", i1); - logger.debug("val={} val={}", i1, i2); - logger.debug("val={} val={} val={}", new Object[] { i1, i2, i3 }); - - logger.debug("Hello world 2", e); - logger.info("Hello world 2."); - - logger.warn("Hello world 3."); - logger.warn("Hello world 3", e); - - logger.error("Hello world 4."); - logger.error("Hello world {}", new Integer(3)); - logger.error("Hello world 4.", e); - } - - public void testNull() { - Logger logger = LoggerFactory.getLogger("testNull"); - logger.debug(null); - logger.info(null); - logger.warn(null); - logger.error(null); - - Exception e = new Exception("This is a test exception."); - logger.debug(null, e); - logger.info(null, e); - logger.warn(null, e); - logger.error(null, e); - } - - public void testMarker() { - Logger logger = LoggerFactory.getLogger("testMarker"); - Marker blue = MarkerFactory.getMarker("BLUE"); - logger.debug(blue, "hello"); - logger.info(blue, "hello"); - logger.warn(blue, "hello"); - logger.error(blue, "hello"); - - logger.debug(blue, "hello {}", "world"); - logger.info(blue, "hello {}", "world"); - logger.warn(blue, "hello {}", "world"); - logger.error(blue, "hello {}", "world"); - - logger.debug(blue, "hello {} and {} ", "world", "universe"); - logger.info(blue, "hello {} and {} ", "world", "universe"); - logger.warn(blue, "hello {} and {} ", "world", "universe"); - logger.error(blue, "hello {} and {} ", "world", "universe"); - } -} diff --git a/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/CommonsLoggingTester.java b/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/CommonsLoggingTester.java deleted file mode 100644 index ad1ba139a..000000000 --- a/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/CommonsLoggingTester.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.test; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * CommonsLoggingTester tests org.apache.commons.logging functionality. - * - * @author John Conlon - */ -public class CommonsLoggingTester { - - boolean testCommonslogging() throws Exception { - testIsEnabledAPI(); - testPrintAPI(); - return true; - } - - public void testIsEnabledAPI() { - // assume that we are running over slf4j-simple - Log log = LogFactory.getLog(CommonsLoggingTester.class); - assertFalse("Trace was enabled", log.isTraceEnabled()); - assertFalse("Debug was enabled", log.isDebugEnabled()); - assertTrue("Info was not enabled", log.isInfoEnabled()); - assertTrue("Warn was not enabled", log.isWarnEnabled()); - assertTrue("Error was not enabled", log.isErrorEnabled()); - assertTrue("Fatal was not enabled", log.isFatalEnabled()); - } - - private void assertFalse(String failureMessage, boolean value) { - if (value) { - throw new IllegalStateException(failureMessage); - } - } - - private void assertTrue(String failureMessage, boolean value) { - if (!value) { - throw new IllegalStateException(failureMessage); - } - } - - public void testPrintAPI() { - Log log = LogFactory.getLog(CommonsLoggingTester.class); - Exception e = new Exception("just testing"); - - log.trace(null); - log.trace("trace message"); - - log.debug(null); - log.debug("debug message"); - - log.info(null); - log.info("info message"); - - log.warn(null); - log.warn("warn message"); - - log.error(null); - log.error("error message"); - - log.fatal(null); - log.fatal("fatal message"); - - log.trace(null, e); - log.trace("trace message", e); - - log.debug(null, e); - log.debug("debug message", e); - - log.info(null, e); - log.info("info message", e); - - log.warn(null, e); - log.warn("warn message", e); - - log.error(null, e); - log.error("error message", e); - - log.fatal(null, e); - log.fatal("fatal message", e); - } -} diff --git a/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/ProbeImpl.java b/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/ProbeImpl.java deleted file mode 100644 index e5ea67f31..000000000 --- a/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/ProbeImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.test; - -import org.slf4j.osgi.test.service.Probe; - -/** - * ProbeImpl a simple implementation of the Probe interface for testing - * Slf4j components. - * - * @author John Conlon - */ -public class ProbeImpl implements Probe{ - - /** - * - * @throws ClassNotFoundException If there is not a bundle exporting - * the org.apache.commons.logging package - * - */ - public boolean testCommonslogging() throws Exception{ - return new CommonsLoggingTester().testCommonslogging(); - } - -} diff --git a/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/service/Probe.java b/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/service/Probe.java deleted file mode 100644 index 1229d2e94..000000000 --- a/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/service/Probe.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.osgi.test.service; - -/** - * Probe is a service for testing accessibility of - * Slf4j components from the test bundle. - * - * @author John Conlon - * @version $Rev$, $Date$ - */ -public interface Probe { - - /** - * - * testCommonslogging - * - * @return true if all the tests were executed. - * @throws ClassNotFoundError if a org.apache.commons.logging package - * could not be dynamically imported from the OSGi runtime. - * @throws Exception if testing fails - */ - boolean testCommonslogging() throws Exception; - -} diff --git a/trunk/slf4j-simple/LICENSE.txt b/trunk/slf4j-simple/LICENSE.txt deleted file mode 100644 index f6e2f31f7..000000000 --- a/trunk/slf4j-simple/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2004-2007 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - diff --git a/trunk/slf4j-simple/pom.xml b/trunk/slf4j-simple/pom.xml deleted file mode 100644 index 4563ee522..000000000 --- a/trunk/slf4j-simple/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-simple - jar - SLF4J Simple Binding - - http://www.slf4j.org - SLF4J Simple binding - - - - org.slf4j - slf4j-api - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.version} - ${project.description} - ${project.version} - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java b/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java deleted file mode 100644 index d49883b8f..000000000 --- a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import org.slf4j.helpers.MarkerIgnoringBase; -import org.slf4j.helpers.MessageFormatter; - -/** - * A simple (and direct) implementation that logs messages of level - * INFO or higher on the console (System.err). - * - *

The output includes the relative time in milliseconds, thread - * name, the level, logger name, and the message followed by the line - * separator for the host. In log4j terms it amounts to the "%r [%t] - * %level %logger - %m%n" pattern.

- * - *

Sample output follows.

-
-176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order.
-225 [main] INFO examples.SortAlgo - Entered the sort method.
-304 [main] INFO examples.SortAlgo - Dump of integer array:
-317 [main] INFO examples.SortAlgo - Element [0] = 0
-331 [main] INFO examples.SortAlgo - Element [1] = 1
-343 [main] INFO examples.Sort - The next log statement should be an error message.
-346 [main] ERROR examples.SortAlgo - Tried to dump an uninitialized array.
-        at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
-        at org.log4j.examples.Sort.main(Sort.java:64)
-467 [main] INFO  examples.Sort - Exiting main method.
-
- * - * @author Ceki Gülcü - */ -public class SimpleLogger extends MarkerIgnoringBase { - /** - * Mark the time when this class gets loaded into memory. - */ - private static long startTime = System.currentTimeMillis(); - public static final String LINE_SEPARATOR = - System.getProperty("line.separator"); - private static String INFO_STR = "INFO"; - private static String WARN_STR = "WARN"; - private static String ERROR_STR = "ERROR"; - String name; - - /** - * Package access allows only {@link SimpleLoggerFactory} to instantiate - * SimpleLogger instances. - */ - SimpleLogger(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - /** - * Always returns false. - * @return always false - */ - public boolean isTraceEnabled() { - return false; - } - - /** - * A NOP implementation, as this logger is permanently disabled for - * the TRACE level. - */ - public void trace(String msg) { - // NOP - } - - /** - * A NOP implementation, as this logger is permanently disabled for - * the TRACE level. - */ - public void trace(String format, Object param1) { - // NOP - } - - - /** - * A NOP implementation, as this logger is permanently disabled for - * the TRACE level. - */ - public void trace(String format, Object param1, Object param2) { - // NOP - } - - public void trace(String format, Object[] argArray) { - // NOP - } - - /** - * A NOP implementation, as this logger is permanently disabled for - * the TRACE level. - */ - public void trace(String msg, Throwable t) { - // NOP - } - - - /** - * Always returns false. - * @return always false - */ - public boolean isDebugEnabled() { - return false; - } - - /** - * A NOP implementation, as this logger is permanently disabled for - * the DEBUG level. - */ - public void debug(String msg) { - // NOP - } - - /** - * A NOP implementation, as this logger is permanently disabled for - * the DEBUG level. - */ - public void debug(String format, Object param1) { - // NOP - } - - - /** - * A NOP implementation, as this logger is permanently disabled for - * the DEBUG level. - */ - public void debug(String format, Object param1, Object param2) { - // NOP - } - - public void debug(String format, Object[] argArray) { - // NOP - } - - /** - * A NOP implementation, as this logger is permanently disabled for - * the DEBUG level. - */ - public void debug(String msg, Throwable t) { - // NOP - } - - /** - * This is our internal implementation for logging regular (non-parameterized) - * log messages. - * - * @param level - * @param message - * @param t - */ - private void log(String level, String message, Throwable t) { - StringBuffer buf = new StringBuffer(); - - long millis = System.currentTimeMillis(); - buf.append(millis - startTime); - - buf.append(" ["); - buf.append(Thread.currentThread().getName()); - buf.append("] "); - - buf.append(level); - buf.append(" "); - - buf.append(name); - buf.append(" - "); - - buf.append(message); - - buf.append(LINE_SEPARATOR); - - System.err.print(buf.toString()); - if (t != null) { - t.printStackTrace(System.err); - } - System.err.flush(); - } - - /** - * For formatted messages, first substitute arguments and then log. - * - * @param level - * @param format - * @param param1 - * @param param2 - */ - private void formatAndLog( - String level, String format, Object arg1, Object arg2) { - String message = MessageFormatter.format(format, arg1, arg2); - log(level, message, null); - } - - /** - * For formatted messages, first substitute arguments and then log. - * - * @param level - * @param format - * @param argArray - */ - private void formatAndLog(String level, String format, Object[] argArray) { - String message = MessageFormatter.arrayFormat(format, argArray); - log(level, message, null); - } - - /** - * Always returns true. - */ - public boolean isInfoEnabled() { - return true; - } - - /** - * A simple implementation which always logs messages of level INFO according - * to the format outlined above. - */ - public void info(String msg) { - log(INFO_STR, msg, null); - } - - /** - * Perform single parameter substitution before logging the message of level - * INFO according to the format outlined above. - */ - public void info(String format, Object arg) { - formatAndLog(INFO_STR, format, arg, null); - } - - /** - * Perform double parameter substitution before logging the message of level - * INFO according to the format outlined above. - */ - public void info(String format, Object arg1, Object arg2) { - formatAndLog(INFO_STR, format, arg1, arg2); - } - - /** - * Perform double parameter substitution before logging the message of level - * INFO according to the format outlined above. - */ - public void info(String format, Object[] argArray) { - formatAndLog(INFO_STR, format, argArray); - } - - - /** - * Log a message of level INFO, including an exception. - */ - public void info(String msg, Throwable t) { - log(INFO_STR, msg, t); - } - - /** - * Always returns true. - */ - public boolean isWarnEnabled() { - return true; - } - - /** - * A simple implementation which always logs messages of level WARN according - * to the format outlined above. - */ - public void warn(String msg) { - log(WARN_STR, msg, null); - } - - /** - * Perform single parameter substitution before logging the message of level - * WARN according to the format outlined above. - */ - public void warn(String format, Object arg) { - formatAndLog(WARN_STR, format, arg, null); - } - - /** - * Perform double parameter substitution before logging the message of level - * WARN according to the format outlined above. - */ - public void warn(String format, Object arg1, Object arg2) { - formatAndLog(WARN_STR, format, arg1, arg2); - } - - /** - * Perform double parameter substitution before logging the message of level - * WARN according to the format outlined above. - */ - public void warn(String format, Object[] argArray) { - formatAndLog(WARN_STR, format, argArray); - } - - /** - * Log a message of level WARN, including an exception. - */ - public void warn(String msg, Throwable t) { - log(WARN_STR, msg, t); - } - - /** - * Always returns true. - */ - public boolean isErrorEnabled() { - return true; - } - - /** - * A simple implementation which always logs messages of level ERROR according - * to the format outlined above. - */ - public void error(String msg) { - log(ERROR_STR, msg, null); - } - - /** - * Perform single parameter substitution before logging the message of level - * ERROR according to the format outlined above. - */ - public void error(String format, Object arg) { - formatAndLog(ERROR_STR, format, arg, null); - } - - /** - * Perform double parameter substitution before logging the message of level - * ERROR according to the format outlined above. - */ - public void error(String format, Object arg1, Object arg2) { - formatAndLog(ERROR_STR, format, arg1, arg2); - } - - /** - * Perform double parameter substitution before logging the message of level - * ERROR according to the format outlined above. - */ - public void error(String format, Object[] argArray) { - formatAndLog(ERROR_STR, format, argArray); - } - - - /** - * Log a message of level ERROR, including an exception. - */ - public void error(String msg, Throwable t) { - log(ERROR_STR, msg, t); - } -} diff --git a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLoggerFactory.java b/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLoggerFactory.java deleted file mode 100644 index 6414a5420..000000000 --- a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLoggerFactory.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2004-2005 SLF4J.ORG - * Copyright (c) 2004-2005 QOS.ch - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.ILoggerFactory; - -/** - * An implementation of {@link ILoggerFactory} which always returns - * {@link SimpleLogger} instances. - * - * @author Ceki Gülcü - */ -public class SimpleLoggerFactory implements ILoggerFactory { - - final static SimpleLoggerFactory INSTANCE = new SimpleLoggerFactory(); - - Map loggerMap; - - public SimpleLoggerFactory() { - loggerMap = new HashMap(); - } - - /** - * Return an appropriate {@link SimpleLogger} instance by name. - */ - public Logger getLogger(String name) { - Logger slogger = null; - // protect against concurrent access of the loggerMap - synchronized (this) { - slogger = (Logger) loggerMap.get(name); - if (slogger == null) { - slogger = new SimpleLogger(name); - loggerMap.put(name, slogger); - } - } - return slogger; - } -} diff --git a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticLoggerBinder.java deleted file mode 100644 index 8a5ee00e5..000000000 --- a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.impl; - -import org.slf4j.ILoggerFactory; -import org.slf4j.LoggerFactory; -import org.slf4j.spi.LoggerFactoryBinder; - -/** - * The binding of {@link LoggerFactory} class with an actual instance of - * {@link ILoggerFactory} is performed using information returned by this class. - * - * - * @author Ceki Gülcü - */ -public class StaticLoggerBinder implements LoggerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - // Note: JCL gets substituted at build time by an appropriate Ant task - private static final String loggerFactoryClassStr = SimpleLoggerFactory.class.getName(); - - /** The ILoggerFactory instance returned by the {@link #getLoggerFactory} method - * should always be the same object - */ - private final ILoggerFactory loggerFactory; - - private StaticLoggerBinder() { -// Note: JCL gets substituted at build time by an appropriate Ant task - loggerFactory = new SimpleLoggerFactory(); - } - - public ILoggerFactory getLoggerFactory() { - return loggerFactory; - } - - public String getLoggerFactoryClassStr() { - return loggerFactoryClassStr; - } -} diff --git a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticMDCBinder.java deleted file mode 100644 index a397bce7e..000000000 --- a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticMDCBinder.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.slf4j.impl; - -import org.slf4j.helpers.NOPMakerAdapter; -import org.slf4j.spi.MDCAdapter; - - -/** - * This implementation is bound to {@link NOPMakerAdapter}. - * - * @author Ceki Gülcü - */ -public class StaticMDCBinder { - - - /** - * The unique instance of this class. - */ - public static final StaticMDCBinder SINGLETON = new StaticMDCBinder(); - - private StaticMDCBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link StaticMDCBinder}. - */ - public MDCAdapter getMDCA() { - return new NOPMakerAdapter(); - } - - public String getMDCAdapterClassStr() { - return NOPMakerAdapter.class.getName(); - } -} diff --git a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticMarkerBinder.java deleted file mode 100644 index 6017ea9cc..000000000 --- a/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticMarkerBinder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -package org.slf4j.impl; - -import org.slf4j.IMarkerFactory; -import org.slf4j.MarkerFactory; -import org.slf4j.helpers.BasicMarkerFactory; -import org.slf4j.spi.MarkerFactoryBinder; - -/** - * - * The binding of {@link MarkerFactory} class with an actual instance of - * {@link IMarkerFactory} is performed using information returned by this class. - * - * @author Ceki Gülcü - */ -public class StaticMarkerBinder implements MarkerFactoryBinder { - - /** - * The unique instance of this class. - */ - public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder(); - - final IMarkerFactory markerFactory = new BasicMarkerFactory(); - - private StaticMarkerBinder() { - } - - /** - * Currently this method always returns an instance of - * {@link BasicMarkerFactory}. - */ - public IMarkerFactory getMarkerFactory() { - return markerFactory; - } - - /** - * Currently, this method returns the class name of - * {@link BasicMarkerFactory}. - */ - public String getMarkerFactoryClassStr() { - return BasicMarkerFactory.class.getName(); - } - - -} diff --git a/trunk/slf4j-simple/src/main/resources/META-INF/MANIFEST.MF b/trunk/slf4j-simple/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 84ebee0be..000000000 --- a/trunk/slf4j-simple/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,10 +0,0 @@ -Implementation-Title: slf4j-simple -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: slf4j.simple -Bundle-Name: slf4j-simple -Bundle-Vendor: SLF4J.ORG -Require-Bundle: slf4j.api -Bundle-RequiredExecutionEnvironment: J2SE-1.3 -Export-Package: org.slf4j.impl;version=${project.version} -Import-Package: org.slf4j;version=${project.version}, org.slf4j.spi;version=${project.version}, org.slf4j.helpers;version=${project.version} -Fragment-Host: slf4j.api \ No newline at end of file diff --git a/trunk/slf4j-simple/src/test/java/org/slf4j/InvocationTest.java b/trunk/slf4j-simple/src/test/java/org/slf4j/InvocationTest.java deleted file mode 100644 index fb83a0dbc..000000000 --- a/trunk/slf4j-simple/src/test/java/org/slf4j/InvocationTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2004-2007 QOS.CH - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - * - */ - -package org.slf4j; - -import junit.framework.TestCase; - - -/** - * Test whether invoking the SLF4J API causes problems or not. - * - * @author Ceki Gulcu - * - */ -public class InvocationTest extends TestCase { - - public InvocationTest (String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void test1() { - Logger logger = LoggerFactory.getLogger("test1"); - logger.debug("Hello world."); - } - - public void test2() { - Integer i1 = new Integer(1); - Integer i2 = new Integer(2); - Integer i3 = new Integer(3); - Exception e = new Exception("This is a test exception."); - Logger logger = LoggerFactory.getLogger("test2"); - - logger.debug("Hello world 1."); - logger.debug("Hello world {}", i1); - logger.debug("val={} val={}", i1, i2); - logger.debug("val={} val={} val={}", new Object[]{i1, i2, i3}); - - logger.debug("Hello world 2", e); - logger.info("Hello world 2."); - - - logger.warn("Hello world 3."); - logger.warn("Hello world 3", e); - - - logger.error("Hello world 4."); - logger.error("Hello world {}", new Integer(3)); - logger.error("Hello world 4.", e); - } - - // http://bugzilla.slf4j.org/show_bug.cgi?id=78 - public void testNullParameter_BUG78() { - Logger logger = LoggerFactory.getLogger("testNullParameter_BUG78"); - String[] parameters = null; - String msg = "hello {}"; - logger.info(msg, parameters); - } - - public void testNull() { - Logger logger = LoggerFactory.getLogger("testNull"); - logger.debug(null); - logger.info(null); - logger.warn(null); - logger.error(null); - - Exception e = new Exception("This is a test exception."); - logger.debug(null, e); - logger.info(null, e); - logger.warn(null, e); - logger.error(null, e); - } - - public void testMarker() { - Logger logger = LoggerFactory.getLogger("testMarker"); - Marker blue = MarkerFactory.getMarker("BLUE"); - logger.debug(blue, "hello"); - logger.info(blue, "hello"); - logger.warn(blue, "hello"); - logger.error(blue, "hello"); - - logger.debug(blue, "hello {}", "world"); - logger.info(blue, "hello {}", "world"); - logger.warn(blue, "hello {}", "world"); - logger.error(blue, "hello {}", "world"); - - logger.debug(blue, "hello {} and {} ", "world", "universe"); - logger.info(blue, "hello {} and {} ", "world", "universe"); - logger.warn(blue, "hello {} and {} ", "world", "universe"); - logger.error(blue, "hello {} and {} ", "world", "universe"); - } - - public void testMDC() { - MDC.put("k", "v"); - assertNull(MDC.get("k")); - MDC.remove("k"); - assertNull(MDC.get("k")); - MDC.clear(); - } -} diff --git a/trunk/slf4j-site/LICENSE.txt b/trunk/slf4j-site/LICENSE.txt deleted file mode 100644 index f6e2f31f7..000000000 --- a/trunk/slf4j-site/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2004-2007 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - diff --git a/trunk/slf4j-site/pom.xml b/trunk/slf4j-site/pom.xml deleted file mode 100644 index 8410b5f2a..000000000 --- a/trunk/slf4j-site/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - org.slf4j - slf4j-parent - 1.5.1 - - - 4.0.0 - - org.slf4j - slf4j-site - ${parent.version} - jar - SLF4J Site - - http://www.slf4j.org - - - - - src/site/pages - - ../../../target/site - true - - - - - - - - - org.apache.maven.plugins - maven-site-plugin - - ${project.parent.basedir}/target/site - - - - org.apache.maven.plugins - - maven-project-info-reports-plugin - - - - - - - - - - - - \ No newline at end of file diff --git a/trunk/slf4j-site/src/site/images.src/bindings.flw b/trunk/slf4j-site/src/site/images.src/bindings.flw deleted file mode 100644 index 2643b2454..000000000 Binary files a/trunk/slf4j-site/src/site/images.src/bindings.flw and /dev/null differ diff --git a/trunk/slf4j-site/src/site/images.src/bindings.png b/trunk/slf4j-site/src/site/images.src/bindings.png deleted file mode 100644 index d826a8a94..000000000 Binary files a/trunk/slf4j-site/src/site/images.src/bindings.png and /dev/null differ diff --git a/trunk/slf4j-site/src/site/images.src/bridging.flw b/trunk/slf4j-site/src/site/images.src/bridging.flw deleted file mode 100644 index 1e6b77784..000000000 Binary files a/trunk/slf4j-site/src/site/images.src/bridging.flw and /dev/null differ diff --git a/trunk/slf4j-site/src/site/images.src/bridging.png b/trunk/slf4j-site/src/site/images.src/bridging.png deleted file mode 100644 index 622a0f08a..000000000 Binary files a/trunk/slf4j-site/src/site/images.src/bridging.png and /dev/null differ diff --git a/trunk/slf4j-site/src/site/pages/bug-reporting.html b/trunk/slf4j-site/src/site/pages/bug-reporting.html deleted file mode 100644 index 940adb3e5..000000000 --- a/trunk/slf4j-site/src/site/pages/bug-reporting.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - -SLF4J Bug reporting - - - - - - -
- -
- -
- - -

Before you report a bug

- -

The SLF4J community consists of those who use SLF4J and its - implementations, help answer questions on discussions lists, - contribute documentation and patches, and those who develop and - maintain the code for SLF4J and its implementations. Almost all - those who assist on a day to day basis resolving bug reports do - this for a wide variety of reasons, and almost all of them do this - on their own time. -

- -

Many bugs reported end up not being a bug in SLF4J, but are due - to misconfiguration, problems caused by installed applications, - the operating system, etc. -

- -

Before reporting a bug please make every effort to resolve the - problem yourself. Just reporting a bug will not fix it. A good - bug report includes a detailed description of the problem and a - succinct test case which can reproduce the problem. -

- -

Review the documentation

- -

Review the documentation for the version of component you are - using. The problem you are having may already be addressed in the - docs. -

- -

Search the mailing list archives

- -

It is very likely you are not the first to run into a problem. - Others may have already found a solution. Our various mailing lists are likely to have - discussed this problem before. -

- -

Search Bugzilla

- -

Please search the bug database to see if the bug you are seeing - has already been reported. The bug may have already been fixed - and is available in a later version. If someone else has reported - the same bug, you could add supporting information to help - reproduce and resolve the bug. -

- - -

Reporting with Bugzilla

- -

Onlly after you have exhausted the aforementioned steps, should - you file a formal report in bugzilla. -

- -

Please make sure you provide as much information as - possible. Its very hard to fix a bug if the person looking into - the problem can't reproduce it. -

- - - - - - - - -
- - diff --git a/trunk/slf4j-site/src/site/pages/changes/changes-1.3.txt b/trunk/slf4j-site/src/site/pages/changes/changes-1.3.txt deleted file mode 100644 index 4e9a71125..000000000 --- a/trunk/slf4j-site/src/site/pages/changes/changes-1.3.txt +++ /dev/null @@ -1,45 +0,0 @@ - -Changes in SLF4J 1.3.0 with respect to 1.2 as reported by the clirr -tool. - -slf4j-api -========= - -INFO: 6000: org.slf4j.Logger: Added public field ROOT_LOGGER_NAME -INFO: 8000: org.slf4j.LoggerFactory: Class org.slf4j.LoggerFactory added -INFO: 8000: org.slf4j.MarkerFactory: Class org.slf4j.MarkerFactory added -INFO: 8000: org.slf4j.helpers.BasicMarker: Class org.slf4j.helpers.BasicMarker added -INFO: 8000: org.slf4j.helpers.BasicMarkerFactory: Class org.slf4j.helpers.BasicMarkerFactory added -INFO: 8000: org.slf4j.helpers.MarkerIgnoringBase: Class org.slf4j.helpers.MarkerIgnoringBase added -INFO: 8000: org.slf4j.helpers.MessageFormatter: Class org.slf4j.helpers.MessageFormatter added -INFO: 8000: org.slf4j.helpers.Util: Class org.slf4j.helpers.Util added -ERROR: 8001: org.slf4j.impl.BasicMarker: Class org.slf4j.impl.BasicMarker removed -ERROR: 8001: org.slf4j.impl.BasicMarkerFactory: Class org.slf4j.impl.BasicMarkerFactory removed -ERROR: 8001: org.slf4j.impl.MarkerIgnoringBase: Class org.slf4j.impl.MarkerIgnoringBase removed -ERROR: 8001: org.slf4j.impl.MessageFormatter: Class org.slf4j.impl.MessageFormatter removed -ERROR: 8001: org.slf4j.impl.Util: Class org.slf4j.impl.Util removed -INFO: 8000: org.slf4j.spi.LocationAwareLogger: Class org.slf4j.spi.LocationAwareLogger added - -slf4j-nop -========= - -ERROR: 8001: org.slf4j.LoggerFactory: Class org.slf4j.LoggerFactory removed -ERROR: 8001: org.slf4j.MarkerFactory: Class org.slf4j.MarkerFactory removed - -slf4j-simple -============ - -ERROR: 8001: org.slf4j.LoggerFactory: Class org.slf4j.LoggerFactory removed -ERROR: 8001: org.slf4j.MarkerFactory: Class org.slf4j.MarkerFactory removed - -slf4j-log4j12 -============= - -ERROR: 8001: org.slf4j.LoggerFactory: Class org.slf4j.LoggerFactory removed -ERROR: 8001: org.slf4j.MarkerFactory: Class org.slf4j.MarkerFactory removed - -slf4j-jdk14 -=========== - -ERROR: 8001: org.slf4j.LoggerFactory: Class org.slf4j.LoggerFactory removed -ERROR: 8001: org.slf4j.MarkerFactory: Class org.slf4j.MarkerFactory removed \ No newline at end of file diff --git a/trunk/slf4j-site/src/site/pages/codes.html b/trunk/slf4j-site/src/site/pages/codes.html deleted file mode 100644 index af791dc34..000000000 --- a/trunk/slf4j-site/src/site/pages/codes.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - -SLF4J Error Codes - - - - - - -
- -
- -
- -
-

SLF4J warning or error messages and their meanings

- -
- - -

- - The method - o.a.commons.logging.impl.SLF4FLogFactory#release - was invoked. - -

- -

Given the structure of the commons-logging API, in particular - as implemented by SLF4J, the - o.a.commons.logging.impl.SLF4FLogFactory#release() - method should never be called. However, depending on the - deployment of commons-logging.jar files in your servlet - container, release() method may be unexpectedly - invoked by a copy of - org.apache.commons.logging.LogFactory class shipping - with commons-logging.jar. -

- -

This is a relatively common occurrence with recent versions of - Tomcat, especially if you place jcl-over-slf4j.jar in - WEB-INF/lib directory of your web-application instead of - $TOMCAT_HOME/common/lib, where $TOMCAT_HOME stands for - the directory where Tomcat is installed. In order to fully benefit - from the stability offered by jcl-over-slf4j.jar, we - recommend that you place jcl-over-slf4j.jar in - $TOMCAT_HOME/common/lib without placing a copy in your - web-applications. -

- -

Please also see bug - #22.

- - -

- - Operation [suchAndSuch] is not supported in jcl-over-slf4j. - -

- -

An UnsuportedOperationException is thrown whenever - one of the protected methods introduced in JCL 1.1 are - invoked. These methods are invoked by LogFactory - implementations shipping with - commons-logging.jar. However, the LogFactory - implemented by jcl-over-slf4j.jar, namely - SLF4FLogFactory, does not call any of these methods. -

- -

If you observe this problem, then it is higly probable that you - have a copy of commons-logging.jar in your class path - overriding the classes shipping with - jcl-over-slf4j.jar. Note that this issue is very similar - in nature to the warning issued when the - "o.a.commons.logging.impl.SLF4FLogFactory.release()" method is - invoked, discussed in the previous item. -

- -

- - Failed to load class - org.slf4j.impl.StaticLoggerBinder - -

- -

This error is reported when the - org.slf4j.impl.StaticLoggerBinder class could not be - loaded into memory. This happens when no appropriate SLF4J - binding could be found on the class path. Placing one (and only - one) of slf4j-nop.jar, slf4j-simple.jar, - slf4j-log4j12.jar, slf4j-jdk14.jar or - logback-classic.jar on the class path should solve the - problem. -

- -

- Logging factory implementation - cannot be null -

- -

This error is reported when the LoggerFactory - class could not find an appropriate binding. Placing one (and only - one) of slf4j-nop.jar, slf4j-simple.jar, - slf4j-log4j12.jar, slf4j-jdk14.jar or - logback-classic.jar on the class path should prove to be - an effective remedy. -

- - -

- Failed to load class - "org.slf4j.impl.StaticMDCBinder" - -

- -

This error indicates that appropriate SLF4J binding could not - be found on the class path. Placing one (and only one) of - slf4j-nop.jar, slf4j-simple.jar, - slf4j-log4j12.jar, slf4j-jdk14.jar or - logback-classic.jar on the class path should solve the - problem. -

- -

- MDCAdapter cannot be null - -

- -

This error is reported when org.slf4j.MDC class - has not been initialized correctly. Same cause and remedy as the - previously listed item. -

- - -

SLF4J versions - 1.4.0 and later requires log4j 1.2.12 or later

- -

The trace level was added to log4j in version 1.2.12 released - on August 29, 2005. The trace level was added to the SLF4J API in - version 1.4.0 on May 16th, 2007. Thus, starting with SLF4J 1.4.0, - the log4j binding for SLF4J requires log4j version 1.2.12 or - above. -

- -

However, as reported in bug 68, in - some environments it may be difficult to upgrade the log4j - version. To accomodate such circumstances, SLF4J's - Log4jLoggerAdapter will map the TRACE level as - DEBUG.

- - - -
- - - \ No newline at end of file diff --git a/trunk/slf4j-site/src/site/pages/compatibility.html b/trunk/slf4j-site/src/site/pages/compatibility.html deleted file mode 100644 index 361593fbe..000000000 --- a/trunk/slf4j-site/src/site/pages/compatibility.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - -Compatibility report - - - - - - -
- -
- -
- - -

Compatibility report

- -

Given the very large user base of SLF4J, we take backward - compatibility very seriously. As such, changes that may cause - incompatibility problems are listed in this page. Moreover, since - slf4j-api.jar is the main entry point into SLF4J, that is the module - that will be covered in most detail. -

- -

The list is computed using clirr. If you have reasons - to suspect incompatible changes not mentioned here, please kindly - contact the slf4j developers list.

- - - -

Version 1.5.1 compared to 1.5.0

- - -

slf4j-api module, list of breaking changes:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SeverityDescriptionClassMethod / Field
ErrorMethod 'getCopyOfContextMap()' has been added to an - interface - org.slf4j.spi.MDCAdapterpublic java.util.Map getCopyOfContextMap()
ErrorMethod 'setContextMap(Map)' has been added to an - interface - org.slf4j.spi.MDCAdapterpublic void setContextMap(java.util.Map)
ErrorMethod 'getDetachedMarker(String)' has been added to an - interface - org.slf4j.IMarkerFactorypublic org.slf4j.Marker getDetachedMarker(java.lang.String)
InfoMethod 'equals(Object)' has been added to an - interface - org.slf4j.Markerpublic boolean equals(java.lang.Object)
infoMethod 'hashCode()' has been added to an - interface - org.slf4j.Markerpublic int hashCode()
- -

The addition of the getCopyOfContextMap() method in - the MDCAdapter class should only impact users who have - their own implementation of the said interface. Except for bindings - that ship with SLF4J and for logback-classic, which will be - naturally upgraded, there are no known other implementations of - MDCAdapter. In a rare but still possible scenario, if - the user mixes different versions for slf4j-api.jar, say version - 1.5.1. and an SLF4J binding, say slf4j-log4j12.jar version 1.5.0, - then a java.lang.AbstractMethodError will be thrown, - but only if the client code calls the newly added method. In short, although generally speaking the - addition of a method to an interface is a breaking change, we are - confident that no users will be impacted in this particular - case. -

- -

Similar reasoning applies to the setContextMap(Map) - method.

- -

The addition of getDetachedMarker(String) method in - the org.slf4j.IMarkerFactory should not impact users as - the only (known) implementation of this interface ships with SLF4J - itself. -

- -

The equals() and hashCode() methods - were added to the org.slf4j.Marker interface for - documentation purposes. Given that all objects implicitly implement - these methods, their addition should theoretically not break - existing code.

- - -

Other modules

- -

No breaking changes to report.

- - - -

Version 1.5.0 compared to - 1.4.3

- -

No breaking changes to report.

- - -

Version 1.4.3 compared to - 1.4.2

-

No breaking changes to report.

- - -

Version 1.4.2 compared to 1.4.1

-

No breaking changes to report.

- - -

Version 1.4.1 compared to - 1.4.0

-

No breaking changes to report.

- -
\ No newline at end of file diff --git a/trunk/slf4j-site/src/site/pages/css/site.css b/trunk/slf4j-site/src/site/pages/css/site.css deleted file mode 100644 index 3e9640f07..000000000 --- a/trunk/slf4j-site/src/site/pages/css/site.css +++ /dev/null @@ -1,280 +0,0 @@ -html { - padding:0px; - margin:0px; -} - -body { - background-color: #fff; - font-family: Verdana, Arial, SunSans-Regular, Sans-Serif; - color: #000; - padding:0px; - margin:0px; - font-size: small; -} - -p, h2, pre { - margin: 0px; - padding-top: 5px; - padding-bottom: 5px; - /*padding-left: 1ex;*/ - /*padding: 5px 20px 5px 20px; */ -} - -p.rm { - padding-top: 0px; - padding-bottom: 0px; -} - -a { - color: #0000CC; - /*font-size: smaller;*/ - background-color:transparent; - text-decoration: none; -} - -#content a:hover { - text-decoration: underline; -} - -.source { - border-top: 1px solid #DDDDDD; - border-bottom: 1px solid #DDDDDD; - background:#eee; - font-family: Courier, "MS Courier New", Prestige, Everson Monocourrier, monospace; - padding-bottom: 0.5ex; - padding-top: 0.5ex; - padding-left: 1ex; - white-space: pre; -} - -pre { - background-color:transparent; - font-family: Courier, Monaco, Monospace; -} - -.alignright { - margin-top: 0; - text-align: right; - font-size: 10px; -} - -h1, h2, h3, h4 { - color: #333; -} - -h2 { - padding-top:10px; - background-color: transparent; - font-weight: 900; - font-size: x-large; -} - -h3 { - padding-top:10px; - background-color: transparent; - font-weight: normal; - font-size: large; -} - -h4 { - padding-top:5px; - background-color: transparent; - font-weight: large; - font-size: normal; -} - -.footer { - text-align: right; - color: #564b47; - background-color: #fff; - padding:0px; - border-top: 1px solid #CCCCCC; - margin-top: 3ex; - font-size: smaller; -} - - -strong { - /*font-size: 13px;*/ - font-weight: bold; -} - -/* positioning-layers static and absolute */ - -#breadcrumbs { - padding: 3px 10px 3px 10px; - margin: 0px 4px 0px 4px; - font-size: small; - border: 1px solid #CCCCCC; - /*border-bottom: 1px solid #aaa; - /* background-color: #ccc; lime; - border-color: #663300;*/ - background-color: #ffd0a0; - /*max-width: 77em;*/ -} - -#left { - position: absolute; - left: 0px; - width: 15em; - color: #564b47; - margin: 4px 0px 0px 4px; - padding: 0px; - /* background-color: #ffffff; */ - border: 1px solid #cccccc; - /* background-color: #ffcc99; */ - background-color: #ffffff; - font-size: 80%; -} - -#left a, #right a { - display: block; - width: 95.5%; - margin: 0px; - padding: 2px; - border: solid 1px #FFFFFF; - color: #0000CC; - text-decoration: none; -} - -p.menu_header { - margin: 0px; - padding: 2px; - font-weight: normal; - background-color: #ffd0a0; - border-top: solid 1px #CCCCCC; - border-bottom: solid 1px #CCCCCC; -} - -#left a:hover, #right a:hover { - border: solid 1px #FFFFFF; - background-color: #3333CC; - color: #ffffff; -} - -#content { - margin: 0px 17em 0px 17em; - padding: 0px; - background-color: #ffffff; -} - -#right { - position: absolute; - right: 0px; - width: 14em; - color: #564b47; - margin: 4px 4px 0px 0px; - padding: 0px; - background-color: #ffffff; - border: 1px solid #cccccc; - font-size: 80%; -} - -#left img { - display: block; - margin: 20px 0 20px 17px; - border: none; - width: 90px; - height: 30px; -} - -#content img { - border:none; - margin-left: auto; - margin-right: auto; - display: block; -} - -table.bodyTable { - padding: 0px; - width: 100%; - margin-left: -2px; - margin-right: -2px; -} - -table.bodyTable th { - color: white; - background-color: #bbb; - font-weight: bold; -} - - -table.bodyTable tr.a { - background-color: #ddd; -} - -table.bodyTable tr.b { - background-color: #eee; -} - -.author { - text-align: left; - font-weight: bold; -} - -.definition { - padding-left: 5px; - padding-right: 5px; - margin: 5px 50px 5px 50px; - text-align: justify; - background-color: #E6E64C; -} - -.deftitle { - font-weight: bold; -} - -.big { - font-size: 130%; -} - -.green { - color: green; -} -.blue { - color: blue; -} - -.redBold { - color: red; - font-weight: bold; -} -.greenBold { - color: green; - font-weight: bold; -} - -code { - font-family: Courier, monospace; -} - - -.option { - border: 1px solid black; - font-family: Arial, sans-serif; -} - -.highlight { - width: 300px; - float: right; - display: inline; - font-weight: bolder; - border:1px solid #000; - background:#FFCC99; - padding-top: 0px; - padding-left: 1ex; - padding-right: 1ex; - margin-left: 3em; - margin-right: 3em; -} - -table.bodyTable tr.a { - background-color: #ddd; -} - -table.bodyTable tr.b { - background-color: #eee; -} -table.bodyTable tr.alt { - background-color: #eee; -} \ No newline at end of file diff --git a/trunk/slf4j-site/src/site/pages/docs.html b/trunk/slf4j-site/src/site/pages/docs.html deleted file mode 100644 index 4328050a9..000000000 --- a/trunk/slf4j-site/src/site/pages/docs.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - -SLF4J Documentation - - - - - - -
- -
- -
- -

Documentation

- -

Given the small size of SLF4J, its documentation is not very - lengthy.

- - - -

Articles

- - - - - - -
- - diff --git a/trunk/slf4j-site/src/site/pages/download.html b/trunk/slf4j-site/src/site/pages/download.html deleted file mode 100644 index a0d0b2c22..000000000 --- a/trunk/slf4j-site/src/site/pages/download.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - -SLF4J Binary files - - - - - - -
- -
- -
- - - -

Latest official SLF4J version

- -

Download version ${project.version} including full source code, - class files and documentation in ZIP or TAR.GZ format:

- - - - -

Previous versions

- -

Previous versions of SLF4J can be downloaded from the main repository. -

- - - -
- - diff --git a/trunk/slf4j-site/src/site/pages/faq.html b/trunk/slf4j-site/src/site/pages/faq.html deleted file mode 100644 index 3455cbf52..000000000 --- a/trunk/slf4j-site/src/site/pages/faq.html +++ /dev/null @@ -1,1140 +0,0 @@ - - - - -SLF4J FAQ - - - - - - -
- -
- -
- -
- -

Frequently Asked Questions about SLF4J

- -

Generalities

- -
    -
  1. What is SLF4J?
  2. - -
  3. When should SLF4J be used?
  4. - -
  5. Is SLF4J yet another loggingfacade?
  6. - -
  7. - If SLF4J fixes JCL, then why - wasn't the fix made in JCL instead of creating a new project? - -
  8. - -
  9. - When using SLF4J, do I have to - recompile my application to switch to a different logging - system? - -
  10. - -
  11. What are SLF4J's requirements?
  12. - - -
  13. - Why is SLF4J licensed under X11 type - license instead of the Apache Software License? - -
  14. - -
  15. - Where can I get a particular - SLF4J binding? - -
  16. - -
  17. - Should my library attempt to - configure logging? - -
  18. - -
  19. - What about Maven 2 transitive - dependencies? - -
  20. -
- - - About the SLF4J API - -
    - -
  1. - Why don't the printing methods - in the Logger interface accept message of type Object, but only - messages of type String? - -
  2. - -
  3. - - Can I log an exception without an accompanying message? - -
  4. - - -
  5. - What is the fastest way of - (not) logging? - -
  6. - -
  7. - How can I log the string contents - of a single (possibly complex) object? - -
  8. - - -
  9. Why doesn't the - org.slf4j.Logger interface have methods for the - FATAL level?
  10. - -
  11. Why was the TRACE level introduced only in - SLF4J version 1.4.0?
  12. - -
  13. Does the SLF4J logging API support I18N - (internationalization)?
  14. - - -
- - - - Implementing the SLF4J API - -
    - -
  1. How do I make my logging - framework SLF4J compatible?
  2. - -
  3. How can my logging system add - support for the Marker interface?
  4. - -
- - - General questions about logging - - -
    - -
  1. Should Logger members of a class - be declared as static?
  2. - - -
  3. Is there a recommended idiom - for declaring a loggers in a class?
  4. - -
- -
- - -
- -

Generalities

- -
-
What is SLF4J?
-
-

SLF4J is a simple facade for logging systems allowing the - end-user to plug-in the desired logging system at deployment - time. -

- -
-
- -
When should SLF4J be used? -
- -
-

In short, libraries and other embedded components should - consider SLF4J for their logging needs because libraries - cannot afford to impose their choice of logging system on the - end-user. On the other hand, it does not necessarily make - sense for stand-alone applications to use SLF4J. Stand-alone - applications can invoke the logging system of their choice - directly. -

- -

SLF4J is only a facade, meaning that it does not provide a - complete logging solution. Operations such as configuring - appenders or setting logging levels cannot be performed with - SLF4J. Thus, at some point in time, any non-trivial - application will need to directly invoke the underlying - logging system. In other words, complete independence from the - API underlying logging system is not possible for a - stand-alone application. Nevertheless, SLF4J reduces the - impact of this dependence to near-painless levels. -

- -

Suppose that your CRM application uses log4j for its - logging. However, one of your important clients request that - logging be performed through JDK 1.4 logging. If your - application is riddled with thousands of direct log4j calls, - migration to JDK 1.4 would be a long and error-prone - process. Had you been invoking SLF4J API instead of log4j, the - migration could be completed in a matter of minutes instead of - hours. -

- -

SLF4J lets component developers to defer the choice of the - logging system to the end-user but eventually a choice needs - to be made. -

- -
- -
- -
- - Is SLF4J yet another logging facade? -
- -
-

SLF4J is conceptually similar to JCL. As such, it can be - thought of as yet another logging facade. However, SLF4J is - orders of magnitude simpler in design and arguably more - robust. -

- -
- -
-
- - If SLF4J fixes JCL, then why wasn't the fix made in JCL - instead of creating a new project? - -
- -
-

This is a very good question. First, SLF4J static binding - approach is very simple, perhaps even laughably so. It was - not easy to convince developers of the validity of the - approach. It is only after SLF4J was released and started to - become accepted did the approach gain respectability in the - relevant community. -

- -

Second, SLF4J offers two enhancements which developers - currently tend to underestimate. Parameterized log messages - solve an important problem associated with logging performance - in a pragmatic way. Marker objects, which are supported by the - org.slf4j.Logger interface, pave the way for - adoption of advanced logging systems and still leave the door - open to switching back to more traditional logging systems if - need be. -

- -
-
- -
- When - using SLF4J, do I have to recompile my application to switch - to a different logging system? -
- -
-

No, you do not need to recompile your application. You can - switch to a different logging system by removing the previous - SLF4J binding and replacing it with the binding of your choice. -

- -

For example, if you were using the NOP implementation and - would like to switch to log4j version 1.2, simply replace - slf4j-nop.jar with slf4j-log4j12.jar on - your class path but do not forget to add log4j-1.2.x.jar as - well. Want to switch to JDK 1.4 logging? Just replace - slf4j-log4j12.jar with slf4j-jdk14.jar. -

- -
-
-
- What are SLF4J's - requirements? -
- -
- -

In principle, SLF4J requires JDK 1.3 or above, in - particular slf4j-api is compatible with JDK 1.3. However, - the underlying logging system might have a higher - requirement. For instance, the slf4j-jdk14 binding - requires JDK 1.4. Logback requires JDK 1.5. -

- -

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BindingRequirements
slf4j-nopJDK 1.3
slf4j-simpleJDK 1.3
slf4j-log4j12JDK 1.3, plus any other library - dependencies required by the log4j appenders in use
slf4j-jdk14JDK 1.4 or above
logback-classicJDK 1.5 or above, plus any other library dependencies - required by the logback appenders in use
- -
-
- -
- - Why is SLF4J licensed under X11 type license instead of the - Apache Software License? - -
- -
-

SLF4J is licensed under a permissive X11 type license - instead of the ASL or the LGPL - because the X11 license is deemed by both the Apache Software - Foundation as well as the Free Software Foundation as - compatible with their respective licenses. -

- -
-
-
- - Where can I get a particular SLF4J binding? - -
- -
- -

SLF4J bindings for SimpleLogger, - NOPLogger, Log4jLoggerAdapter - and JDK14LoggerAdapter - are contained within the files slf4j-nop.jar, - slf4j-simple.jar, slf4j-log4j12.jar, and - slf4j-jdk14.jar. These files ship with the official SLF4J distribution. Please - note that all bindings depend on slf4j-api.jar. -

- -

The binding for logback-classic ships with the logback - distribution. However, as with all other bindings, the - logback-classic binding requires slf4j-api.jar. -

- -
-
- -
- Should my library attempt to configure logging? -
- -
-

Embedded components such as libraries do not need and - should not configure the underlying logging system. They - invoke SLF4J to log but should let the end-user configure the - logging environment. When embedded components try to configure - logging on their own, they often override the end-user's - wishes. At the end of the day, it is the end-user who has to - read the logs and process them. She should be the person to - decide how she wants her logging configured. -

- -
-
- -
What about Maven2 - transitive dependencies? -
- -
-

As an author of a library built with Maven2, you might - want to test your application using a binding, say - slf4j-log4j12 or logback-classic, without forcing log4j or - logback-classic as a dependency upon your users. As of SLF4J - version 1.3, this quite easy to accomplish. But first, since - your library's code depends on the SLF4J API you will need to - declare slf4j-api as a compile-time (default scope) - dependency. -

-

 

-

<dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${project.version}</version> -</dependency>

- -

 

- -

Limiting the transitivity of the SLF4J binding used in your - tests can be accomplished by declaring the scope of the - SLF4J-binding dependency as "test". Here is an example:

- -

 

- -

<dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>${project.version}</version> - <scope>test</scope> -</dependency>

- -

Thus, as far as your users are concerned you are exporting - slf4j-api as a transitive dependency of your library, but not - any SLF4J-binding or an underlying logging system. -

- -
- -
-
- -
- - -

About the SLF4J API

- -
- -
Why - don't the printing methods in the Logger interface accept - message of type Object, but only messages of type String? -
- -
- -

In SLF4J 1.0beta4, the printing methods such as debug(), - info(), warn(), error() in the Logger interface were - modified so as to accept only messages of type String - instead of Object. -

- -

Thus, the set of printing methods for the DEBUG level - became:

- -

debug(String msg); -debug(String format, Object arg); -debug(String format, Object arg1, Object arg2); -debug(String msg, Throwable t);

- -

Previously, the first argument in the above methods was of - type Object.

- -

This change enforces the notion that logging systems are - about decorating and handling messages of type String, and not - any arbitrary type (Object). -

- -

Just as importantly, the new set of method signatures offer - a clearer differentiation between the overladed methods - whereas previously the choice of the invoked method due to - Java overloding rules were not always easy to follow.

- -

It was also easy to make mistakes. For example, previously - it was legal to write:

- -

logger.debug(new Exception("some error"));

- -

Unfortunately, the above call did not print the stack trace - of the exception. Thus, a potentially crucial piece of - information could be lost. When the first parameter is - restricted to be of type String, then only the method -

- -

debug(String msg, Throwable t)

- -

can be used to log exceptions. Note that this method - ensures that every logged exception is accompanied with a - descriptive message.

- -
-
- -
- - - Can I log an exception without an accompanying message? - -
-
-

In short, no.

- -

If e is an Exception, and you - would like to log an exception at the ERROR level, you must - add an accompanying message. For example,

- -

logger.error("some accompanying message", e);

- -

You might correctly observe that not all exceptions have a - meaningful message to accompany them. Moreover, a good - exception should already contain a self explanatory - description. The accompanying message may therefore be - considered redundant. -

- - -

While these are valid arguments, there are three opposing - arguments also worth considering. First, on many, albeit not - all occasions, the accompanying message can convey useful - information nicely complementing the description contained - in the exception. Frequently, at the point where the - exception is logged, the developer has access to more - contextual information than at the point where the exception - is thrown. Second, it is not difficult to imagine more or - less generic messages, e.g. "Exception caught", "Exception - follows", that can be used as the first argument for - error(String msg, Throwable t) invocations. - Third, most log output formats display the message on a - line, followed by the exception on a separate line. Thus, - the message line would look inconsistent without a message. -

- -

In short, if the user were allowed to log an exception - without an accompanying message, it would be the job of the - logging system to invent a message. This is actually what - the throwing(String - sourceClass, String sourceMethod, Throwable thrown) - method in java.util.logging package does. (It decides on its - own that accompanying message is the string "THROW".) -

- -

It may initially appear strange to require an accompanying - message to log an exception. Nevertheless, this is common - practice in all log4j derived systems such as - java.util.logging, logkit, etc. and of course log4j itself. It - seems that the current consensus considers requiring an - accompanying message as a good a thing (TM). -

- -
-
- - - -
- What is the fastest way of (not) logging?
- -

SLF4J supports an advanced feature called parameterized - logging which can significantly boost logging performance for - disabled logging statement.

- -

For some Logger logger, writing,

-

logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));

- -

incurs the cost of constructing the message parameter, that - is converting both integer i and - entry[i] to a String, and concatenating - intermediate strings. This, regardless of whether the message - will be logged or not. -

- -

One possible way to avoid the cost of parameter - construction is by surrounding the log statement with a - test. Here is an example.

- -

if(logger.isDebugEnabled()) { - logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i])); -}

- - -

This way you will not incur the cost of parameter - construction if debugging is disabled for - logger. On the other hand, if the logger is - enabled for the DEBUG level, you will incur the cost of - evaluating whether the logger is enabled or not, twice: once in - debugEnabled and once in debug. This - is an insignificant overhead because evaluating a logger takes - less than 1% of the time it takes to actually log a statement. -

- -

Better alternative based on parameterized - messages

- -

There exists a very convenient alternative based on message - formats. Assuming entry is an object, you can write: -

- - -

Object entry = new SomeObject(); -logger.debug("The entry is {}.", entry);

- -

After evaluting whether to log or not, and only if the - decision is affirmative, will the logger implementation format - the message and replace the '{}' pair with the string value of - entry. In other words, this form does not incur - the cost of parameter construction in case the log statement is - disabled. -

- - -

The following two lines will yield the exact same - output. However, the second form will outperform the first - form by a factor of at least 30, in case of a - disabled logging statement. -

- -

logger.debug("The new entry is "+entry+"."); -logger.debug("The new entry is {}.", entry);

- - -

A two argument variant is also availalble. For example, you - can write:

- - -

logger.debug("The new entry is {}. It replaces {}.", entry, oldEntry);

- -

-

If three or more arguments need to be passed, you can make - use of the Object[] variant. For example, you can - write:

- -

-

logger.debug("Value {} was inserted between {} and {}.", - new Object[] {newVal, below, above});

- -

-

SLF4J uses its own message formatting implementation which - differs from that of the Java platform. This is justified by - the fact that SLF4J's implementation performs several orders - of magnitude faster but at the cost of being non-standard and - less flexible. -

- -

-

- -
- -
- - -
How can - I log the string contents of a single (possibly complex) - object? - -
- -
-

In relatively rare cases where the message to be logged - is the string form of an object, then the parameterized - printing method of the appropriate level can be - used. Assuming complexObject is an object of - certain complexity, for a log statement of level DEBUG, you - can write: -

- -

logger.debug("{}", complexObject);

- - -

The logging system will invoke - complexObject.toString() method only after it - has ascertained that the log statement was - enabled. Otherwise, the cost of - complexObject.toString() conversion will be - advantageously avoided. -

- -
- -
- - - - -
Why doesn't the - org.slf4j.Logger interface have methods for the - FATAL level? - -
- -
- -

From the stand point of a logging system, the distinction - between a fatal error and an error is usually not very - useful. Most programmers exit the application when a fatal - error is encountered. However, a logging library cannot (and - should not) decide on its own to terminate an - application. The initiative to exit the application must be - left to the developer. -

- - -

Thus, the most the FATAL level can do is to - highlight a given error as the cause for - application to crash. However, errors are by definition - exceptional events that merit attention. If a given - situation causes errors to be logged, the causes should be - attended to as soon as possible. However, if the "error" is - actually a normal situation which cannot be prevented but - merits being aware of, then it should be marked as WARN, not - ERROR. -

- -

Assuming the ERROR level designates exceptional situations - meriting close attention, we are inclined to believe that the - FATAL level is superfluous. -

- - -
-
- -
- Why was the TRACE level introduced only in - SLF4J version 1.4.0? - -
- -
- -

The addition of the TRACE level has been frequently and - hotly debated request. By studying various projects, we - observed that the TRACE level was used to disable logging - output from certain classes without needing to - configure logging for those classes. Indeed, the TRACE level - is by default disabled in log4j and logback as well most other - logging systems. The same result can be achieved by adding the - appropriate directives in configuration files. -

- -

Thus, in many of cases the TRACE level carried the same - semantic meaning as DEBUG. In such cases, the TRACE level - merely saves a few configuration directives. In other, more - interesting occasions, where TRACE carries a different meaning - than DEBUG, Marker - objects can be put to use to convey the desired - meaning. However, if you can't be bothered with markers and - wish to use a logging level lower than DEBUG, the TRACE level - can get the job done. -

- -

Note that while the cost of evaluating a disabled log - request is in the order of a few nanoseconds, the - use of the TRACE level (or any other level for that matter) is - discouraged in tight loops where the log request might be - evaluated millions of times. If the log request is enabled, - then it will overwhelm the target destination with massive - output. If the request is disabled, it will waste resources. -

- -

In short, although we still discourage the use of the TRACE - level because alternatives exist or because in many cases log - requests of level TRACE are wasteful, given that people kept - asking for it, we decided to bow to popular demand. -

-
- -
- -
- Does the SLF4J logging API support - I18N (internationalization)? - -
- -
-

No. SLF4J does not offer any particular support for - I18N. However, nothing prevents you from implementing i18n - support around the SLF4J API.

- -

As suggested by Sebastien Davids in bug report - 50, a possible pattern might be:

- -

-class MyClass { - - ResourceBundle bundle = ResourceBundle.getBundle("my.package.messages"); - Logger logger = LoggerFactory.getLogger(MyClass.class); - - void method() { - if (logger.isWarnEnabled()) { - MessageFormat format = new MessageFormat(bundle.getString("my_message_key")); - logger.warn(format.format(new Object[] { new Date(), 1 })); - } - } -}

- -

Where my_message_key is defined as

-

my_message_key=my text to be i18n {1,date,short} {0,number,00}

- - - - -
- -
-
- - -
- -

Implementing the SLF4J API

- -
-
How do - I make my logging framework SLF4J compatible? - -
- - -
- -

Adding supporting for the SLF4J is suprisingly - easy. Essentialy, you coping an existing binding and tailoring - it a little (as explained below) does the trick. -

- -

Assuming your logging system has notion of a - logger, called say MyLogger, you need to provide - an adapter for MyLogger to - org.slf4j.Logger interface. Refer to slf4j-jcl, - slf4j-jdk14, and slf4j-log4j12 modules for examples of - adapters. -

- -

Once you have written an appropriate adapter, say - MyLoggerAdapter, you need to provide a factory - class implementing the org.slf4j.ILoggerFactory - interface. This factory should return instances - MyLoggerAdapter. Let MyLoggerFactory - be the name of your factory class. -

- -

Once you have the adapter, namely - MyLoggerAdapter, and a factory, namely - MyLoggerFactory, the last remaining step is to - modify the StaticLoggerBinder class so that it - reurns an new instance of MyLoggerFactory. You - will also need to modify the - loggerFactoryClassStr variable. -

- -

For Marker or MDC support, you could use the one of the - existing NOP implementations. -

- -

In summary, to create an SLF4J binding for your logging - system, follow these steps:

- -
    -
  1. start with a copy of an existing module,
  2. -
  3. create an adapter between your logging system and - org.slf4j.Logger interface -
  4. -
  5. create a factory for the adapter created in the previous step,
  6. -
  7. >modify StaticLoggerBinder class to use the - factory you created in the previous step
  8. -
- -
-
-
How - can my logging system add support for the Marker - interface? - -
-
- -

Markers consitute a revolutionary concept which is - supported by logback but not other existing logging - systems. Consequently, SLF4J confromant logging systems are - allowed to ignore marker data passed by the user. -

- -

However, even though marker data may be ignored, the user - must still be allowed to specify marker data. Otherwise, users - would not be able to switch between logging systems that - support markers and those that do not. In order to provide - minimal support for markers, SLF4J conformant systems need to - to include certain Marker related classes, namely, - org.slf4j.Marker, - org.slf4j.IMarkerFactory, - org.slf4j.MarkerFactory, - org.slf4j.impl.BasicMarker, - org.slf4j.impl.BasicMarkerFactory, - org.slf4j.impl.MarkerIgnoringBase, - org.slf4j.impl.StaticMarkerBinder and - org.slf4j.spi.MarkerFactoryBinder. Al of these - classes are availalbe in the SLF4J subversion repository. -

- -

The MarkerIgnoringBase class can serve as a - base for adapters or native implementations of logging systems - lacking marker support. In MarkerIgnoringBase, - methods taking marker data simply invoke the corresponding - method without the Marker argument, discarding any Marker data - passed as argument. Your SLF4J adapters can extend - MarkerIgnoringBase to quickly implement the - methods in org.slf4j.Logger which take a - Marker as the first argument. -

- -
-
-
-
- -
-

General questions about logging

- - -
-
Should Logger - members of a class be declared as static? -
-
- -

We used to recommend that loggers members be - declared as instance variables instead of static. After further - analysis, we no longer recommend one approach over the - other. -

- -

Here is a summary of the pros and cons of each approach. -

- - - - - - - - - - - - - - - - - - - - - - - -
Advantages for declaring loggers as staticDisadvantages for declaring loggers as static
-
    -
  1. common and well-established idiom
  2. -
  3. less CPU overhead: loggers are retreived and - assigned only once, at hosting class - initialisation
  4. -
  5. less memory overhead: logger declaration will - consume one reference per class
  6. -
  7. serialization of the hosting class does not require - any special action -
  8. -
-
-
    -
  1. For libraries shared between applications, not - possible to take advantage of repository selectors. It - should be noteed that if the SLF4J binding and the - underlying API ships with each application (not shared - between applications), then each application will still - have its own logging environment. -
  2. -
  3. not IOC-friendly
  4. -
-
Advantages for declaring loggers as instance variablesDisadvantages for declaring loggers as - instance variables
-
    -
  1. Possible to take advantage of repository selectors - even for libraries shared between applications. However, - repository selectors only work if the underlying logging - sytem is logback-classic. Repository selectors do not - work for the SLF4J+log4j combination. -
  2. -
  3. IOC-friendly
  4. -
-
-
    -
  1. Less common idiom than declaring loggers as static - variables
  2. - -
  3. higher CPU overhead: loggers are retreived and - assigned for each instance of the hosting class
  4. - -
  5. higher memory overhead: logger declaration will - consume one reference per instance of the hosting class
  6. - -
  7. if the hosting class is serialized, then the logger - declaration has to be marked as transient -
  8. - -
-
- -

Explanation

- -

Static logger members cost a single variable reference for - all instances of the class whereas an instance logger member - will cost a variable reference for every instance of the - class. For simple classes instantiated thousands of times - there might be a noticeable difference. -

- -

However, more recent logging systems, e.g log4j or logback, - support a distinct logger context for each application running - in the application server. Thus, even if a single copy of - log4j.jar or logback-classic.jar is deployed - in the server, the logging system will be able to differentiate - between applications and offer a distinct logging environment - for each application. -

- -

More specifically, each time a logger is retrieved by - invoking LoggerFactory.getLogger() method, the - underlying logging system will return an instance appropriate - for the current application. Please note that within the - same application retrieving a logger by a given name - will always return the same logger. For a given name, a - different logger will be returned only for different - applications. -

- -

If the logger is static, then it will only be retrieved once - when the hosting class is loaded into memory. If the hosting - class is used in only in one application, there is not much to - be concerned about. However, if the hosting class is shared - between several applications, then all instances of the shared - class will log into the context of the application which - happened to fist load the shared class into memory - hardly the - behavior expected by the user. -

- -

Unfortunately, for non-native implementations of the SLF4J - API, namely with slf4j-log4j12, log4j's repository selector will - not be able to do its job properly because slf4j-log4j12, a - non-native SLF4J binding, will store logger instances in a map, - short-circuiting context-dependent logger retrieval. For native - SLF4J implementations, such as logback-classic, repository - selectors will work as expected. -

- -

The Apache Commons wiki contains an informative - article covering the same question.

- -

Logger serialization

- -

Contrary to static variables, instance variables are - serialized by default. However, the org.sfl4j.Logger interface - is not serializable nor are the logger classes in underlying - logging systems such as java.util.logging, log4j or - logback-classic. -

- - -

Summary

- -

In summary, declaring logger members as static variables, - requires less work, less CPU and memory overhead and causes no - problems with serialization. On the other hand, declaring logger - members as instance variables, requires more work, more CPU and - memory overhead and is likely to cause problems with - serialization. However, instance variables make it possible to - create a distinct logger environment for each application, even - for loggers declared in shared libraries. Perhaps more important - than previously mentioned considerations, instance variables are - IOC-friendly whereas static variables are not. -

- -

-

-http://wiki.apache.org/jakarta-commons/Logging/StaticLog -
-
- -
-
Is there a recommended idiom for - declaring a logger in a class? -
- -
-

The following is the recommended logger declaration - idiom. It assumes that your logger is a static variable of the - class.

- -

package some.package; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MyClass { - final static Logger logger = LoggerFactory.getLogger(MyClass.class); - ... etc -}

- -

Unfortunately, give that the name of the hosting class is - part of the logger declarion, the above logger declaration - idom is not is not resitant to cut-and-pasting - between classes. -

-
-
- - - - - - - - -
-
- - diff --git a/trunk/slf4j-site/src/site/pages/inde_base.html b/trunk/slf4j-site/src/site/pages/inde_base.html deleted file mode 100644 index 83bbef9fb..000000000 --- a/trunk/slf4j-site/src/site/pages/inde_base.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -SLF4J - - - - - - -
- -
- -
- - - - - -
- - diff --git a/trunk/slf4j-site/src/site/pages/index.html b/trunk/slf4j-site/src/site/pages/index.html deleted file mode 100644 index 7a0cde459..000000000 --- a/trunk/slf4j-site/src/site/pages/index.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - -SLF4J - - - - - - -
- -
- -
- - -

Simple Logging Facade for Java (SLF4J)

- -

The Simple Logging Facade for Java or (SLF4J) is intended to - serve as a simple facade for various logging APIs allowing to the - end-user to plug in the desired implementation at - deployment time. SLF4J also allows for a gradual migration path away from - Jakarta Commons Logging (JCL). -

- -

SLF4J API offers an advanced abstraction of various logging - systems, including JDK 1.4 logging, log4j and logback. Features - include parameterized - logging and MDC support. -

- -

Logging systems can either choose to implement the the SLF4J - interfaces directly, e.g. logback or SimpleLogger. Alternatively, - it is possible (and rather easy) to write SLF4J adapters for a given - API implementation, e.g. Log4jLoggerAdapter - or JDK14LoggerAdapter.. -

- -

Simplicity

- -

The SLF4J interfaces and their various adapters are simple and - straightforward. Most developers familiar with the Java language - should be able to read and fully understand the code in less than - one hour. -

- -

SLF4J does not rely on any special class loader machinery. In - fact, the binding between SLF4J and a given logging API - implementation is performed statically at compile time of - each binding. Each binding is hardwired to use one and only one - specific logging API implementation. Each binding corresponds to one - jar file. In your code, in addition to slf4j-api.jar, you - simply drop the binding of your choice, that is a jar file, onto the - appropriate class path location. As a consequence of this simple - approach, SLF4J suffers from none of the class loader problems or - memory leaks observed with Jakarta Commons Logging (JCL). -

- -

We hope that simplicity of the SLF4J interfaces and the deployment - model will make it easy for developers of other logging APIs to - conform to the SLF4J model. -

- -

Projects depending on SLF4J

- -

Here is a non-exhaustive list of projects currently depending on - SLF4J, in alphabetical order: -

- - - - - - - - - - - - -
- - - - - - - - -
- - -
- - diff --git a/trunk/slf4j-site/src/site/pages/license.html b/trunk/slf4j-site/src/site/pages/license.html deleted file mode 100644 index 8d30c10e3..000000000 --- a/trunk/slf4j-site/src/site/pages/license.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - -SLF4J License - - - - - - -
- -
- -
- - -

SLF4J License

- -

SLF4J source code and binaries are distributed under the - following license. -

- -
- Copyright (c) 2004-2007 QOS.ch - All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -
- -

These terms are identical to those of the MIT License, - also called the X License or the X11 License, which is a simple, - permissive non-copyleft free software license. It is deemed - compatible with virtually all types of licenses, commercial or - otherwise. In particular, the Free Software Foundation has declared - it compatible with - GNU GPL. It is also known to be approved by the Apache Software - Foundation as compatible with Apache Software License. -

- - - -
- - diff --git a/trunk/slf4j-site/src/site/pages/log4j-over-slf4j.html b/trunk/slf4j-site/src/site/pages/log4j-over-slf4j.html deleted file mode 100644 index bdab179ab..000000000 --- a/trunk/slf4j-site/src/site/pages/log4j-over-slf4j.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - -Log4j Bridge - - - - - - - - -
- -
- -
- -

Log4j over SLF4J

- -

Recent versions of SLF4J ship with a module called - log4j-over-slf4j. It allows log4j users to migrate - existing applications to SLF4J without changing a single line - of code but simply by replacing the log4j.jar file - with log4j-over-slf4j.jar, as described below. -

- -

How does it work?

- -

The log4j-over-slf4j module contains replacements of most - widely used log4j classes, namely - org.apache.log4j.Category, - org.apache.log4j.Logger, - org.apache.log4j.Priority, - org.apache.log4j.Level, - org.apache.log4j.MDC, and - org.apache.log4j.BasicConfigurator. These replacement - classes redirect all work to their corresponding SLF4J classes. -

- -

To use log4j-over-slf4j in your own application, the first step - is to locate and then to replace log4j.jar with - log4j-over-slf4j.jar. Note that you still need an SLF4J - binding and its dependencies for log4j-over-slf4j to work - properly. -

- -

- In most situtations, replacing a jar file is all it takes in - order to migrate from log4j to SLF4J. -

- -

Note that as a result of this migration, log4j configuration - files will no longer be picked up. If you need to migrate your - log4j.properties file to logback, the log4j translator - might be of help. For configuring logback, please refer to its manual. -

- -

We are happy to report that several applications are - successfully using log4j-over-slf4j in production. -

- - -

When does it not work?

- -

The log4j-over-slf4j module will not work when the - application calls log4j components that are not present in the - bridge. For example, direct references to log4j appenders, - filters or PropertyConfigurator are not supported by - log4j-over-slf4j. While the number of cases where - log4j-over-slf4j is insufficient is not completely negligible, in - the vast majority of cases where log4j is configured through a - configuration file, be it log4j.properties or - log4j.xml, log4j-over-slf4j is enough in order to migrate - your application to SLF4J. -

- -

What about the overhead?

- -

There overhead of using log4j-over-slf4j instead of log4j - directly is relatively small. Given that log4j-over-slf4j - immediately delegates all work to SLF4J, the CPU overhead should - be negligible, in the order of a few nanoseconds. There - is a memory overhead corresponding to an entry in a hashmap per - logger, which should be usually acceptable even for very large - applications consisting of several thousand loggers. Moreover, if - you choose logback as your underlying logging system, and given - that logback is both much faster and more memory-efficient than - log4j, the gains made by using logback should compensate for the - overhead of using log4j-over-slf4j instead of log4j directly. -

- - - -
- - diff --git a/trunk/slf4j-site/src/site/pages/mailing-lists.html b/trunk/slf4j-site/src/site/pages/mailing-lists.html deleted file mode 100644 index f9cec96c9..000000000 --- a/trunk/slf4j-site/src/site/pages/mailing-lists.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - -SLF4J - - - - - - -
- -
- -
- -

SLF4J Mailing Lists

- -

A mailing list is an electronic discussion forum that anyone can - subscribe to. When someone sends an email message to the mailing - list, a copy of that message is broadcast to everyone who is - subscribed to that mailing list. Mailing lists provide a simple and - effective communication mechanism. With potentially thousands of - subscribers, there is a common set of etiquette guidelines that you - should observe. Please keep on reading. -

- -

Respect the mailing list type

- -

The "User" lists where you can send questions and comments about - configuration, setup, usage and other "user" types of questions. - The "Developer" lists where you can send questions and comments - about the actual software source code and general "development" - types of questions. -

- -

Some questions are appropriate for posting on both the "user" and - the "developer" lists. In this case, pick one and only one. Do not - cross post. -

- -

Please do your best to ensure that you are not sending HTML or - "Stylelized" email to the list. If you are using Outlook or Outlook - Express or Eudora, chances are that you are sending HTML email by - default. There is usually a setting that will allow you to send - "Plain Text" email. -

- - - - - -

slf4j-announcements list

- -

- Low Traffic: - Subscribe | - Unsubscribe -
- Archives: - Pipermail | - MARC -

-

The announcements list is reserved for important SLF4J API - related announcements. As such, the traffic on this list is - guaranteed to be very low. -

- -

Given that implementations are expected to statically bind with - the SLF4J API, we recommend that any implementor of the SLF4J API - be subscribed at least to the announcements list. -

- -

slf4j-user list

- -

- Medium Traffic: - Subscribe | - Unsubscribe -
- Archives: - Pipermail | - Gmane | - MARC | - Nabble | - MailArchive - - -

- -

This is the list for users of slf4j. It is also a good forum for - asking questions about how slf4j works, and how it can be - used. SLF4J developers are usually subscribed to to this list in - order to offer support.

- - -

slf4j-dev list

- -

- Medium Traffic: - Subscribe | - Unsubscribe -
- Archives: - Pipermail | - Gmane | - MARC | - Nabble | - MailArchive -

-

 

- -

On IRC

- -

We can also be reached by IRC at irc.freenode.net#slf4j.

- -

 

- - -
- - diff --git a/trunk/slf4j-site/src/site/pages/manual.html b/trunk/slf4j-site/src/site/pages/manual.html deleted file mode 100644 index 7ea17ce19..000000000 --- a/trunk/slf4j-site/src/site/pages/manual.html +++ /dev/null @@ -1,305 +0,0 @@ - - - - -SLF4J Manual - - - - - - -
- -
- -
- - -

SLF4J User manual

- -

The Simple Logging Facade for Java or (SLF4J) is intended to - serve as a simple facade for various logging APIs allowing to plug - in the desired implementation at deployment time. -

- -

Typical usage pattern

- -
- 1: import org.slf4j.Logger;
- 2: import org.slf4j.LoggerFactory;
- 3: 
- 4: public class Wombat {
- 5:  
- 6:   final Logger logger = LoggerFactory.getLogger(Wombat.class);
- 7:   Integer t;
- 8:   Integer oldT;
- 9:
-10:   public void setTemperature(Integer temperature) {
-11:    
-12:     oldT = t;        
-13:     t = temperature;
-14:
-15:     logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);
-16:
-17:     if(temperature.intValue() > 50) {
-18:       logger.info("Temperature has risen above 50 degrees.");
-19:     }
-20:   }
-21: }
-      
- -

The example above illustrates the typical usage pattern for - SLF4j. Note the use of formatted log messages on line 15. See - the question "What is the fastest way of - logging?" in the FAQ for more details. -

- -

Swapping implementations at deployment time

- -

SLF4J supports multiple logging systems, namely, NOP, - Simple, log4j version 1.2, JDK 1.4 logging, - JCL and logback. The SLF4J distribution ships with several jar - files slf4j-nop.jar, slf4j-simple.jar, - slf4j-log4j12.jar, slf4j-log4j13.jar, - slf4j-jdk14.jar and slf4j-jcl.jar. Each of - these jar files is hardwired at compile-time to use - just one implementation, that is NOP, Simple, log4j version - 1.2, JDK 1.4 logging, and repectively - JCL. As of SLF4J version 1.1.0, all of the - bindings shipped with SLF4J depend on slf4j-api.jar - which must be present on the class path for the binding to - function properly.

- -

Small applications

- -

Small applications where configuring a fully-fledged - logging systems can be somewhat of an overkill, can drop in - slf4j-api.jar+slf4j-simple.jar instead of a binding for a - fully-fledged logging system.

- -

Libraries

- -

Authors of widely-distributed components and libraries may - code against the SLF4J interface in order to avoid imposing an - logging system on the end-user. At deployment - time, the end-user may choose the desired logging system by inserting the corresponding jar file in her - classpath. This stupid, simple and robust approach avoids many - of the painful bugs associated with dynamic discovery - processes. -

- -

Simplicity

- -

The SLF4J interfaces and their various adapters are - extremely simple. Most developers familiar with the Java - language should be able to read and fully understand the code - in less than one hour. -

- -

As noted earlier, SLF4J does not rely on any special class - loader machinery. Every variant of - slf4j-<impl>.jar is statically hardwired at - compile time to use one and only specific - implementation. Thus, SLF4J suffers from none of the class loader - problems observed when using JCL.

- -

Hopefully, the simplicity of the SLF4J interfaces and the - deployment model will make it easy for developers of other - logging APIs to conform to the SLF4J model. -

- -

Built-in support in logback

- -

The ch.qos.logback.classic.Logger class in - logback directly implements SLF4J's - org.slf4j.Logger interface. -

- -

Logback's built-in (a.k.a. native) support for SLF4J means - that the adapter for does not need to wrap logback objects in - order to make them conform to SLF4J's Logger - interface. A logback - ch.qos.logback.classic.Logger is a - org.slf4j.Logger. Thus, using SLF4J in - conjunction with logback involves strictly zero memory and - computational overhead. -

- - - - -

Mapped Diagnostic Context (MDC) support

- -

As of version 1.4.1, SLF4J supports MDC, or mapped - diagnosic context. If the underlying logging system offers MDC - functionality, then SLF4J will delegate to the underlying - system's MDC. Note that at this time, only log4j and logback - offer MDC functionality. If the undelying system does not - offer MDC, then SLF4J will silently drop MDC information. -

- -

Thus, as a SLF4J user, you can take advantage of MDC - information in the presence of log4j or logback, but without - forcing these upon your users as dependencies. -

- -

As of SLF4J version 1.5.0, SLF4J provides MDC support for - java.util.logging (JDK 1.4 logging) as well. -

- -

For more information on MDC please see the chapter on - MDC in the logback manual. - - - - -

Gradual migration to SLF4J from Jakarta Commons Logging - (JCL)

- -

jcl-over-slf4j.jar

- -

To ease migration to SLF4J from JCL, recent SLF4J - distributions include the jar file - jcl-over-slf4j.jar. This jar file is intended as a - drop-in replacement for JCL version 1.0.4. It implements the - public API of JCL but using SLF4J underneath, hence the name - "JCL over SLF4J." -

- -

Our JCL over SLF4J implementation will allow you to migrate - to SLF4J gradually, especially if some of the libraries your - software depends on continue to use JCL for the foreseeable - future. You can immediately enjoy the benefits of SLF4J's - reliability and preserve backward compatibility at the same - time. Just replace commons-logging.jar with - jcl-over-slf4j.jar. Subsequently, the selection of - the underlying logging system will be done by SLF4J instead of - JCL but without the class loader headaches. The underlying - logging system can be any of NOP, simple, jdk14 logging, log4j - or logback. Any existing dependency on commons-logging - therefore becomes less of an issue. -

- -

slf4j-jcl.jar

- -

Some of our users after having switched to SLF4J API - realize that in some contexts the use of JCL is mandatory and - their use of SLF4J can be a problem. For this uncommon but - important case, SLF4J offers a JCL binding, found in the file - slf4j-jcl.jar. The JCL binding will delegate all - logging calls made through SLF4J API to JCL. Thus, if for some - reason an existing application must use JCL, your - part of that application can still code against the SLF4J API - in a manner transparent to the larger application - environment. Your choice of SLF4J API will be invisible to the - rest of the application which can continue to use JCL. -

- -

jcl-over-slf4j.jar should not be confused with - slf4j-jcl.jar

- - -

JCL-over-SLF4J, i.e. jcl-over-slf4j.jar, comes - in handy in situations where JCL needs to be supported for - backward compatibility reasons. It can be used to fix problems - associated with JCL, without necessarily adopting the SLF4J - API, a decision which can be deferred to a later time. -

- -

On the other hand, slf4j-jcl.jar is useful after you have already adopted the SLF4J API for your component - which needs to be embedded in a larger application environment - where JCL is a formal requirement. Your software component can - still use SLF4J API without disrupting the larger - application. Indeed, slf4j-jcl.jar will delegate all - logging decisions to JCL so that the dependency on SLF4J API - by your component will be transparent to the larger whole.

- -

Please note that jcl-over-slf4j.jar and - slf4j-jcl.jar cannot be deployed at the same - time. The former jar file will cause JCL to delegate the - choice of the logging system to SLF4J and the latter jar file - will cause SLF4J to delegate the choice of the logging system - to JCL, resulting in an infinite loop. -

- -

Executive summary

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AdvantageDescription
Swappable logging API implementationsThe desired logging API can be plugged in at - deployment time by inserting the appropriate jar file on - your classpath. -
Fail-fast operationAssuming the appropriate jar file is available on the - classpath, under no circumstances will SLF4J cause your - application to fail. SLF4J's simple and robust design - ensures that SLF4J never causes exceptions to be thrown. - -

Contrast this with - LogConfigurationException thrown by JCL which - will cause your otherwise functioning application to - fail. JCL-logging will throw a - LogConfigurationException in case the Log - interface and its dynamically discovered implementation - are loaded by different class loaders. -

-
Adapter implementations for popular logging systems - SLF4J supports popular logging systems, namely log4j, - JDK 1.4 logging, Simple logging and NOP. The logback project supports - SLF4J natively.
Easy migration path -

The implementation of JCL over SLF4J, i.e - jcl-over-slf4j.jar, will allow your project to - migrate to SLF4J piecemeal, without breaking - compatibility with existing software using JCL. -

-
Support for formated log messagesAll SLF4J adapters support formated log messages with - significantly improved performace results.
- - -
- - diff --git a/trunk/slf4j-site/src/site/pages/migrator.html b/trunk/slf4j-site/src/site/pages/migrator.html deleted file mode 100644 index f6613ad5a..000000000 --- a/trunk/slf4j-site/src/site/pages/migrator.html +++ /dev/null @@ -1,231 +0,0 @@ - - - - -SLF4J Migrator - - - - - - -
- -
- -
- - -

SLF4J Migrator

- -

The SLF4J migrator is a small Java tool for migrating Java source - files from the Jakarta Commons Logging (JCL) API to SLF4J. It can - also migrate from the log4j API to SLF4J, or from - java.util.logging API to SLF4J. -

- -

The SLF4J migrator consists of a single jar file that can be - launched as a stand-alone java application. Here is the command: -

- -

java -jar slf4j-migrator-${version}.jar

- -
- -

Once the application is launched, a window similar to the - following should appear. -

- -

- -

Use the application should be self-explanatory. Please note that - this migration tool does in-place replacement of Java files, meaning - that there will be no back-up copies of modified files. It is - your responsibility to backup your files before using SLF4J - migrator. -

- - -

Limitations

- -

SLF4J migrator is intended as a simple tool to help you to - migrate your project source using JCL, log4j or JUL to SLF4J. It can - only perform elementary conversion steps. Essentially, it will - replace appropriate import lines and logger declarations. -

- -

MyClass is a sample class using JCL. Here it is before:

- -

package some.package; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public MyClass { - - - Log logger = LogFactory.getLog(MyClass.class); - - public void someMethod() { - logger.info("Hello world"); - } -}

- - and after migration:

- -

package some.package; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public MyClass { - - Logger logger = LoggerFactory.getLogger(MyClass.class); - - public void someMethod() { - logger.info("Hello world"); - } -}

- -
- -

Altough its conversion rules are elementary, the SLF4J migrator - can still alleviate much of the grunt-work involved in migrating a - Java project from JCL to SLF4J. -

- -

Migration rules from log4j to SLF4J, or from JUL to SLF4J are - similar.

- -

General limitations

- -
    - -
  • Build scipts are not modified - -

    Your Ant/Maven/Ivy build scripts need to be modified manualy to - use SLF4J instead of JCL or log4j.

    - -

    -
  • - -
  • only messages of type String are supported - -

    If one of your log statements contains a non-string object as - its sole parameter, you will have to manually add a toString() - method call on the object. -

    - -

    For example,

    -

    logger.debug(new Object());

    -

    has to be manually re-written as

    -

    logger.debug(new Object().toString());

    - -

    -
  • - -
  • the FATAL level is not supported. - -

    You have to convert them manually. This is limitation is not - deemed very serious because there are usually very few log - statements bearing the FATAL level. -

    - -

    -

    -
  • - -
  • if a method declares multipe loggers on the same line, the - conversion will not be complete. Example: - -

    - public void someMethod(Log l1, Log l2) { - ... - } - - will be converted as - - public void someMethod(Log l1, Logger l2) { - ... - } -

    -
  • -
- -

Limitations when migrating from log4j

- -
    -
  • NDC statements are left as-is - -

    Since NDC is not supported by SLF4J, the migrator cannot - properly handle NDC statements. You have to migrate them to MDC - manually. Again, this limitation is not deemed serious bebause - there are usually very few NDC statements even in large projects. -

    - -

    Please note that contrary to NDC, MDC statements are migrated - correctly because SLF4J suports such statements.

    - -

    -
  • - -
  • Calls to PropertyConfigurator or - DomConfigurator cannot be migrated since they have no - SLF4J equivalents. - -

    -

    - -
  • -
- -

Limitations when migrating from JUL

- - -
    -
  • Calls to finest(), finer() or - finest() methods of - java.util.loggging.Logger are left as is. - -

    Given that finest(), finer() or - finest() calls could map to both trace() or debug() - calls in SLF4J, it is impossible to guess how the user wants to - map these calls. -

    - -

    -

    - -
  • - - -
  • All strings matching ".severe(" are replaced by the string - ".error(" without any contexual analysys. Similarly, all strings - matching ".warning(" are replaced by ".warn(". - -

    Since the match/replace operation is not contextual, if your - code contains methods named "severe" or "warning", then the - migration results will have compilation errors. Fortunately, such - errors should be rare and easy to identify. -

    - -

    -

    - -
  • - -
  • Invocations of the following methods defined in the - java.util.logging.Logger class need to be migrated - manually: log, logp, logrb, - entering, exiting. - -
  • -
- -
- - \ No newline at end of file diff --git a/trunk/slf4j-site/src/site/pages/news.html b/trunk/slf4j-site/src/site/pages/news.html deleted file mode 100644 index 423f864fd..000000000 --- a/trunk/slf4j-site/src/site/pages/news.html +++ /dev/null @@ -1,870 +0,0 @@ - - - - -SLF4J News - - - - - - -
- -
- -
- - -

SLF4J News

- -

Please note that you can receive SLF4J related announcements by - subscribing to the SLF4J - announce mailing list. -

- -
- - -

June 5th, 2008 - Release of SLF4J 1.5.1

- -

See also the compatibility - report for this version.

- -

In order to support JCL version 1.1.1, the - jcl104-over-slf4j module was renamed as - jcl-over-slf4j. SLF4J will no longer ship with - jcl104-over-slf4j.jar but with jcl-over-slf4j.jar. - The related work responds to enhancement request discussed in bug 85 as - reported by Niklas Gustavsson. -

- -

The slf4j-jcl binding now depends on commons-logging - version 1.1.1 instead of the older 1.0.4

- - -

Added a java.util.logging to SLF4J bridge as requested in bug 38 by - Christian Stein, David Smiley, Johan Ferner, Joern Huxhorn and - others. -

- -

Fixed bug - 68 reported by Su Chuan and David Rauschenbach. SLF4J requires - log4j 1.2.12 or later. However, if an older version of log4j is - present (lacking the TRACE level), in order to avoid - NoSuchMethodError exceptions, the SLF4J's - Log4jLoggerAdapter will map the TRACE level as DEBUG. -

- - -

Fixed bug - 78 reported by Venu Thachappilly. If the argument array passed - to a Logger printing method (debug, info, etc.) was null, a - NullPointerException was thrown. With the correction, - the messagePattern is returned as is, without parameter - substitution. -

- - -

Added the getCopyOfContextMap and - setContextMap methods to the MDCAdapter - and org.sf4j.MDC classes. This was requested in bug 84 by - Anton Tagunov. -

- -

Fixed bug - 74, an endless recursion problem in Marker.contains method, - reported by Michael Newcomb. Also added he - getDetachedMarker method to IMarkerFactor - and MarkerFactory classes which was indirectly - requested in bug 74. -

- -

Added the methods getLevel() and - getEffectiveLevel() to the Category class - in log4j-over-slf4j. This addition was requested in bug 74 by - Michael Newcomb. -

- -

The SLF4J Migrator - tool has been improved to support migration from JUL to SLF4J. -

- -

In MarkerIgnoringBase class, corrected mapping of - trace methods with markers to their equivalents without marker - data. Previously, the mapping was trace to debug. The incorrect - mapping affected only calls to the trace method with - markers. Interestingly enough, this bug was picked up by new unit - tests and has not been reported as a bug by our users. -

- - -

February 26th, 2008 - Release of SLF4J 1.5.0

- - -

A tool called SLF4J Migrator now - ships with SLF4J. It can help you migrate your project using JCL or - log4j to use SLF4J instead. -

- -

Fixed bug - 61 reported by Christopher Sahnwaldt. It is now possible to - place a backslash in front of a formatting anchor, by escaping the - backslash. For example, the call to - MessageFormatter.format("C:\\\\{}", "foo") will now - correctly return "C:\\foo". The backslash character needs to be - escaped in Java, which leads to four backslashes. -

- - -

Fixed bug - 63 reported by Maarten Bosteels. SLF4J now supports MDC for - java.util.logging package. -

- -

Fixed bug - 64 reported by Michal Bernhard. The log4j binding will now alert - the user if she uses SLF4J with a version of log4j earlier than 1.2.12. -

- -

Fixed bug - 65 reported by Ben Gidley. Superfluous - <version>${parent.version}</version> lines have been - removed from pom.xml files. These lines reportedly confuse certain - Maven repositories. -

- -

In the org.apache.log4j.Category class, as - implemented in the log4j-over-slf4j module, calls to the printing - trace() are now correctly mapped to SLF4J's trace() printing method - (instead of debug()). Superfluous printing methods with the - signature xxxx(Object, Object) and xxxx(String, - Object, Object) have been removed. -

- -

Fixed bug - 67 reported by Chris Custine. The manifest file for - jcl104-over-slf4j now correctly declares version 1.0.4 for the - exported JCL packages. -

- - -

Fixed bug - 69 reported by Joern Huxhorn, who graciously supplied the fix as - well as a test case. The add method in - BasicMarker class now correctly prevents multiple - addition of the same child. Moreover, the remove method - now correctly removes the specified child marker. -

- -

Fixed bug - 41 reported by Sebastian Davids. The manifest files of various - projects now mention J2SE-1.3 as the required execution - environment. -

- -

Fixed bug - 71 reported by Manfred Geiler. The SLF4JLog and - SLF4JLocationAwareLog classes are now serializable solving - serialization problems encountered with certain libraries which - attempt to serialize JCL log instances. -

- -

Fixed bug - 73 reported by Oleg Smirsky. A "Fragment-Host: slf4j.api" line - has been added to every MANIFEST.MF file exporting - org.slf4j.impl. -

- - -

Fixed bug - 72 reported by Ian Carr. Performance issues with slf4j-jdk14 for - disabled log statements have now been corrected. -

- -
- -

August 20th, 2007 - Release of SLF4J 1.4.3

- -

Fixed bug - 60 as reported by Costin Leau. OSGI manifest entries now declare - the correct SLF4J version. -

- -

Clarified the behavior of the various methods methods in the MDC - class with respect to "null" parameters. This was requested in bug 58 by - Sebastian Davids. -

- -

Removed the slf4j-archetype module because nobody seems to have a - use for it.

- -

July 12th, 2007 - Release of SLF4J 1.4.2

- -

The log4j-over-slf4j module - has been moved back into SLF4J. Originally, this module was part of - SLF4J and was moved into logback due to the lack of MDC support in - SLF4J. With version 1.4.2 and the addition of MDC support in SLF4J - 1.4.1, log4j-over-slf4j returns to its original home. Note that the - previous name of the module was log4j-bridge. -

- -

Addition of the getMDCAdapter method to - org.slf4j.MDC class. This allows access to the actual MDC - implementation which can on occasion come in very handy. -

- -
- - - -

July 4th, 2007 - Release of SLF4J 1.4.1

- - -

SLF4J now supports Mapped Diagnostic - Contexts (MDC) as requested by Andy Gerweck and Steve Ebersole - in bug - 49. -

- -

Fixed bug - 53 as reported by Heinrich Nirschl. The public method - trace(String) in the Log4jLoggerAdapter - class incorrecly called the underlying log4j logger with level DEBUG - instead of TRACE. -

- -

Fixed various documentation related errors kindly reported by - Mark Vedder. -

- - -
- - -

May 16th, 2007 - Release of SLF4J 1.4.0

- - -

In response to many user requests over time, the TRACE level has - been added to org.slf4j.Logger - interface. Please also see the FAQ entry - discussing the TRACE level. -

- - -

Fixed bug - 47 as reported by Terry Todd. In previous a SLF4J release the - org.apache.commons.logging.impl.SLF4FLogFactory class - was renamed as SLF4JLogFactory. The - META-INF/services/org.apache.commons.logging.LogFactory - resource file had not reflected this change. It does now. -

- - -

Eric Yung reported - that Apache commons-configuration access certain commons-logging - classes, namely org.apache.commons.logging.impl.NoOpLog - and SimpleLog, directly. Following Eric's suggestion, - jcl104-over-slf4j now includes the aforementioned classes. -

- - -
- -

April 15th, 2007 - Release of SLF4J 1.3.1

- - -

In response to a enhancement - request made by Michael Newcomb, a marker can now be detached - from the internal list of the MarkerFactory that - generated it. -

- -

Fixed a silly but nonetheless annoying bug where log request of - level ERROR made through jcl104-over-slf4j would log twice. This bug - was reported - and precisely described by Andrew Cooke. -

- - -
- -

February 25th, 2007 - Release of SLF4J 1.3.0

- -

This release consists of rearrangement of classes among - projects. More specifically, the - org.slf4j.LoggerFactory class is now packaged within - the slf4j-api.jar file instead of the various slf4j - bindings. It follows that client code needs to depend on only - slf4j-api in order to compile, while the various slf4j bindings are - only needed as runtime dependencies. See also the Maven2-related FAQ entry. Given the - practical significance of this change, we highly recommend that - library-authors upgrade to version 1.3 at their earliest - convenience. -

- -

Bug number - 23 has been fixed, at the cost of minor and backward compatible - changes. In other words, jcl104-over-slf4j now preserves caller - location information. -

- -

It is now possible to obtain the root logger of the underlying - logging implementation by requesting a logger named - "ROOT". This feature was requested by Sebastien Davids - in bug - report 35.

- -

For an exact list of changes please refer to the 1.3.0 compatibility report file - as generated by clirr.

- - -
- -

January 24th, 2007 - Release of SLF4J 1.2

-

This release includes several modifications to make SLF4J - an OSGi-friendly framework. - The modules' MANIFEST.MF files now include - OSGi metadata. Regarding these improvements, and OSGi in general, the - SLF4J project is happy to welcome John E. Conlon as a new committer. -

- -

Marker objects are now Serializable. -

- -
- -

December 21st, 2006 - Release of SLF4J 1.1.0 (final)

- -

This release consists of minor bug fixes and documentation - changes. More importantly, the log4j-over-slf4j module has been - moved to the logback project, under the name log4j-bridge. -

- -

Added the file "org.apache.commons.logging.LogFactory" under - META-INF/services directory which went missing in the 1.1.0 series - of SLF4J. This fixes a compatibility problem with Apache Axis which - uses its own discovery mechanism, namely, commons-discovery version - 0.2. The problem was reported in bug report 33 - by David Varnes. -

- -

The file jcl104-over-slf4j.jar had various entries missing in its - MANIFEST.MF file, as reported by Boris Unkel in bug number - 30. -

- -
- -

November 16th, 2006 - Release of SLF4J 1.1.0-RC1

- -

This release consists of packaging related bug fix in addition to - minor documentation changes. -

- -

Contrary to RC0, RC1 no longer uses SNAPSHOT versions for the - slf4j-parent pom. The solution to Maven - version problem does not work for public projects such as SLF4J - because SNAPHOTs are not allowed on ibiblio. -

- - -
- -

November 4th, 2006 - Release of SLF4J 1.1.0-RC0

- -

This release consists of bug fixes. Moreover, since the major - packaging related changes in 1.1.0-beta0 seem to work well, this - release is marked as RC0.

- -

Fixed the JDK 1.5 dependency for the SLF4J build, as reported by - Boris Unkel in bug number - 28. SLF4J now explicitly declares a dependency on JDK 1.4 in its - pom.xml file. -

- -

Fixed an incorrect reference to the logback project in slf4j-api - pom file. This bug was reported by Boris Unkel in bug number - 29. -

- -

Fixed a syncroisation problem in factories of almost all SLF4J - bindings. This bug was reported independenly by Howard M. Lewis Ship - and Boris Unkel in bug reports 26 and - respectively 27. -

- -
- -

September 7th, 2006 - Release of SLF4J 1.1.0-beta0

- -

Release 1.1.0-beta0 is a relatively important release with a - refactoring of the way class files are organized in jar files. In - previous releases, each binding was self-contained in a single jar - file. In this release, each and every binding depends on - slf4j-api.jar which contains the bulk of the classes - required to use SLF4J, except for one or two adapter classes. Only - the adapter classes are now shipped with each specific binding jar - as appropriate for the underlying logging system.. -

- -

This release is built using Maven instead of Ant. As for the java - code, it has not been changed.

- -
- -

June 8th, 2006 - Release of SLF4J 1.0.2

- -

Release 1.0.2 is a maintenance release containing bug fixes - only.

- -
    - -
  • Fixed bug number - 22 reported by Bjorn Danielsson. This version of the SLF4J API - will no longer systematically throw an exception when the - o.a.c.l.impl.SLF4FLogFactory#release() method is - invoked. Instead, the release() method will issue a - warning. - -
  • - -
- -
- -

May 1st, 2006 - Release of SLF4J 1.0.1

- -

Release 1.0.1 is a maintenance release containing bug fixes only. - -

    - -
  • Fixed bug number - 20 reported by Steve Bate. JDK14LoggerAdapter - will now correctly relay the logger name to the underlying JDK 14 - logging system. -
  • - -
  • Added the file "org.apache.commons.logging.LogFactory" under - META-INF/services directory in the jcl104-over-slf4j jar - file. This fixes a compatibility problem with Apache Axis which - uses its own discovery mechanism, namely, commons-discovery - version 0.2. The bug was reported by Dave Wallace. -
  • - -
-

- - -
- -

March 8th, 2006 - Release of SLF4J 1.0

- -

This is release labeled as 1.0 (final) contains few relatively - minor changes: -

- -
    -
  • As discussed - on the slf4j user list, SimpleLogger now directs its - output to stderr instead of stdout. -
  • - -
  • Modified JDK14LoggerAdapter so that caller - information is now correctly printed, as reported in bug 13 by - Peter Royal. -
  • - -
  • Minor additions to the Marker interface.
  • - -
- -
- -

February 4th, 2006 - Release of SLF4J 1.0-RC6 and NLOG4J - 1.2.22

- -

The MarkingLogger interface has been removed and its - contents merged into org.slf4j.Logger. This change - should not adversely affect end-users. However, SLF4J bindings need - to be updated. This has been done for all the bindings shipped with - SLF4J distribution as well as NLOG4J. As for x4juli, the update is - planned for its next release. -

- -

The merge between the MarkingLogger and - Logger interfaces has been motivated by the need to - allow end-users to easily switch between logging systems that - support markers and those that do not. -

- -

Added a default instance to SimpleLoggerFactory to serve as a - last resort fallback mechanism. This instance is designed to be used - by a very specific group of users, namely for those developing - logging systems (e.g. log4j or LOGBack). It is not intended for - end-users of the SLF4J API. -

- -
- -

January 9th, 2006 - Release of SLF4J 1.0-RC5 and NLOG4J - 1.2.21

- -

A maintenance release correcting bugs #11 and #12 and in - general improved resilience to null input parameters across - implementations. Many thanks to Boris Unckel and Kenneth for - reporting the null input issue. -

- -
- -

December 27th, 2005 - Release of SLF4J 1.0-RC4 and NLOG4J - 1.2.20

- - -

The printing methods in org.slf4j.Logger interface - now support passing 3 or more parameters in an Object - array. This was a frequently requested feature missing in previous - versions of SLF4J. -

- -

NLOG4J 1.2.20 reflects the addition of new methods in the - org.slf4j.Logger interface.

- -
- -

December 8th, 2005 - Release of SLF4J 1.0-RC3

- -

Maintenance release fixing reported bugs #6 and #7. -

- - -

November 28th, 2005 - Release of SLF4J 1.0-RC2

- -

In response to a request by Greg Wilkins, this release adds the - jar file slf4j-jcl.jar, an SLF4J binding for JCL. Please - read the gradual migration section - in the manual for more details. -

- -
- -

November 21st, 2005 - Release of SLF4J 1.0-RC1

- -

A maintenance release correcting bugs #4 and #5. Many - thanks to Christian Beil for accurately reporting bug #4. -

- -

There has been also an effort to minimize the file sizes of the - various jar files produced by SLF4J, resulting in jar files - approximately 40% smaller than in version 1.0beta9. -

- -

Given that the SLF4J API is now deemed stable, this release is - marked as RC1, that is release candidate number 1. -

- - -
- -

October 19th, 2005 - Release of SLF4J 1.0-beta9

- -

The SLF4J distribution now includes two distinct bindings - slf4j-log4j12.jar and slf4j-log4j13.jar in order - to differentiate between log4j version 1.2 and version 1.3. This - distinction is absolutely necessary because log4j 1.2 and 1.3 are - not run-time compatible, although they are mostly compile-time - compatible. -

- -
- -

October 19th, 2005 - Release of SLF4J 1.0-beta8 and NLOG4J 1.2.18

- - -

Added a new SLF4J binding, slf4j-log4j.jar, intended to - be used in conjunction with vanilla log4j.jar, as - distributed by the Apache - Logging Services project. The slf4j-log4j binding is quite - similar in structure to the JDK 1.4 binding that existed - previously. -

- -

The slf4j-log4j binding addresses compatibility problems which - arose when copies of both log4j.jar and nlog4j.jar - lay on the class path, in particular when it was undesirable or - impossible to remove the preexisting log4j.jar file. -

- -

Methods in the org.slf4j.Logger interface related to - markers were moved to a separate super interface called - org.slf4j.MarkingLogger. This refactoring reduces - the weight of the - Logger interface. -

- -
- -

August 28th, 2005 - Release of SLF4J 1.0-beta7 and NLOG4J 1.2.17

- -

Spurred by bug report - #3, SLF4J binding code has been refactored and - simplified. Logging systems implementing SLF4J interfaces have to - have less work in order to bind with SLF4J. Moreover, these changes - have no incidence on the published interface of SLF4J. -

- - -
- -

August 26th, 2005 - Release of SLF4J 1.0-beta6

- -

To ease migration to SLF4J from JCL, this release includes a jar - file called jcl-over-slf4j-1.0.4.jar. This jar file can be - used as drop-in replacement for JCL version 1.0.4. It implements the - public API of JCL using SLF4J underneath. -

- -

Thus, you can immediately benefit from the advantages of SLF4J - without waiting for all the libraries you depend on to migrate to - SLF4J first.

- -
- -

August 16th, 2005 - Release of NLOG4J 1.2.16

- -

This release adds solves a compatibility problem between log4j - and nlog4j. Previous to this release, code compiled with log4j - would not run correctly with nlog4j. -

- -

With the fixes introduced in NLOG4J 1.2.16, code compiled with - log4j 1.2.x will run without problems when deployed using NLOG4j. -

- -

However, the inverse is not true. Code compiled with nlog4j can - only be deployed using nlog4j. -

- -
- -

August 12th, 2005 - Release of SLF4J 1.0-beta5 and NLOG4J - 1.2.15

- -

This release adds support for the Marker interface. Thus, log - statements can be decorated with Marker data allowing more - expressive power in the processing of log statements. -

- -

For the sake of IoC frameworks, Logger instances can - new be queried for their name. -

- -

With the addition of markers, sub-domains are no longer - needed.

- -

The LoggerFactoryAdapter has been simplified and - renamed as ILoggerFactory. -

- -
- -

July 5th, 2005 - Release of NLOG4J 1.2.14

- -

This release fixes compatibility problems between NLOG4J and - Jakarta Commons Logging. -

- -
- -

June 28th, 2005 - Release of SLF4J 1.0-beta4 and NLOG4J - 1.2.13

- -

Following discussions on the SLF4J developers list, the - signatures of the printing methods in org.slf4j.Logger - interface have been modified to admit messages of type - String instead of type Object as - previously. The current set of printing methods is listed below. -

- -
- void debug(String msg); 
- void debug(String format, Object arg); 
- void debug(String format, Object arg1, Object arg2); 
- void debug(String msg, Throwable t); 
-
- void error(String msg); 
- void error(String format, Object arg;) 
- void error(String format, Object arg1, Object arg2); 
- void error(String msg, Throwable t); 
-      
- void info(String msg); 
- void info(String format, Object arg); 
- void info(String format, Object arg1, Object arg2); 
- void info(String msg, Throwable t); 
-      
- void warn(String msg); 
- void warn(String format, Object arg); 
- void warn(String format, Object arg1, Object arg2); 
- void warn(String msg, Throwable t);  
- - -

NLOG4J release 1.2.13 reflects changes in the SLF4J API. -

- -

You can download SLF4J and NLOG4J, including full source code, - class files and documentation on our download page. -

- -
- -

May 17th, 2005 - SLF4J version 1.0-beta-3 released

- -

In response to user comments, the org.slf4j.ULogger - interface has been renamed as org.slf4j.Logger. -

- - -
- -

May 17th, 2005 - NLOG4J version 1.2.12 released

- -

SLF4J.ORG is proud to release NLOG4J 1.2.12, a log4j-replacement - with native SLF4J API support. Except for users of LF5, chainsaw or - NTEvenAppender, NLOG4J should be considered as a 100% - compatible, drop-in replacement for log4j version 1.2.9. -

- -

This release reflects changes in the SLF4J API, i.e renaming of - org.slf4j.ULogger interface as - org.slf4j.Logger. -

- -
- -

May 17th, 2005 - SLF4J version 1.0-beta-3 released

- -

SLF4J.ORG is proud to release SLF4J 1.0-beta-3. In response to - user comments, the org.slf4j.ULogger interface has been - renamed as org.slf4j.Logger. -

- -

You can download SLF4J, including full source code, class files - and documentation on our download page. -

- -
- -

May 14th, 2005 - NLOG4J version 1.2.11 released

- -

SLF4J.ORG is proud to release NLOG4J 1.2.11, a log4j-replacement - with native SLF4J API support. Except for users of LF5, chainsaw or - NTEvenAppender, NLOG4J should be considered as a 100% - compatible, drop-in replacement for log4j version 1.2.9. -

- -

You can download NLOG4J version 1.2.11, including full source - code, class files and documentation on our download page. -

- -
- -

May 4th, 2005 - SLF4J version 1.0-beta-2 released

- -

SLF4J.ORG is proud to release SLF4J 1.0-beta-2. This release - contains cosmetic or javadoc changes. For example, the project has a - new logo. -

- -

You can download SLF4J version 1.0-beta2, including full source - code, class files and documentation on our download page. -

- - -
- -

1 May 2005 - not-log4j-1.2.10 released

- -

Subsequent to the recall of log4j 1.2.10, SLF4J.ORG releases - non-log4j-1.2.10 for those interested in SLF4J support in log4j. -

- -

You can download not-log4j version 1.2.10, including full source - code, class files and documentation on our download page. -

- -
- - -

22 April 2005 - SLF4J project goes live

- -

The SLF4J project site, including SVN repositories go - live. Users can download SLF4J version 1.0-beta1. -

- -
- -

15 April 2005 - start of work on SLF4J source code

- -

Start of work on the SLF4j source code. -

- -
- -

13 April 2005 - start of work on SLF4J project

- -

Launch of the SLF4J project. Work has begun on the web-site, svn - repositories as well as the source code. -

- - - - -
- - diff --git a/trunk/slf4j-site/src/site/pages/svn.html b/trunk/slf4j-site/src/site/pages/svn.html deleted file mode 100644 index d91258a0c..000000000 --- a/trunk/slf4j-site/src/site/pages/svn.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - -SLF4J - - - - - - -
- -
- -
- -

Source code repositories

- -

SLF4j developers live in different countries throughout the - world. To enable them to work together, we keep the source code in - a revision control system called Subversion. SLF4J developers have write - access to the Subversion repository, enabling them to make changes - to the source code. Everyone else has read access to the repository, so - you may check out the most up-to-date development version of the - software. Note that the latest version in the Subversion repository - many not work as expected, it may not even compile properly. If you - are looking for a stable release of the source code, you should - download an official distribution instead of the latest version from Subversion.

- - -

There are several ways to access the Subversion repository:

- -

Web Access

- -

If you just wish to browse around or download a few individual - files, the best tool is the web-based ViewVC interface for - Subversion repositories: -

- - - - - - - -
For SLF4J - http://svn.slf4j.org/viewvc/slf4j/trunk/ -
- -

Checking out a read-only copy

- - -

To access the Subversion repositories anonymously, you will need - a Subversion client. -

- -

To check out the SLF4j module, issue the following command:

- -
svn checkout http://svn.slf4j.org/repos/slf4j/trunk
- -

Note that anonymous access allows read-only access only. For - read-write access please contact the slf4j developer list. -

- - - - - -
- - diff --git a/trunk/slf4j-site/src/site/pages/templates/footer.js b/trunk/slf4j-site/src/site/pages/templates/footer.js deleted file mode 100644 index dc416c0be..000000000 --- a/trunk/slf4j-site/src/site/pages/templates/footer.js +++ /dev/null @@ -1,5 +0,0 @@ - - -document.write('') diff --git a/trunk/slf4j-site/src/site/pages/templates/header.js b/trunk/slf4j-site/src/site/pages/templates/header.js deleted file mode 100644 index 34c334215..000000000 --- a/trunk/slf4j-site/src/site/pages/templates/header.js +++ /dev/null @@ -1,7 +0,0 @@ - -document.write('

'); -document.write(''); -document.write(''); -document.write('') -document.write('

'); -document.write(''); \ No newline at end of file diff --git a/trunk/slf4j-site/src/site/pages/templates/left.js b/trunk/slf4j-site/src/site/pages/templates/left.js deleted file mode 100644 index 893b7f9f6..000000000 --- a/trunk/slf4j-site/src/site/pages/templates/left.js +++ /dev/null @@ -1,24 +0,0 @@ - -document.write(''); -document.write('

Introduction'); -document.write('News'); -document.write('Documentation'); -document.write('License'); -document.write('Download'); - -document.write('Source Repository'); -document.write('Mailing Lists'); -document.write('Bug Reporting'); - -document.write('

'); -document.write('Logback'); -document.write('x4juli'); -document.write(''); -document.write('JDK14'); -document.write('Log4j'); -document.write('Simple'); -document.write('Simple-log'); -document.write('

'); - - - diff --git a/trunk/slf4j-site/src/site/pages/templates/right.js b/trunk/slf4j-site/src/site/pages/templates/right.js deleted file mode 100644 index 502225b8b..000000000 --- a/trunk/slf4j-site/src/site/pages/templates/right.js +++ /dev/null @@ -1,59 +0,0 @@ - -document.write(''); - -document.write('

JCL harmful to your health'); -document.write('

'); - -document.write('

SLF4J soapbox'); -document.write('

'); - -document.write('

JDK logging'); -document.write('

'); - -document.write('

oh wait!'); -document.write('

'); - -document.write('

Open comment'); -document.write('

'); - - -document.write('

Hello SLF4J'); -document.write('

'); - - -document.write('

Innovation in the Log space'); -document.write('

'); - - -document.write('

Frameworks I use'); -document.write('

'); - -document.write('

VERSION 99.0'); -document.write('

'); - -document.write('

JCL and SLF4J'); -document.write('

'); - - -document.write('

Code Template for Netbeans'); -document.write('

'); - - -document.write('

Maven2, Cargo etc.'); -document.write('

'); - -document.write('

JCL woes'); -document.write('

'); - -document.write('

Embedded Web Integration'); -document.write('

'); - - -document.write('

How to Use SLF4J with log4j'); -document.write('

'); - -document.write('

Cool down the hot deployment'); -document.write('

'); - -document.write('

Join us: Be Commons-Logging Free!'); -document.write('

'); diff --git a/trunk/slf4j-site/src/site/resources/images/logos/qosLogo.png b/trunk/slf4j-site/src/site/resources/images/logos/qosLogo.png deleted file mode 100644 index 52b216e91..000000000 Binary files a/trunk/slf4j-site/src/site/resources/images/logos/qosLogo.png and /dev/null differ diff --git a/trunk/slf4j-site/src/site/resources/images/logos/qoslogo.gif b/trunk/slf4j-site/src/site/resources/images/logos/qoslogo.gif deleted file mode 100644 index d06ec29be..000000000 Binary files a/trunk/slf4j-site/src/site/resources/images/logos/qoslogo.gif and /dev/null differ diff --git a/trunk/slf4j-site/src/site/resources/images/logos/slf4j-logo.jpg b/trunk/slf4j-site/src/site/resources/images/logos/slf4j-logo.jpg deleted file mode 100644 index 62295c91c..000000000 Binary files a/trunk/slf4j-site/src/site/resources/images/logos/slf4j-logo.jpg and /dev/null differ diff --git a/trunk/slf4j-site/src/site/resources/images/logos/valid-html401.png b/trunk/slf4j-site/src/site/resources/images/logos/valid-html401.png deleted file mode 100644 index 7cd17ee52..000000000 Binary files a/trunk/slf4j-site/src/site/resources/images/logos/valid-html401.png and /dev/null differ diff --git a/trunk/slf4j-site/src/site/resources/images/slf4j-migrator.gif b/trunk/slf4j-site/src/site/resources/images/slf4j-migrator.gif deleted file mode 100644 index 27c126ef7..000000000 Binary files a/trunk/slf4j-site/src/site/resources/images/slf4j-migrator.gif and /dev/null differ diff --git a/trunk/src/main/assembly/source.xml b/trunk/src/main/assembly/source.xml deleted file mode 100644 index 02b1ba3f6..000000000 --- a/trunk/src/main/assembly/source.xml +++ /dev/null @@ -1,261 +0,0 @@ - - dist - - zip - tar.gz - - - - - slf4j-api/ - slf4j-api/ - - pom.xml - - - - - slf4j-jcl/ - slf4j-jcl/ - - pom.xml - - - - - slf4j-jdk14/ - slf4j-jdk14/ - - pom.xml - - - - - slf4j-log4j12/ - slf4j-log4j12/ - - pom.xml - - - - - slf4j-nop/ - slf4j-nop/ - - pom.xml - - - - - slf4j-simple/ - slf4j-simple/ - - pom.xml - - - - - jcl104-over-slf4j/ - jcl104-over-slf4j/ - - pom.xml - - - - - log4j-over-slf4j/ - log4j-over-slf4j/ - - pom.xml - - - - - slf4j-site/ - slf4j-site/ - - pom.xml - - - - - slf4j-migrator/ - slf4j-site/ - - pom.xml - - - - - - - - slf4j-api/src/ - slf4j-api/src/ - - - test/output/ - - - - - - slf4j-jcl/src/ - slf4j-jcl/src/ - - - - slf4j-jdk14/src/ - slf4j-jdk14/src/ - - - - slf4j-log4j12/src/ - slf4j-log4j12/src/ - - - slf4j-nop/src/ - slf4j-nop/src/ - - - slf4j-simple/src/ - slf4j-simple/src/ - - - slf4j-jcl/src/ - slf4j-jcl/src/ - - - jcl104-over-slf4j/src/ - jcl104-over-slf4j/src/ - - - log4j-over-slf4j/src/ - log4j-over-slf4j/src/ - - - slf4j-site/src/ - slf4j-site/src/ - - - slf4j-migrator/src/ - slf4j-migrator/src/ - - - - - - - slf4j-api/target/ - / - - slf4j-api-${project.version}-sources.jar - slf4j-api-${project.version}.jar - - - - - slf4j-jcl/target/ - / - - slf4j-jcl-${project.version}.jar - slf4j-jcl-${project.version}-sources.jar - - - - - slf4j-jdk14/target/ - / - - slf4j-jdk14-${project.version}-sources.jar - slf4j-jdk14-${project.version}.jar - - - - - slf4j-log4j12/target/ - / - - slf4j-log4j12-${project.version}.jar - slf4j-log4j12-${project.version}-sources.jar - - - - - slf4j-nop/target/ - / - - slf4j-nop-${project.version}.jar - slf4j-nop-${project.version}-sources.jar - - - - - slf4j-simple/target/ - / - - slf4j-simple-${project.version}-sources*.jar - slf4j-simple-${project.version}.jar - - - - - jcl104-over-slf4j/target/ - / - - jcl104-over-slf4j-${project.version}-sources.jar - jcl104-over-slf4j-${project.version}.jar - - - - log4j-over-slf4j/target/ - / - - log4j-over-slf4j-${project.version}.jar - log4j-over-slf4j-${project.version}-sources.jar - - - - - slf4j-migrator/target/ - / - - slf4j-migrator-${project.version}.jar - slf4j-migrator-${project.version}-sources.jar - - - - - - target/site - /site - - dist/* - - - - - - - src/ - README* - LICENSE* - pom.xml - - - - - \ No newline at end of file diff --git a/trunk/version.pl b/trunk/version.pl deleted file mode 100644 index 9334e7dcc..000000000 --- a/trunk/version.pl +++ /dev/null @@ -1,43 +0,0 @@ - -if ($#ARGV < 1) { - print "Usage: version.pl VER FILE {FILE, FILE}\n"; - exit; -} - -$V= $ARGV[0]; -print "VER:$V\r\n"; -shift(@ARGV); - -sub replace () { - my $filename = $_[0]; - - if(-s $filename) { - print "Processing [" . $filename . "]\r\n"; - - my $backup = "$filename.original"; - - rename($filename, $backup); - open(OUT, ">$filename"); - open(IN, "$backup"); - - my $hitCount=0; - while() { - if($hitCount == 0 && /.*<\/version>/) { - s/.*<\/version>/$V<\/version>/; - $hitCount++; - } - print OUT; - } - close(IN); - close(OUT); - } else { - print "File [" . $filename . "] does not exist\r\n" - } -} - -foreach $ARG (@ARGV) { - do replace($ARG); -} - - -