Merge pull request #38 from FinamTrade/master

Introducing support for android logging
This commit is contained in:
Andrey Korzhevskiy 2013-03-26 16:26:17 -07:00
commit 624256e28a
13 changed files with 977 additions and 1 deletions

2
.gitignore vendored
View File

@ -10,4 +10,4 @@ target
integration/bundle/
integration/felix-cache/
runner
.DS_Store

View File

@ -57,6 +57,7 @@
<module>slf4j-jdk14</module>
<module>slf4j-log4j12</module>
<module>slf4j-jcl</module>
<module>slf4j-android</module>
<module>slf4j-ext</module>
<module>jcl-over-slf4j</module>
<module>log4j-over-slf4j</module>

2
slf4j-android/.gitignore vendored Executable file
View File

@ -0,0 +1,2 @@
/gen

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.slf4j"
android:versionCode="175"
android:versionName="1.7.5">
<uses-sdk android:minSdkVersion="3" />
</manifest>

24
slf4j-android/LICENSE.txt Normal file
View File

@ -0,0 +1,24 @@
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.

View File

@ -0,0 +1,12 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
android.library=true
# Project target.
target=android-3

63
slf4j-android/pom.xml Normal file
View File

@ -0,0 +1,63 @@
<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-parent</artifactId>
<version>1.7.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>slf4j-android</artifactId>
<packaging>jar</packaging>
<name>SLF4J Android Binding</name>
<description>SLF4J Android Binding</description>
<url>http://www.slf4j.org</url>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>1.5_r4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
<Bundle-Description>${project.description}</Bundle-Description>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<!-- Google Android requires class compatibility set to 5.0 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,545 @@
/*
* Copyright (c) 2004-2011 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 android.util.Log;
import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MarkerIgnoringBase;
import org.slf4j.helpers.MessageFormatter;
/**
* A simple implementation that delegates all log requests to the Google Android
* logging facilities. Note that this logger does not support {@link org.slf4j.Marker}.
* That is, methods taking marker data simply invoke the corresponding method
* without the Marker argument, discarding any marker data passed as argument.
* <p/>
* The logging levels specified for SLF4J can be almost directly mapped to
* the levels that exist in the Google Android platform. The following table
* shows the mapping implemented by this logger.
* <p/>
* <table border="1">
* <tr><th><b>SLF4J<b></th><th><b>Android</b></th></tr>
* <tr><td>TRACE</td><td>{@link android.util.Log#VERBOSE}</td></tr>
* <tr><td>DEBUG</td><td>{@link android.util.Log#DEBUG}</td></tr>
* <tr><td>INFO</td><td>{@link android.util.Log#INFO}</td></tr>
* <tr><td>WARN</td><td>{@link android.util.Log#WARN}</td></tr>
* <tr><td>ERROR</td><td>{@link android.util.Log#ERROR}</td></tr>
* </table>
*
* @author Andrey Korzhevskiy <a.korzhevskiy@gmail.com>
*/
public class AndroidLoggerAdapter extends MarkerIgnoringBase {
private static final long serialVersionUID = -1227274521521287937L;
/**
* Package access allows only {@link AndroidLoggerFactory} to instantiate
* SimpleLogger instances.
*/
AndroidLoggerAdapter(final String name) {
this.name = name;
}
/**
* Is this logger instance enabled for the VERBOSE level?
*
* @return True if this Logger is enabled for level VERBOSE, false otherwise.
*/
public boolean isTraceEnabled() {
return Log.isLoggable(name, Log.VERBOSE);
}
/**
* Log a message object at level VERBOSE.
*
* @param msg
* - the message object to be logged
*/
public void trace(final String msg) {
Log.v(name, msg);
}
/**
* Log a message at level VERBOSE according to the specified format and
* argument.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for level VERBOSE.
* </p>
*
* @param format
* the format string
* @param arg
* the argument
*/
public void trace(final String format, final Object arg) {
if (Log.isLoggable(name, Log.VERBOSE)) {
FormattingTuple ft = MessageFormatter.format(format, arg);
Log.v(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* Log a message at level VERBOSE according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the VERBOSE level.
* </p>
*
* @param format
* the format string
* @param arg1
* the first argument
* @param arg2
* the second argument
*/
public void trace(final String format, final Object arg1, final Object arg2) {
if (Log.isLoggable(name, Log.VERBOSE)) {
FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Log.v(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* Log a message at level VERBOSE according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the VERBOSE level.
* </p>
*
* @param format
* the format string
* @param argArray
* an array of arguments
*/
public void trace(final String format, final Object... argArray) {
if (Log.isLoggable(name, Log.VERBOSE)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
Log.v(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* Log an exception (throwable) at level VERBOSE with an accompanying message.
*
* @param msg
* the message accompanying the exception
* @param t
* the exception (throwable) to log
*/
public void trace(final String msg, final Throwable t) {
Log.v(name, 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 Log.isLoggable(name, Log.DEBUG);
}
/**
* Log a message object at level DEBUG.
*
* @param msg
* - the message object to be logged
*/
public void debug(final String msg) {
Log.d(name, msg);
}
/**
* Log a message at level DEBUG according to the specified format and argument.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for level DEBUG.
* </p>
*
* @param format
* the format string
* @param arg
* the argument
*/
public void debug(final String format, final Object arg) {
if (Log.isLoggable(name, Log.DEBUG)) {
FormattingTuple ft = MessageFormatter.format(format, arg);
Log.d(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* Log a message at level DEBUG 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(final String format, final Object arg1, final Object arg2) {
if (Log.isLoggable(name, Log.DEBUG)) {
FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Log.d(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* Log a message at level DEBUG 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(final String format, final Object... argArray) {
if (Log.isLoggable(name, Log.DEBUG)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
Log.d(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* 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(final String msg, final Throwable t) {
Log.d(name, 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 Log.isLoggable(name, Log.INFO);
}
/**
* Log a message object at the INFO level.
*
* @param msg
* - the message object to be logged
*/
public void info(final String msg) {
Log.i(name, msg);
}
/**
* Log a message at level INFO 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(final String format, final Object arg) {
if (Log.isLoggable(name, Log.INFO)) {
FormattingTuple ft = MessageFormatter.format(format, arg);
Log.i(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* 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(final String format, final Object arg1, final Object arg2) {
if (Log.isLoggable(name, Log.INFO)) {
FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Log.i(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* Log a message at level INFO 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(final String format, final Object... argArray) {
if (Log.isLoggable(name, Log.INFO)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
Log.i(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* 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(final String msg, final Throwable t) {
Log.i(name, 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 Log.isLoggable(name, Log.WARN);
}
/**
* Log a message object at the WARN level.
*
* @param msg
* - the message object to be logged
*/
public void warn(final String msg) {
Log.w(name, 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(final String format, final Object arg) {
if (Log.isLoggable(name, Log.WARN)) {
FormattingTuple ft = MessageFormatter.format(format, arg);
Log.w(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* 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(final String format, final Object arg1, final Object arg2) {
if (Log.isLoggable(name, Log.WARN)) {
FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Log.w(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* Log a message at level WARN 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(final String format, final Object... argArray) {
if (Log.isLoggable(name, Log.WARN)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
Log.w(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* 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(final String msg, final Throwable t) {
Log.w(name, 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 Log.isLoggable(name, Log.ERROR);
}
/**
* Log a message object at the ERROR level.
*
* @param msg
* - the message object to be logged
*/
public void error(final String msg) {
Log.e(name, 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(final String format, final Object arg) {
if (Log.isLoggable(name, Log.ERROR)) {
FormattingTuple ft = MessageFormatter.format(format, arg);
Log.e(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* 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(final String format, final Object arg1, final Object arg2) {
if (Log.isLoggable(name, Log.ERROR)) {
FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Log.e(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* Log a message at level ERROR 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(final String format, final Object... argArray) {
if (Log.isLoggable(name, Log.ERROR)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
Log.e(name, ft.getMessage(), ft.getThrowable());
}
}
/**
* 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(final String msg, final Throwable t) {
Log.e(name, msg, t);
}
}

View File

@ -0,0 +1,108 @@
/*
* Copyright (c) 2004-2011 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 android.util.Log;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* AndroidLoggerFactory is an implementation of {@link ILoggerFactory} returning
* the appropriately named {@link AndroidLoggerFactory} instance.
*
* @author Andrey Korzhevskiy <a.korzhevskiy@gmail.com>
*/
public class AndroidLoggerFactory implements ILoggerFactory {
private final ConcurrentMap<String, Logger> loggerMap;
static final int TAG_MAX_LENGTH = 23; // tag names cannot be longer on Android platform
// see also android/system/core/include/cutils/property.h
// and android/frameworks/base/core/jni/android_util_Log.cpp
public AndroidLoggerFactory() {
loggerMap = new ConcurrentHashMap<String, Logger>();
}
/*
* (non-Javadoc)
*
* @see org.slf4j.ILoggerFactory#getLogger(java.lang.String)
*/
public Logger getLogger(String name) {
final String passedName = name;
name = forceValidName(passedName); // fix for bug #173
if (!passedName.equals(name)) {
Log.i(AndroidLoggerFactory.class.getSimpleName(),
"Logger name '" + passedName + "' exceeds maximum length of " + TAG_MAX_LENGTH +
" characters, using '" + name + "' instead.");
}
Logger logger = loggerMap.get(name);
if (logger == null) {
Logger newInstance = new AndroidLoggerAdapter(name);
Logger oldInstance = loggerMap.putIfAbsent(name, newInstance);
logger = oldInstance == null ? newInstance : oldInstance;
}
return logger;
}
/**
* Trim name in case it exceeds maximum length of {@value #TAG_MAX_LENGTH} characters.
*/
private static String forceValidName(String name) {
if (name != null && name.length() > TAG_MAX_LENGTH) {
final StringTokenizer st = new StringTokenizer(name, ".");
if (st.hasMoreTokens()) { // note that empty tokens are skipped, i.e., "aa..bb" has tokens "aa", "bb"
final StringBuilder sb = new StringBuilder();
String token;
do {
token = st.nextToken();
if (token.length() == 1) { // token of one character appended as is
sb.append(token);
sb.append('.');
} else if (st.hasMoreTokens()) { // truncate all but the last token
sb.append(token.charAt(0));
sb.append("*.");
} else { // last token (usually class name) appended as is
sb.append(token);
}
} while (st.hasMoreTokens());
name = sb.toString();
}
// Either we had no useful dot location at all or name still too long.
// Take leading part and append '*' to indicate that it was truncated
if (name.length() > TAG_MAX_LENGTH) {
name = name.substring(0, TAG_MAX_LENGTH - 1) + '*';
}
}
return name;
}
}

View File

@ -0,0 +1,80 @@
/**
* Copyright (c) 2004-2011 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&uuml;lc&uuml;
*/
public class StaticLoggerBinder implements LoggerFactoryBinder {
/**
* The unique instance of this class.
*/
private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
/**
* Return the singleton of this class.
*
* @return the StaticLoggerBinder singleton
*/
public static StaticLoggerBinder getSingleton() {
return SINGLETON;
}
/**
* Declare the version of the SLF4J API this implementation is compiled against.
* The value of this field is usually modified with each release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
public static String REQUESTED_API_VERSION = "1.6.99"; // !final
private static final String loggerFactoryClassStr = AndroidLoggerFactory.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 AndroidLoggerFactory();
}
public ILoggerFactory getLoggerFactory() {
return loggerFactory;
}
public String getLoggerFactoryClassStr() {
return loggerFactoryClassStr;
}
}

View File

@ -0,0 +1,59 @@
/**
* Copyright (c) 2004-2011 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.BasicMDCAdapter;
import org.slf4j.spi.MDCAdapter;
/**
* This implementation is bound to {@link BasicMDCAdapter}.
*
* @author Ceki G&uuml;lc&uuml;
*/
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();
}
}

View File

@ -0,0 +1,66 @@
/**
* Copyright (c) 2004-2011 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&uuml;lc&uuml;
*/
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();
}
}

View File

@ -0,0 +1,9 @@
Implementation-Title: slf4j-android
Bundle-ManifestVersion: 2
Bundle-SymbolicName: slf4j.android
Bundle-Name: slf4j-android
Bundle-Vendor: SLF4J.ORG
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.slf4j.impl;version=${parsedVersion.osgiVersion}
Import-Package: org.slf4j;version=${parsedVersion.osgiVersion}, org.slf4j.spi;version=${parsedVersion.osgiVersion}, org.slf4j.helpers;version=${parsedVersion.osgiVersion}
Fragment-Host: slf4j.api