changeset 376:0a75ed73bccc

partly revert rev 538c19ad1272 (logging)
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 18 Apr 2015 19:57:42 -0600
parents e2e70d27c258
children a8d03e6882c6
files logging/src/luan/modules/logging/Logging.luan logging/src/luan/modules/logging/LuanLogger.java
diffstat 2 files changed, 40 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/logging/src/luan/modules/logging/Logging.luan	Fri Apr 17 18:34:02 2015 -0600
+++ b/logging/src/luan/modules/logging/Logging.luan	Sat Apr 18 19:57:42 2015 -0600
@@ -4,6 +4,7 @@
 local ConsoleAppender = require "java:org.apache.log4j.ConsoleAppender"
 local Level = require "java:org.apache.log4j.Level"
 local RollingFileAppender = require "java:org.apache.log4j.RollingFileAppender"
+local LuanLogger = require "java:luan.modules.logging.LuanLogger"
 
 
 layout = "%d %-5p %c - %m%n"
@@ -56,10 +57,11 @@
 local function to_luan_logger(log4j_logger)
 	local tbl = {}
 
-	tbl.error = log4j_logger.error
-	tbl.warn = log4j_logger.warn
-	tbl.info = log4j_logger.info
-	tbl.debug = log4j_logger.debug
+	local luanLogger = LuanLogger.new(log4j_logger)
+	tbl.error = luanLogger.error
+	tbl.warn = luanLogger.warn
+	tbl.info = luanLogger.info
+	tbl.debug = luanLogger.debug
 
 	function tbl.get_level()
 		local level = log4j_logger.getLevel()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/logging/src/luan/modules/logging/LuanLogger.java	Sat Apr 18 19:57:42 2015 -0600
@@ -0,0 +1,34 @@
+package luan.modules.logging;
+
+import org.apache.log4j.Logger;
+import luan.Luan;
+import luan.LuanState;
+import luan.LuanException;
+import luan.LuanTable;
+import luan.LuanJavaFunction;
+
+
+public final class LuanLogger {
+	private final Logger logger;
+
+	public LuanLogger(Logger logger) {
+		this.logger = logger;
+	}
+
+	public void error(LuanState luan,Object obj) throws LuanException {
+		logger.error( luan.toString(obj) );
+	}
+
+	public void warn(LuanState luan,Object obj) throws LuanException {
+		logger.warn( luan.toString(obj) );
+	}
+
+	public void info(LuanState luan,Object obj) throws LuanException {
+		logger.info( luan.toString(obj) );
+	}
+
+	public void debug(LuanState luan,Object obj) throws LuanException {
+		logger.debug( luan.toString(obj) );
+	}
+
+}