diff src/goodjava/logging/Log4jFactory.java @ 1402:27efb1fcbcb5

move luan.lib to goodjava
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 17 Sep 2019 01:35:01 -0400
parents src/luan/lib/logging/Log4jFactory.java@8b61c8c4e07a
children 6fc083e1d08c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/goodjava/logging/Log4jFactory.java	Tue Sep 17 01:35:01 2019 -0400
@@ -0,0 +1,52 @@
+package goodjava.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));
+	}
+}