Mavenizing of SLF4J, on going work

This commit is contained in:
Ceki Gulcu 2006-08-14 20:34:26 +00:00
parent cc9492f5aa
commit ddce36368f
19 changed files with 2054 additions and 0 deletions

99
pom.xml Normal file
View File

@ -0,0 +1,99 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j</artifactId>
<version>1.1.0</version>
<packaging>pom</packaging>
<name>SLF4J</name>
<url>http://www.slf4j.org</url>
<organization>
<name>QOS.ch</name>
<url>http://www.qos.ch</url>
</organization>
<inceptionYear>2005</inceptionYear>
<modules>
<module>slf4j-api</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<build>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>
maven-project-info-reports-plugin
</artifactId>
<reportSets>
<reportSet>
<reports>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
<links>
<link>
http://java.sun.com/j2se/1.5.0/docs/api
</link>
</links>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.1</version>
<configuration>
<descriptors>
<descriptor>
src/main/assembly/source.xml
</descriptor>
</descriptors>
<finalName>
logback-${project.version}
</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>target/site/dist/</outputDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

78
slf4j-api/pom.xml Normal file
View File

@ -0,0 +1,78 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j</artifactId>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${parent.version}</version>
<packaging>jar</packaging>
<name>SLF4J API Module</name>
<url>http://www.slf4j.org</url>
<description>
<!--
Never _never_ let Eclipse's auto format function add
a line return in the description.
The generated jar will contain a corrupt MANIFEST file.
-->
Logback: the generic, reliable, fast and flexible logging library for Java.
</description>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<reportFormat>plain</reportFormat>
<trimStackTrace>false</trimStackTrace>
<excludes>
<exclude>**/AllTest.java</exclude>
<exclude>**/PackageTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>bundle-test-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,66 @@
/*
* 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;
/**
* <code>ILoggerFactory</code> instances manufacture {@link Logger}
* instances by name.
*
* <p>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. Only developers of SLF4J conforming logging systems
* need to worry about this interface.
*
* <p>See the section <a href="http://slf4j.org/faq.html#3">Implementing
* the SLF4J API</a> in the FAQ for details on how to make your logging
* system conform to SLF4J.
*
* @author Ceki G&uuml;lc&uuml;
*/
public interface ILoggerFactory {
/**
* Return an appropriate {@link Logger} instance as specified by the
* <code>name</code> parameter.
*
* <p>Null-valued name arguments are considered invalid.
*
* <p>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);
}

View File

@ -0,0 +1,68 @@
/*
* 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;
/**
* Implementaitons of this interface are used to manufacture {@link Marker}
* instances.
*
* <p>See the section <a href="http://slf4j.org/faq.html#3">Implementing
* the SLF4J API</a> in the FAQ for details on how to make your logging
* system conform to SLF4J.
*
* @author Ceki G&uuml;lc&uuml;
*/
public interface IMarkerFactory {
/**
* Manufacture a {@link Marker} instance by name. If the instance has been
* created earlier, return the previously created instance.
*
* <p>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);
}

View File

@ -0,0 +1,546 @@
/*
* 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;
/**
*
* The main user interface to logging. It is expected that logging
* takes place through concrete implementations of this interface.
*
* @author Ceki G&uuml;lc&uuml;
*/
public interface Logger {
/**
* Return the name of this <code>Logger</code> instance.
*/
public String getName();
/**
* 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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the DEBUG level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the DEBUG level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the DEBUG level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the INFO level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the INFO level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the INFO level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the WARN level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the WARN level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the WARN level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the ERROR level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the ERROR level. </p>
*
* @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.
*
* <p>This form avoids superfluous object creation when the logger
* is disabled for the ERROR level. </p>
*
* @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);
}

View File

@ -0,0 +1,120 @@
/*
* 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.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.
*
* <p>Markers can contain child markers, which in turn can contain children
* of their own.
*
* @author Ceki G&uuml;lc&uuml;
*/
public interface Marker {
/**
* This constant represents any marker, including a null marker.
*/
public static final String ANY_MARKER = "*";
/**
* This constant represents any non-null marker.
*/
public static 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);
// void makeImmutable();
// public boolean isImmutable();
}

View File

@ -0,0 +1,142 @@
/*
* 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.Marker;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
/**
* An almost trivial implementation of the {@link Marker} interface.
*
* <p><code>BasicMarker</code> lets users specify marker
* information. However, it does not offer any useful operations on
* that information.
*
* <p>Simple logging systems which ignore marker data, just return
* instances of this class in order to conform to the SLF4J API.
*
* @author Ceki G&uuml;lc&uuml;
*/
public class BasicMarker implements Marker {
final String name;
List children;
final IMarkerFactory factory;
BasicMarker(String name, IMarkerFactory factory) {
this.name = name;
this.factory = factory;
}
public String getName() {
return name;
}
public synchronized void add(Marker child) {
if (child == null) {
throw new NullPointerException(
"Null children cannot be added to a Marker.");
}
if (children == null) {
children = new Vector();
}
children.add(child);
}
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) {
return false;
}
}
// 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;
}
public boolean contains(String name) {
if(name == null) {
return false;
}
if(factory.exists(name)) {
Marker other = factory.getMarker(name);
return contains(other);
} else {
return false;
}
}
}

View File

@ -0,0 +1,94 @@
/*
* 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.IMarkerFactory;
import org.slf4j.Marker;
/**
* An almost trivial implementation of the {@link IMarkerFactory}
* interface which creates {@link BasicMarker} instances.
*
* <p>Simple logging systems can conform to the SLF4J API by binding
* {@link org.slf4j.MarkerFactory} with an instance of this class.
*
* @author Ceki G&uuml;lc&uuml;
*/
public class BasicMarkerFactory implements IMarkerFactory {
Map markerMap = new HashMap();
/**
* Regular users should <em>not</em> create
* <code>BasicMarkerFactory</code> instances. <code>Marker</code>
* 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, this);
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);
}
}

View File

@ -0,0 +1,147 @@
/*
* 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.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 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);
}
}

View File

@ -0,0 +1,159 @@
/*
* 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;
/**
* Formats messages according to very simple substitution rules. Substitutions can be
* made 1, 2 or more arguments.
* <p>
* For example,
* <pre>MessageFormatter.format("Hi {}.", "there");</pre> will
* return the string "Hi there.".
* <p>
* The {} pair is called the <em>formatting anchor</em>. It serves to designate the
* location where arguments need to be substituted within the message pattern.
* <p>
* 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, <pre>MessageFormatter.format("File name is \\{{}}.", "App folder.zip");</pre>
* will return the string "File name is {App folder.zip}.".
*
* See {@link #format(String, Object)}, {@link #format(String, Object, Object)}
* and {@link #arrayFormat(String, Object[])} methods for more details.
*
* @author Ceki G&uuml;lc&uuml;
*/
public class MessageFormatter {
static final char DELIM_START = '{';
static final char DELIM_STOP = '}';
/**
* Performs single argument substitution for the 'messagePattern' passed as
* parameter.
* <p>
* For example, <pre>MessageFormatter.format("Hi {}.", "there");</pre> will
* return the string "Hi there.".
* <p>
* @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.
* <p>
* For example,
* <pre>MessageFormatter.format("Hi {}. My name is {}.", "Alice", "Bob");</pre> 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);
StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);
for (int L = 0; L < argArray.length; L++) {
char escape = 'x';
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 (j > 0) {
escape = messagePattern.charAt(j - 1);
}
if(escape == '\\') {
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 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 second {} pair.
sbuf.append(messagePattern.substring(i, messagePattern.length()));
return sbuf.toString();
}
}

View File

@ -0,0 +1,50 @@
/*
* 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;
/**
*
* An internal utility class.
*
* @author Ceki G&uuml;lc&uuml;
*/
public class Util {
static final public void reportFailure(String msg, Throwable t) {
System.err.println(msg);
System.err.println("Reported exception:");
t.printStackTrace();
}
}

View File

@ -0,0 +1,17 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title></title>
</head>
<body>
<p>Implementations of core logging interfaces defined in the {@link
org.slf4j} package.</p>
<hr/>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title></title>
</head>
<body>
<p>Core logging interfaces.</p>
<hr/>
</body>
</html>

View File

@ -0,0 +1,66 @@
/*
* 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&uuml;lc&uuml;
*/
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
* <code>LoggerFactoryBinder</code> instance is <em>intended</em> to return.
*
* <p>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();
}

View File

@ -0,0 +1,67 @@
/*
* 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&uuml;lc&uuml;
*/
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
* <code>MarkerFactoryBinder</code> instance is <em>intended</em> to return.
*
* <p>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();
}

View File

@ -0,0 +1,8 @@
<body>
Classes and interfaces which are internal to SLF4J. Under most
circumstances SLF4J users should be oblivious even to the existence of
this package.
</body>

View File

@ -0,0 +1,20 @@
// TOTO
package org.slf4j;
import org.slf4j.impl.MessageFormatterTest;
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.addTestSuite(MessageFormatterTest.class);
suite.addTestSuite(BasicMarkerTest.class);
return suite;
}
}

View File

@ -0,0 +1,114 @@
/*
* 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;
import org.slf4j.impl.BasicMarkerFactory;
/**
* @author ceki
*/
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";
final IMarkerFactory factory;
final Marker blue;
final Marker red;
final Marker green;
final Marker comp;
final Marker multiComp;
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));
}
}

View File

@ -0,0 +1,177 @@
/*
* 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.impl.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 test1Param() {
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("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);
}
public void test2Param() {
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 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);
}
}