changeset 1222:cb422386f6b5

logging
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 25 Mar 2018 17:35:30 -0600
parents b99947af8b79
children c7adcdf79bf2
files src/luan/LuanState.java src/luan/modules/lucene/LuceneIndex.java
diffstat 2 files changed, 12 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
diff -r b99947af8b79 -r cb422386f6b5 src/luan/LuanState.java
--- a/src/luan/LuanState.java	Sun Mar 25 17:13:11 2018 -0600
+++ b/src/luan/LuanState.java	Sun Mar 25 17:35:30 2018 -0600
@@ -8,12 +8,16 @@
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import luan.impl.LuanCompiler;
 import luan.modules.BasicLuan;
 import luan.modules.JavaLuan;
 
 
 public final class LuanState implements LuanCloneable {
+	private static final Logger logger = LoggerFactory.getLogger(LuanState.class);
+
 	public LuanJavaOk javaOk;
 	private Map registry;
 	private final List<Reference<Closeable>> onClose = new ArrayList<Reference<Closeable>>();
@@ -46,11 +50,16 @@
 		onClose.add(new WeakReference<Closeable>(c));
 	}
 
-	public void close() throws IOException {
+	public void close() {
 		for( Reference<Closeable> ref : onClose ) {
 			Closeable c = ref.get();
-			if( c != null )
-				c.close();
+			if( c != null ) {
+				try {
+					c.close();
+				} catch(IOException e) {
+					logger.error(c.toString(),e);
+				}
+			}
 		}
 		onClose.clear();
 	}
diff -r b99947af8b79 -r cb422386f6b5 src/luan/modules/lucene/LuceneIndex.java
--- a/src/luan/modules/lucene/LuceneIndex.java	Sun Mar 25 17:13:11 2018 -0600
+++ b/src/luan/modules/lucene/LuceneIndex.java	Sun Mar 25 17:35:30 2018 -0600
@@ -71,7 +71,6 @@
 import luan.LuanTable;
 import luan.LuanFunction;
 import luan.LuanException;
-//import luan.LuanMeta;
 import luan.LuanRuntimeException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -460,41 +459,6 @@
 	}
 
 
-/*
-	public final LuanMeta indexedFieldsMeta = new LuanMeta() {
-
-		@Override public boolean canNewindex() {
-			return true;
-		}
-
-		@Override public Object __index(LuanState luan,LuanTable tbl,Object key) {
-			return mfp.fields.get(key);
-		}
-
-		@Override public void __new_index(LuanState luan,LuanTable tbl,Object key,Object value) throws LuanException {
-			if( !(key instanceof String) )
-				throw new LuanException("key must be string");
-			String field = (String)key;
-			if( value==null ) {  // delete
-				mfp.fields.remove(field);
-				return;
-			}
-			if( !(value instanceof FieldParser) )
-				throw new LuanException("value must be FieldParser like the values of Lucene.type");
-			FieldParser parser = (FieldParser)value;
-			mfp.fields.put( field, parser );
-		}
-
-		@Override public final Iterator keys(LuanTable tbl) {
-			return mfp.fields.keySet().iterator();
-		}
-
-		@Override protected String type(LuanTable tbl) {
-			return "lucene-indexed-fields";
-		}
-
-	};
-*/
 	public FieldParser getIndexedFieldParser(String field) {
 		return mfp.fields.get(field);
 	}