Mercurial Hosting > luan
changeset 1455:1437fb1f0956
add slf4j-goodjava
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 08 Mar 2020 16:50:14 -0600 |
parents | 219f2b937f2b |
children | 4cc4f08a94e1 |
files | classpath.sh scripts/build-luan.sh slf4j/src/org/slf4j/impl/GoodAdapter.java slf4j/src/org/slf4j/impl/GoodFactory.java slf4j/src/org/slf4j/impl/StaticLoggerBinder.java |
diffstat | 5 files changed, 190 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/classpath.sh Sun Mar 08 14:11:30 2020 -0600 +++ b/classpath.sh Sun Mar 08 16:50:14 2020 -0600 @@ -1,6 +1,7 @@ LUAN_HOME=`pwd` CLASSPATH=$LUAN_HOME/src +CLASSPATH=$CLASSPATH:$LUAN_HOME/slf4j/src for file in $LUAN_HOME/lib/*; do CLASSPATH=$CLASSPATH:$file;
--- a/scripts/build-luan.sh Sun Mar 08 14:11:30 2020 -0600 +++ b/scripts/build-luan.sh Sun Mar 08 16:50:14 2020 -0600 @@ -1,17 +1,25 @@ set -e cd `dirname $0`/.. +LUANHOME=`pwd` rm -rf build mkdir -p build/luan/jars +cp lib/* build/luan/jars find . -name *.class -delete . classpath.sh -javac -classpath $CLASSPATH `find src -name *.java` -cd src; jar cvf ../build/luan/jars/luan.jar `find . -name *.class -o -name *.luan`; cd .. -cp lib/* build/luan/jars + +cd $LUANHOME/src +javac -classpath $CLASSPATH `find . -name *.java` +jar cvf $LUANHOME/build/luan/jars/luan.jar `find . -name *.class -o -name *.luan` +cd $LUANHOME/slf4j/src +javac -classpath $CLASSPATH `find . -name *.java` +jar cvf $LUANHOME/build/luan/jars/slf4j-goodjava.jar `find . -name *.class -o -name *.luan` + +cd $LUANHOME cp scripts/install.sh build/luan chmod +x build/luan/install.sh cp scripts/uninstall.sh build/luan
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/slf4j/src/org/slf4j/impl/GoodAdapter.java Sun Mar 08 16:50:14 2020 -0600 @@ -0,0 +1,134 @@ +package org.slf4j.impl; + +import org.slf4j.helpers.MarkerIgnoringBase; +import org.slf4j.helpers.MessageFormatter; +import org.slf4j.helpers.FormattingTuple; + + +final class GoodAdapter extends MarkerIgnoringBase { + private final goodjava.logging.Logger logger; + + GoodAdapter(goodjava.logging.Logger logger) { + this.logger = logger; + } + + public void error​(String msg) { + logger.error(msg); + } + + public void error​(String msg, Throwable t) { + logger.error(msg,t); + } + + public boolean isErrorEnabled() { + return true; + } + + public void error(String format, Object... arguments) { + FormattingTuple ft = MessageFormatter.arrayFormat(format,arguments); + logger.error( ft.getMessage(), ft.getThrowable() ); + } + + public void error(String format, Object arg1, Object arg2) { + error(format,new Object[]{arg1,arg2}); + } + + public void error(String format, Object arg) { + error(format,new Object[]{arg}); + } + + public void warn(String msg) { + logger.warn(msg); + } + + public void warn(String msg, Throwable t) { + logger.warn(msg,t); + } + + public boolean isWarnEnabled() { + return true; + } + + public void warn(String format, Object... arguments) { + FormattingTuple ft = MessageFormatter.arrayFormat(format,arguments); + logger.warn( ft.getMessage(), ft.getThrowable() ); + } + + public void warn(String format, Object arg1, Object arg2) { + warn(format,new Object[]{arg1,arg2}); + } + + public void warn(String format, Object arg) { + warn(format,new Object[]{arg}); + } + + public void info(String msg) { + logger.info(msg); + } + + public void info(String msg, Throwable t) { + logger.info(msg,t); + } + + public boolean isInfoEnabled() { + return logger.isInfoEnabled(); + } + + public void info(String format, Object... arguments) { + FormattingTuple ft = MessageFormatter.arrayFormat(format,arguments); + logger.info( ft.getMessage(), ft.getThrowable() ); + } + + public void info(String format, Object arg1, Object arg2) { + info(format,new Object[]{arg1,arg2}); + } + + public void info(String format, Object arg) { + info(format,new Object[]{arg}); + } + + public void debug(String msg) { + logger.debug(msg); + } + + public void debug(String msg, Throwable t) { + logger.debug(msg,t); + } + + public boolean isDebugEnabled() { + return logger.isDebugEnabled(); + } + + public void debug(String format, Object... arguments) { + FormattingTuple ft = MessageFormatter.arrayFormat(format,arguments); + logger.debug( ft.getMessage(), ft.getThrowable() ); + } + + public void debug(String format, Object arg1, Object arg2) { + debug(format,new Object[]{arg1,arg2}); + } + + public void debug(String format, Object arg) { + debug(format,new Object[]{arg}); + } + + public void trace(String msg) { + } + + public void trace(String msg, Throwable t) { + } + + public boolean isTraceEnabled() { + return false; + } + + public void trace(String format, Object... arguments) { + } + + public void trace(String format, Object arg1, Object arg2) { + } + + public void trace(String format, Object arg) { + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/slf4j/src/org/slf4j/impl/GoodFactory.java Sun Mar 08 16:50:14 2020 -0600 @@ -0,0 +1,20 @@ +package org.slf4j.impl; + +import java.util.Map; +import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.ILoggerFactory; + + +public final class GoodFactory implements ILoggerFactory { + private final Map<String,Logger> map = new HashMap<String,Logger>(); + + public synchronized Logger getLogger(String name) { + Logger logger = map.get(name); + if( logger == null ) { + logger = new GoodAdapter(goodjava.logging.LoggerFactory.getLogger(name)); + map.put(name,logger); + } + return logger; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/slf4j/src/org/slf4j/impl/StaticLoggerBinder.java Sun Mar 08 16:50:14 2020 -0600 @@ -0,0 +1,24 @@ +package org.slf4j.impl; + +import org.slf4j.ILoggerFactory; +import org.slf4j.spi.LoggerFactoryBinder; + + +public final class StaticLoggerBinder implements LoggerFactoryBinder { + private static final ILoggerFactory loggerFactory = new GoodFactory(); + + public ILoggerFactory getLoggerFactory() { + return loggerFactory; + } + + public String getLoggerFactoryClassStr() { + return GoodFactory.class.getName(); + } + + + private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); + + public static final StaticLoggerBinder getSingleton() { + return SINGLETON; + } +}