changeset 1337:8b61c8c4e07a

remove slf4j
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 15 Feb 2019 07:14:50 -0700
parents 7483108154bb
children 5d414f5d34e8
files lib/slf4j-api-1.6.4.jar lib/slf4j-log4j12-1.6.4.jar src/luan/Luan.java src/luan/host/Backup.java src/luan/host/WebHandler.java src/luan/lib/logging/Log4jFactory.java src/luan/lib/logging/Logger.java src/luan/lib/logging/LoggerFactory.java src/luan/modules/http/LuanHandler.java src/luan/modules/logging/LuanLogger.java src/luan/modules/lucene/LuceneIndex.java src/luan/modules/sql/Database.java src/luan/webserver/Connection.java src/luan/webserver/RequestParser.java src/luan/webserver/Server.java src/luan/webserver/Status.java src/luan/webserver/handlers/DomainHandler.java src/luan/webserver/handlers/LogHandler.java src/luan/webserver/handlers/SafeHandler.java
diffstat 19 files changed, 110 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
Binary file lib/slf4j-api-1.6.4.jar has changed
Binary file lib/slf4j-log4j12-1.6.4.jar has changed
--- a/src/luan/Luan.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/Luan.java	Fri Feb 15 07:14:50 2019 -0700
@@ -10,8 +10,8 @@
 import java.util.Iterator;
 import java.util.Arrays;
 import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.modules.BasicLuan;
 import luan.modules.JavaLuan;
 import luan.modules.PackageLuan;
--- a/src/luan/host/Backup.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/host/Backup.java	Fri Feb 15 07:14:50 2019 -0700
@@ -7,8 +7,8 @@
 import java.util.Map;
 import java.util.List;
 import java.util.ArrayList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import org.apache.lucene.index.SnapshotDeletionPolicy;
 import org.apache.lucene.index.IndexCommit;
 import org.apache.lucene.store.FSDirectory;
--- a/src/luan/host/WebHandler.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/host/WebHandler.java	Fri Feb 15 07:14:50 2019 -0700
@@ -1,8 +1,8 @@
 package luan.host;
 
 import java.io.File;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.webserver.Handler;
 import luan.webserver.Request;
 import luan.webserver.Response;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/luan/lib/logging/Log4jFactory.java	Fri Feb 15 07:14:50 2019 -0700
@@ -0,0 +1,52 @@
+package luan.lib.logging;
+
+
+public final class Log4jFactory extends LoggerFactory {
+	private static final class Log4jLogger implements Logger {
+		final org.apache.log4j.Logger log4j;
+
+		Log4jLogger(org.apache.log4j.Logger log4j) {
+			this.log4j = log4j;
+		}
+
+		@Override public void error(String msg) {
+			log4j.error(msg);
+		}
+
+		@Override public void error(String msg,Throwable t) {
+			log4j.error(msg,t);
+		}
+
+		@Override public void warn(String msg) {
+			log4j.warn(msg);
+		}
+
+		@Override public void warn(String msg,Throwable t) {
+			log4j.warn(msg,t);
+		}
+
+		@Override public void info(String msg) {
+			log4j.info(msg);
+		}
+
+		@Override public void info(String msg,Throwable t) {
+			log4j.info(msg,t);
+		}
+
+		@Override public void debug(String msg) {
+			log4j.debug(msg);
+		}
+
+		@Override public void debug(String msg,Throwable t) {
+			log4j.debug(msg,t);
+		}
+	}
+
+	@Override protected Logger getLoggerImpl(Class cls) {
+		return new Log4jLogger(org.apache.log4j.Logger.getLogger(cls));
+	}
+
+	@Override protected Logger getLoggerImpl(String name) {
+		return new Log4jLogger(org.apache.log4j.Logger.getLogger(name));
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/luan/lib/logging/Logger.java	Fri Feb 15 07:14:50 2019 -0700
@@ -0,0 +1,14 @@
+package luan.lib.logging;
+
+// Because slf4j is an overcomplicated piece of shit that caches loggers when it shouldn't.
+
+public interface Logger {
+	public void error(String msg);
+	public void error(String msg,Throwable t);
+	public void warn(String msg);
+	public void warn(String msg,Throwable t);
+	public void info(String msg);
+	public void info(String msg,Throwable t);
+	public void debug(String msg);
+	public void debug(String msg,Throwable t);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/luan/lib/logging/LoggerFactory.java	Fri Feb 15 07:14:50 2019 -0700
@@ -0,0 +1,17 @@
+package luan.lib.logging;
+
+
+public abstract class LoggerFactory {
+	public static LoggerFactory impl = new Log4jFactory();
+
+	protected abstract Logger getLoggerImpl(Class cls);
+	protected abstract Logger getLoggerImpl(String name);
+
+	public static Logger getLogger(Class cls) {
+		return impl.getLoggerImpl(cls);
+	}
+
+	public static Logger getLogger(String name) {
+		return impl.getLoggerImpl(name);
+	}
+}
--- a/src/luan/modules/http/LuanHandler.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/modules/http/LuanHandler.java	Fri Feb 15 07:14:50 2019 -0700
@@ -12,7 +12,7 @@
 import java.util.ArrayList;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.slf4j.Logger;
+import luan.lib.logging.Logger;
 import luan.webserver.Request;
 import luan.webserver.Response;
 import luan.webserver.Status;
--- a/src/luan/modules/logging/LuanLogger.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/modules/logging/LuanLogger.java	Fri Feb 15 07:14:50 2019 -0700
@@ -1,7 +1,7 @@
 package luan.modules.logging;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.Luan;
 import luan.LuanException;
 
--- a/src/luan/modules/lucene/LuceneIndex.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/modules/lucene/LuceneIndex.java	Fri Feb 15 07:14:50 2019 -0700
@@ -74,8 +74,8 @@
 import luan.LuanCloner;
 import luan.LuanException;
 import luan.LuanRuntimeException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 
 
 public final class LuceneIndex implements Closeable {
--- a/src/luan/modules/sql/Database.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/modules/sql/Database.java	Fri Feb 15 07:14:50 2019 -0700
@@ -9,8 +9,8 @@
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Properties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.LuanTable;
 import luan.LuanException;
 
--- a/src/luan/webserver/Connection.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/webserver/Connection.java	Fri Feb 15 07:14:50 2019 -0700
@@ -4,8 +4,8 @@
 import java.io.OutputStream;
 import java.io.IOException;
 import java.net.Socket;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.lib.parser.ParseException;
 
 
--- a/src/luan/webserver/RequestParser.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/webserver/RequestParser.java	Fri Feb 15 07:14:50 2019 -0700
@@ -4,8 +4,8 @@
 import java.net.URLDecoder;
 import java.util.List;
 import java.util.ArrayList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.lib.parser.Parser;
 import luan.lib.parser.ParseException;
 
--- a/src/luan/webserver/Server.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/webserver/Server.java	Fri Feb 15 07:14:50 2019 -0700
@@ -8,8 +8,8 @@
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 
 
 public class Server {
--- a/src/luan/webserver/Status.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/webserver/Status.java	Fri Feb 15 07:14:50 2019 -0700
@@ -2,8 +2,8 @@
 
 import java.util.Map;
 import java.util.HashMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 
 
 public class Status {
--- a/src/luan/webserver/handlers/DomainHandler.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/webserver/handlers/DomainHandler.java	Fri Feb 15 07:14:50 2019 -0700
@@ -7,8 +7,8 @@
 import java.lang.ref.ReferenceQueue;
 import java.util.Map;
 import java.util.HashMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.webserver.Handler;
 import luan.webserver.Request;
 import luan.webserver.Response;
--- a/src/luan/webserver/handlers/LogHandler.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/webserver/handlers/LogHandler.java	Fri Feb 15 07:14:50 2019 -0700
@@ -1,7 +1,7 @@
 package luan.webserver.handlers;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.webserver.Handler;
 import luan.webserver.Request;
 import luan.webserver.Response;
--- a/src/luan/webserver/handlers/SafeHandler.java	Thu Feb 14 05:22:22 2019 -0700
+++ b/src/luan/webserver/handlers/SafeHandler.java	Fri Feb 15 07:14:50 2019 -0700
@@ -4,8 +4,8 @@
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import luan.lib.logging.Logger;
+import luan.lib.logging.LoggerFactory;
 import luan.webserver.Handler;
 import luan.webserver.Request;
 import luan.webserver.Response;