From 3b64ce74082a1fbe6899a2ed4e9fd485f4d80a33 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Wed, 14 Mar 2012 11:57:06 +0000
Subject: [PATCH] remove static logs

---
 .../net/metanotion/io/block/BlockFile.java    |  2 +-
 .../metanotion/io/block/FreeListBlock.java    |  9 +-
 .../io/block/index/BSkipLevels.java           | 86 +++++++++----------
 .../metanotion/io/block/index/BSkipList.java  | 36 ++++----
 .../metanotion/io/block/index/BSkipSpan.java  | 34 ++++----
 .../metanotion/io/block/index/IBSkipSpan.java | 52 +++++------
 .../metanotion/util/skiplist/SkipLevels.java  | 34 ++++----
 7 files changed, 130 insertions(+), 123 deletions(-)

diff --git a/core/java/src/net/metanotion/io/block/BlockFile.java b/core/java/src/net/metanotion/io/block/BlockFile.java
index b8019e0a31..99af96b43a 100644
--- a/core/java/src/net/metanotion/io/block/BlockFile.java
+++ b/core/java/src/net/metanotion/io/block/BlockFile.java
@@ -69,7 +69,7 @@ import net.i2p.util.Log;
 public class BlockFile {
 	public static final int PAGESIZE = 1024;
 	public static final long OFFSET_MOUNTED = 20;
-	public static final Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
+	public final Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
 
 	public final RandomAccessInterface file;
 
diff --git a/core/java/src/net/metanotion/io/block/FreeListBlock.java b/core/java/src/net/metanotion/io/block/FreeListBlock.java
index 7c840adcd7..53435b2d4a 100644
--- a/core/java/src/net/metanotion/io/block/FreeListBlock.java
+++ b/core/java/src/net/metanotion/io/block/FreeListBlock.java
@@ -30,6 +30,9 @@ package net.metanotion.io.block;
 
 import java.io.IOException;
 
+import net.i2p.I2PAppContext;
+import net.i2p.util.Log;
+
 import net.metanotion.io.RandomAccessInterface;
 
 /**
@@ -80,7 +83,8 @@ class FreeListBlock {
 					branches[good++] = fpg;
 			}
 			if (good != len) {
-				BlockFile.log.error((len - good) + " bad pages in " + this);
+				Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
+				log.error((len - good) + " bad pages in " + this);
 				len = good;
 				writeBlock();
 			}
@@ -146,7 +150,8 @@ class FreeListBlock {
 		if (len >= MAX_SIZE)
 			throw new IllegalStateException("full");
 		if (getMagic(freePage) == MAGIC_FREE) {
-			BlockFile.log.error("Double free page " + freePage, new Exception());
+			Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
+			log.error("Double free page " + freePage, new Exception());
 			return;
 		}
 		branches[len++] = freePage;
diff --git a/core/java/src/net/metanotion/io/block/index/BSkipLevels.java b/core/java/src/net/metanotion/io/block/index/BSkipLevels.java
index 7442542679..ea0802df19 100644
--- a/core/java/src/net/metanotion/io/block/index/BSkipLevels.java
+++ b/core/java/src/net/metanotion/io/block/index/BSkipLevels.java
@@ -82,13 +82,13 @@ public class BSkipLevels extends SkipLevels {
 		bottom = bsl.spanHash.get(Integer.valueOf(spanPage));
 		if (bottom == null) {
 			// FIXME recover better?
-			BlockFile.log.error("No span found in cache???");
+			bf.log.error("No span found in cache???");
 			throw new IOException("No span found in cache???");
 		}
 
 		this.levels = new BSkipLevels[maxLen];
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Reading New BSkipLevels with " + nonNull + " / " + maxLen + " valid levels page " + levelPage);
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Reading New BSkipLevels with " + nonNull + " / " + maxLen + " valid levels page " + levelPage);
 		// We have to read now because new BSkipLevels() will move the file pointer
 		int[] lps = new int[nonNull];
 		for(int i = 0; i < nonNull; i++) {
@@ -108,7 +108,7 @@ public class BSkipLevels extends SkipLevels {
 						levels[i] = new BSkipLevels(bf, lp, bsl);
 						bsl.levelHash.put(Integer.valueOf(lp), levels[i]);
 					} catch (IOException ioe) {
-						BlockFile.log.error("Corrupt database, bad level " + i +
+						bf.log.error("Corrupt database, bad level " + i +
 						                    " at page " + lp, ioe);
 						levels[i] = null;
 						fail = true;
@@ -119,7 +119,7 @@ public class BSkipLevels extends SkipLevels {
 				Comparable nextKey = levels[i].key();
 				if (ourKey != null && nextKey != null &&
 				    ourKey.compareTo(nextKey) >= 0) {
-					BlockFile.log.warn("Corrupt database, level out of order " + this +
+					bf.log.warn("Corrupt database, level out of order " + this +
 					                    ' ' + print() +
 					                    " i = " + i + ' ' + levels[i]);
 					// This will be fixed in blvlfix() via BlockFile.getIndex()
@@ -128,8 +128,8 @@ public class BSkipLevels extends SkipLevels {
 				}
 				// TODO also check that the level[] array is not out-of-order
 			} else {
-				if (BlockFile.log.shouldLog(Log.WARN))
-					BlockFile.log.warn("WTF " + this + " i = " + i + " of " + nonNull + " / " + maxLen + " valid levels but page is zero");
+				if (bf.log.shouldLog(Log.WARN))
+					bf.log.warn("WTF " + this + " i = " + i + " of " + nonNull + " / " + maxLen + " valid levels but page is zero");
 				levels[i] = null;
 				fail = true;
 			}
@@ -137,7 +137,7 @@ public class BSkipLevels extends SkipLevels {
 		if (fail && bf.file.canWrite()) {
 			// corruption is actually fixed in blvlfix() via BlockFile.getIndex()
 			// after instantiation is complete
-			BlockFile.log.error("Repairing corruption of " + this +
+			bf.log.error("Repairing corruption of " + this +
 			                    ' ' + print());
 			flush();
 			// if the removed levels have no other links to them, they and their data
@@ -157,7 +157,7 @@ public class BSkipLevels extends SkipLevels {
 	@Override
 	public void flush() {
 		if (isKilled) {
-			BlockFile.log.error("Already killed!! " + this, new Exception());
+			bf.log.error("Already killed!! " + this, new Exception());
 			return;
 		}
 		try {
@@ -180,11 +180,11 @@ public class BSkipLevels extends SkipLevels {
 	@Override
 	public void killInstance() {
 		if (isKilled) {
-			BlockFile.log.error("Already killed!! " + this, new Exception());
+			bf.log.error("Already killed!! " + this, new Exception());
 			return;
 		}
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Killing " + this + ' ' + print(), new Exception());
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Killing " + this + ' ' + print(), new Exception());
 		isKilled = true;
 		bsl.levelHash.remove(Integer.valueOf(levelPage));
 		bf.freePage(levelPage);
@@ -197,8 +197,8 @@ public class BSkipLevels extends SkipLevels {
 			BSkipList bsl = (BSkipList) sl;
 			int page = bf.allocPage();
 			BSkipLevels.init(bf, page, bss.page, levels);
-			if (BlockFile.log.shouldLog(Log.DEBUG))
-				BlockFile.log.debug("New BSkipLevels height " + levels + " page " + page);
+			if (bf.log.shouldLog(Log.DEBUG))
+				bf.log.debug("New BSkipLevels height " + levels + " page " + page);
 			return new BSkipLevels(bf, page, bsl);
 		} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
 	}
@@ -228,13 +228,13 @@ public class BSkipLevels extends SkipLevels {
 	 */
 	private boolean blvlfix() {
 		TreeSet<SkipLevels> lvls = new TreeSet(new LevelComparator());
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Starting level search");
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Starting level search");
 		getAllLevels(this, lvls);
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Finished level search, found " + lvls.size() + " levels");
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Finished level search, found " + lvls.size() + " levels");
 		if (!this.equals(lvls.last())) {
-			BlockFile.log.error("First level is out of order! " + print());
+			bf.log.error("First level is out of order! " + print());
 			// TODO switch stack and other fields for the skiplist - hard to test
 		}
 		// traverse the levels, back-to-front
@@ -242,17 +242,17 @@ public class BSkipLevels extends SkipLevels {
 		SkipLevels after = null;
 		for (SkipLevels lv : lvls) {
 			boolean modified = false;
-			if (BlockFile.log.shouldLog(Log.DEBUG))
-				BlockFile.log.debug("Checking " + lv.print());
+			if (bf.log.shouldLog(Log.DEBUG))
+				bf.log.debug("Checking " + lv.print());
 			if (after != null) {
 				int min = Math.min(after.levels.length, lv.levels.length);
 				for (int i = 0; i < min; i++) {
 					SkipLevels cur = lv.levels[i];
 					if (cur != after) {
 						if (cur != null)
-							BlockFile.log.warn("Level " + i + " was wrong, fixing for " + lv.print());
+							bf.log.warn("Level " + i + " was wrong, fixing for " + lv.print());
 						else
-							BlockFile.log.warn("Level " + i + " was null, fixing for " + lv.print());
+							bf.log.warn("Level " + i + " was null, fixing for " + lv.print());
 						lv.levels[i] = after;
 						modified = true;
 					}
@@ -262,7 +262,7 @@ public class BSkipLevels extends SkipLevels {
 				for (int i = 0; i < lv.levels.length; i++) {
 					if (lv.levels[i] != null) {
 						lv.levels[i] = null;
-						BlockFile.log.warn("Last level " + i + " was non-null, fixing for " + lv.print());
+						bf.log.warn("Last level " + i + " was non-null, fixing for " + lv.print());
 						modified = true;
 					}
 				}
@@ -273,8 +273,8 @@ public class BSkipLevels extends SkipLevels {
 			}
 			after = lv;
 		}
-		if (BlockFile.log.shouldLog(Log.INFO))
-			BlockFile.log.info("Checked " + lvls.size() + " levels");
+		if (bf.log.shouldLog(Log.INFO))
+			bf.log.info("Checked " + lvls.size() + " levels");
 		return rv;
 	}
 
@@ -286,16 +286,16 @@ public class BSkipLevels extends SkipLevels {
 	 *  @since 0.8.8
 	 */
 	private void getAllLevels(SkipLevels l, Set lvlSet) {
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("GAL " + l.print());
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("GAL " + l.print());
 		// Do level 0 without recursion, on the assumption everything is findable
 		// from the root
 		SkipLevels cur = l;
 		while (cur != null && lvlSet.add(cur)) {
-			if (BlockFile.log.shouldLog(Log.DEBUG))
-				BlockFile.log.debug("Adding " + cur.print());
-			if (!cur.equals(this) && cur.key() == null && BlockFile.log.shouldLog(Log.WARN))
-				BlockFile.log.debug("Null KEY!!! " + cur.print());
+			if (bf.log.shouldLog(Log.DEBUG))
+				bf.log.debug("Adding " + cur.print());
+			if (!cur.equals(this) && cur.key() == null && bf.log.shouldLog(Log.WARN))
+				bf.log.debug("Null KEY!!! " + cur.print());
 			cur = cur.levels[0];
 		}
 		// If there were no nulls at level 0 in the middle,
@@ -333,23 +333,23 @@ public class BSkipLevels extends SkipLevels {
 	 */
 	@Override
 	public boolean blvlck(boolean fix, int width, SkipLevels[] prevLevels) {
-		BlockFile.log.warn("    Skip level at width " + width);
-		BlockFile.log.warn("        levels " + this.levels.length);
-		BlockFile.log.warn("        first key " + this.key());
-		BlockFile.log.warn("        spanPage " + this.spanPage);
-		BlockFile.log.warn("        levelPage " + this.levelPage);
+		bf.log.warn("    Skip level at width " + width);
+		bf.log.warn("        levels " + this.levels.length);
+		bf.log.warn("        first key " + this.key());
+		bf.log.warn("        spanPage " + this.spanPage);
+		bf.log.warn("        levelPage " + this.levelPage);
 		SkipLevels higher = null;
 		for (int i = levels.length - 1; i >= 0; i--) {
 			if (levels[i] != null) {
-				BlockFile.log.info("                level " + i + " -> " + levels[i].key() + " ");
+				bf.log.info("                level " + i + " -> " + levels[i].key() + " ");
 				if (higher != null) {
 					if (higher.key().compareTo(key()) < 0)
-						BlockFile.log.warn("                Higher level has lower key " + higher.key());
+						bf.log.warn("                Higher level has lower key " + higher.key());
 				}
 			} else {
-				BlockFile.log.info("                level " + i + " empty");
+				bf.log.info("                level " + i + " empty");
 				if (higher != null)
-					BlockFile.log.warn("                Higher level is not empty, key is " + higher.key());
+					bf.log.warn("                Higher level is not empty, key is " + higher.key());
 			}
 		}
 		if (prevLevels != null) {
@@ -359,13 +359,13 @@ public class BSkipLevels extends SkipLevels {
 					prevLevels[i] = levels[i];
 				} else if (prevLevels[i] != null) {
 					// skipping over us
-					BlockFile.log.warn("                Previous levels is non-null " + prevLevels[i].key() + " but not pointing to us at level " + i);
+					bf.log.warn("                Previous levels is non-null " + prevLevels[i].key() + " but not pointing to us at level " + i);
 					// replace so we only get one error
 					prevLevels[i] = levels[i];
 				} else {
 					// dead end in the middle
 					if (levels[i] != null) {
-						BlockFile.log.warn("                Previous levels is null but we are non-null " + levels[i].key() + " at level " + i);
+						bf.log.warn("                Previous levels is null but we are non-null " + levels[i].key() + " at level " + i);
 						// replace so we only get one error
 						prevLevels[i] = levels[i];
 					}
diff --git a/core/java/src/net/metanotion/io/block/index/BSkipList.java b/core/java/src/net/metanotion/io/block/index/BSkipList.java
index 18753e2b7e..5dd2e5fa2d 100644
--- a/core/java/src/net/metanotion/io/block/index/BSkipList.java
+++ b/core/java/src/net/metanotion/io/block/index/BSkipList.java
@@ -96,12 +96,12 @@ public class BSkipList extends SkipList {
 		for (BSkipSpan ss : spanHash.values()) {
 			total += ss.nKeys;
 		}
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Loaded " + this + " cached " + levelHash.size() + " levels and " + spanHash.size() + " spans with " + total + " entries");
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Loaded " + this + " cached " + levelHash.size() + " levels and " + spanHash.size() + " spans with " + total + " entries");
 		if (bf.file.canWrite() &&
 		    (levelCount != levelHash.size() || spans != spanHash.size() || size != total)) {
-			if (BlockFile.log.shouldLog(Log.WARN))
-				BlockFile.log.warn("On-disk counts were " + levelCount + " / " + spans + " / " +  size + ", correcting");
+			if (bf.log.shouldLog(Log.WARN))
+				bf.log.warn("On-disk counts were " + levelCount + " / " + spans + " / " +  size + ", correcting");
 			size = total;
 			flush();
 		}
@@ -121,7 +121,7 @@ public class BSkipList extends SkipList {
                 if (!bf.file.canWrite())
                     return;
 		if (isClosed) {
-			BlockFile.log.error("Already closed!! " + this, new Exception());
+			bf.log.error("Already closed!! " + this, new Exception());
 			return;
 		}
 		try {
@@ -139,7 +139,7 @@ public class BSkipList extends SkipList {
 	/** must be open (do not call close() first) */
 	public void delete() throws IOException {
 		if (isClosed) {
-			BlockFile.log.error("Already closed!! " + this, new Exception());
+			bf.log.error("Already closed!! " + this, new Exception());
 			return;
 		}
 		SkipLevels curLevel = stack;
@@ -229,16 +229,16 @@ public class BSkipList extends SkipList {
 	 *  @return true if the levels were modified.
 	 */
 	public boolean bslck(boolean fix, boolean isMeta) {
-		BlockFile.log.info("    size " + this.size);
-		BlockFile.log.info("    spans " + this.spanHash.size());
-		BlockFile.log.info("    levels " + this.levelHash.size());
-		BlockFile.log.info("    skipPage " + this.skipPage);
-		BlockFile.log.info("    firstSpanPage " + this.firstSpanPage);
-		BlockFile.log.info("    firstLevelPage " + this.firstLevelPage);
-		BlockFile.log.info("    maxLevels " + this.maxLevels());
+		bf.log.info("    size " + this.size);
+		bf.log.info("    spans " + this.spanHash.size());
+		bf.log.info("    levels " + this.levelHash.size());
+		bf.log.info("    skipPage " + this.skipPage);
+		bf.log.info("    firstSpanPage " + this.firstSpanPage);
+		bf.log.info("    firstLevelPage " + this.firstLevelPage);
+		bf.log.info("    maxLevels " + this.maxLevels());
 		//printSL();
 		//print();
-		//BlockFile.log.info("*** Lvlck() ***");
+		//bf.log.info("*** Lvlck() ***");
 		boolean rv = stack.blvlck(fix);
 	     /****
 		int items = 0;
@@ -246,16 +246,16 @@ public class BSkipList extends SkipList {
 			String key = (String) iter.nextKey();
 			if (isMeta) {
 				int sz = ((Integer) iter.next()).intValue();
-				BlockFile.log.info("        Item " + key.toString() + " page " + sz);
+				bf.log.info("        Item " + key.toString() + " page " + sz);
 			} else {
 				String cls= iter.next().getClass().getSimpleName();
-				BlockFile.log.info("        Item " + key.toString() + " class " + cls);
+				bf.log.info("        Item " + key.toString() + " class " + cls);
 			}
 			items++;
 		}
-		BlockFile.log.warn("    actual size " + items);
+		bf.log.warn("    actual size " + items);
 		if (items != this.size)
-			BlockFile.log.warn("****** size mismatch, header = " + this.size + " actual = " + items);
+			bf.log.warn("****** size mismatch, header = " + this.size + " actual = " + items);
               ****/
 		return rv;
 	}
diff --git a/core/java/src/net/metanotion/io/block/index/BSkipSpan.java b/core/java/src/net/metanotion/io/block/index/BSkipSpan.java
index 6fabb9e730..2ca5559b9b 100644
--- a/core/java/src/net/metanotion/io/block/index/BSkipSpan.java
+++ b/core/java/src/net/metanotion/io/block/index/BSkipSpan.java
@@ -100,18 +100,18 @@ public class BSkipSpan extends SkipSpan {
 	@Override
 	public void killInstance() {
 		if (isKilled) {
-			BlockFile.log.error("Already killed!! " + this, new Exception());
+			bf.log.error("Already killed!! " + this, new Exception());
 			return;
 		}
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Killing " + this);
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Killing " + this);
 		isKilled = true;
 		try {
 			int curPage = overflowPage;
 			bf.freePage(page);
 			freeContinuationPages(curPage);
 		} catch (IOException ioe) {
-			BlockFile.log.error("Error freeing " + this, ioe);
+			bf.log.error("Error freeing " + this, ioe);
 		}
 		bsl.spanHash.remove(Integer.valueOf(this.page));
 	}
@@ -146,7 +146,7 @@ public class BSkipSpan extends SkipSpan {
 	 */
 	private void fflush() {
 		if (isKilled) {
-			BlockFile.log.error("Already killed!! " + this, new Exception());
+			bf.log.error("Already killed!! " + this, new Exception());
 			return;
 		}
 		try {
@@ -163,7 +163,7 @@ public class BSkipSpan extends SkipSpan {
 			bf.file.writeShort((short) keys.length);
 			bf.file.writeShort((short) nKeys);
 			if (nKeys <= 0 && prev != null)
-				BlockFile.log.error("Flushing with no entries?" + this, new Exception());
+				bf.log.error("Flushing with no entries?" + this, new Exception());
 
 			int ksz, vsz;
 			int curPage = this.page;
@@ -193,7 +193,7 @@ public class BSkipSpan extends SkipSpan {
 				}
 				// Drop bad entry without throwing exception
 				if (keys[i] == null || vals[i] == null) {
-					BlockFile.log.error("Dropping null data in entry " + i + " page " + curPage +
+					bf.log.error("Dropping null data in entry " + i + " page " + curPage +
 					                    " key=" + this.keys[i] + " val=" + this.vals[i]);
 					nKeys--;
 					i--;
@@ -203,7 +203,7 @@ public class BSkipSpan extends SkipSpan {
 				valData = this.valSer.getBytes(vals[i]);
 				// Drop bad entry without throwing exception
 				if (keyData.length > 65535 || valData.length > 65535) {
-					BlockFile.log.error("Dropping huge data in entry " + i + " page " + curPage +
+					bf.log.error("Dropping huge data in entry " + i + " page " + curPage +
 					                    " keylen=" + keyData.length + " vallen=" + valData.length);
 					nKeys--;
 					i--;
@@ -227,10 +227,10 @@ public class BSkipSpan extends SkipSpan {
 					this.overflowPage = 0;
 				try {
 					int freed = freeContinuationPages(curNextPage[0]);
-					if (BlockFile.log.shouldLog(Log.DEBUG))
-						BlockFile.log.debug("Freed " + freed + " continuation pages");
+					if (bf.log.shouldLog(Log.DEBUG))
+						bf.log.debug("Freed " + freed + " continuation pages");
 				} catch (IOException ioe) {
-					BlockFile.log.error("Error freeing " + this, ioe);
+					bf.log.error("Error freeing " + this, ioe);
 				}
 			}
 		} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
@@ -268,7 +268,7 @@ public class BSkipSpan extends SkipSpan {
 		bss.spanSize = bf.file.readUnsignedShort();
 		bss.nKeys = bf.file.readUnsignedShort();
 		if(bss.spanSize < 1 || bss.spanSize > SkipSpan.MAX_SIZE || bss.nKeys > bss.spanSize) {
-			BlockFile.log.error("Invalid span size " + bss.nKeys + " / "+  bss.spanSize);
+			bf.log.error("Invalid span size " + bss.nKeys + " / "+  bss.spanSize);
 			bss.nKeys = 0;
 			bss.spanSize = bf.spanSize;
 		}
@@ -306,7 +306,7 @@ public class BSkipSpan extends SkipSpan {
 				BlockFile.pageSeek(this.bf.file, curNextPage[0]);
 				int magic = bf.file.readInt();
 				if (magic != BlockFile.MAGIC_CONT) {
-					BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Bad SkipSpan magic number 0x" + Integer.toHexString(magic) + " on page " + curNextPage[0]);
+					bf.log.error("Lost " + (this.nKeys - i) + " entries - Bad SkipSpan magic number 0x" + Integer.toHexString(magic) + " on page " + curNextPage[0]);
 					lostEntries(i, curPage);
 					break;
 				}
@@ -324,7 +324,7 @@ public class BSkipSpan extends SkipSpan {
 				curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
 				curPage = this.bf.readMultiPageData(v, curPage, pageCounter, curNextPage);
 			} catch (IOException ioe) {
-				BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
+				bf.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
 				lostEntries(i, lastGood);
 				break;
 			}
@@ -333,7 +333,7 @@ public class BSkipSpan extends SkipSpan {
 			this.vals[i] = this.valSer.construct(v);
 			// Drop bad entry without throwing exception
 			if (this.keys[i] == null || this.vals[i] == null) {
-				BlockFile.log.error("Null deserialized data in entry " + i + " page " + curPage +
+				bf.log.error("Null deserialized data in entry " + i + " page " + curPage +
 				                    " key=" + this.keys[i] + " val=" + this.vals[i]);
 				fail++;
 				nKeys--;
@@ -343,7 +343,7 @@ public class BSkipSpan extends SkipSpan {
 		}
 		// free any excess overflow pages?
 		if (fail > 0) {
-			BlockFile.log.error("Repairing corruption of " + fail + " entries");
+			bf.log.error("Repairing corruption of " + fail + " entries");
 			if (flushOnError)
 				fflush();
 			// FIXME can't get there from here
@@ -375,7 +375,7 @@ public class BSkipSpan extends SkipSpan {
 			}
 			bf.file.writeShort(this.nKeys);
 		} catch (IOException ioe) {
-			BlockFile.log.error("Error while recovering from corruption of " + this, ioe);
+			bf.log.error("Error while recovering from corruption of " + this, ioe);
 		}
 	}
 
diff --git a/core/java/src/net/metanotion/io/block/index/IBSkipSpan.java b/core/java/src/net/metanotion/io/block/index/IBSkipSpan.java
index 03ca4475e7..d5d33cf968 100644
--- a/core/java/src/net/metanotion/io/block/index/IBSkipSpan.java
+++ b/core/java/src/net/metanotion/io/block/index/IBSkipSpan.java
@@ -60,8 +60,8 @@ public class IBSkipSpan extends BSkipSpan {
 
 	@Override
 	public SkipSpan newInstance(SkipList sl) {
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Splitting page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Splitting page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
 		try {
 			int newPage = bf.allocPage();
 			init(bf, newPage, bf.spanSize);
@@ -86,11 +86,11 @@ public class IBSkipSpan extends BSkipSpan {
 				this.firstKey = keys[0];
 			this.keys = null;
 			this.vals = null;
-			if (BlockFile.log.shouldLog(Log.DEBUG))
-				BlockFile.log.debug("Flushed data for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
-		} else if (BlockFile.log.shouldLog(Log.DEBUG)) {
+			if (bf.log.shouldLog(Log.DEBUG))
+				bf.log.debug("Flushed data for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
+		} else if (bf.log.shouldLog(Log.DEBUG)) {
 			// if keys is null, we are (hopefully) just updating the prev/next pages on an unloaded span
-			BlockFile.log.debug("Flushed pointers for for unloaded page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
+			bf.log.debug("Flushed pointers for for unloaded page " + this.page + " containing " + this.nKeys + '/' + this.spanSize);
 		}
 	}
 
@@ -103,8 +103,8 @@ public class IBSkipSpan extends BSkipSpan {
 		super.loadData();
 		if (this.nKeys > 0)
 			this.firstKey = this.keys[0];
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Loaded data for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize + " first key: " + this.firstKey);
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Loaded data for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize + " first key: " + this.firstKey);
 	}
 
 	/**
@@ -127,11 +127,11 @@ public class IBSkipSpan extends BSkipSpan {
 		curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
 		this.firstKey = (Comparable) this.keySer.construct(k);
 		if (this.firstKey == null) {
-			BlockFile.log.error("Null deserialized first key in page " + curPage);
+			bf.log.error("Null deserialized first key in page " + curPage);
 			repair(1);
 		}
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Loaded header for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize + " first key: " + this.firstKey);
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Loaded header for page " + this.page + " containing " + this.nKeys + '/' + this.spanSize + " first key: " + this.firstKey);
 	}
 
 	/**
@@ -174,7 +174,7 @@ public class IBSkipSpan extends BSkipSpan {
 				BlockFile.pageSeek(this.bf.file, curNextPage[0]);
 				int magic = bf.file.readInt();
 				if (magic != BlockFile.MAGIC_CONT) {
-					BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Bad SkipSpan magic number 0x" + Integer.toHexString(magic) + " on page " + curNextPage[0]);
+					bf.log.error("Lost " + (this.nKeys - i) + " entries - Bad SkipSpan magic number 0x" + Integer.toHexString(magic) + " on page " + curNextPage[0]);
 					lostEntries(i, curPage);
 					break;
 				}
@@ -189,7 +189,7 @@ public class IBSkipSpan extends BSkipSpan {
 			try {
 				curPage = this.bf.readMultiPageData(k, curPage, pageCounter, curNextPage);
 			} catch (IOException ioe) {
-				BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
+				bf.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
 				lostEntries(i, curPage);
 				break;
 			}
@@ -198,7 +198,7 @@ public class IBSkipSpan extends BSkipSpan {
 			if (ckey == null) {
 				// skip the value and keep going
 				curPage = this.bf.skipMultiPageBytes(vsz, curPage, pageCounter, curNextPage);
-				BlockFile.log.error("Null deserialized key in entry " + i + " page " + curPage);
+				bf.log.error("Null deserialized key in entry " + i + " page " + curPage);
 				fail++;
 				continue;
 			}
@@ -209,13 +209,13 @@ public class IBSkipSpan extends BSkipSpan {
 				try {
 					curPage = this.bf.readMultiPageData(v, curPage, pageCounter, curNextPage);
 				} catch (IOException ioe) {
-					BlockFile.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
+					bf.log.error("Lost " + (this.nKeys - i) + " entries - Error loading " + this + " on page " + curPage, ioe);
 					lostEntries(i, curPage);
 					break;
 				}
 				Object rv = this.valSer.construct(v);
 				if (rv == null) {
-					BlockFile.log.error("Null deserialized value in entry " + i + " page " + curPage +
+					bf.log.error("Null deserialized value in entry " + i + " page " + curPage +
 					                    " key=" + ckey);
 					fail++;
 				}
@@ -245,9 +245,9 @@ public class IBSkipSpan extends BSkipSpan {
 			if (this.nKeys > 0)
 				this.firstKey = this.keys[0];
 			flush();
-			BlockFile.log.error("Repaired corruption of " + fail + " entries");
+			bf.log.error("Repaired corruption of " + fail + " entries");
 		} catch (IOException ioe) {
-			BlockFile.log.error("Failed to repair corruption of " + fail + " entries", ioe);
+			bf.log.error("Failed to repair corruption of " + fail + " entries", ioe);
 		}
 	*****/
 	}
@@ -258,8 +258,8 @@ public class IBSkipSpan extends BSkipSpan {
 
 	public IBSkipSpan(BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val) throws IOException {
 		super(bf, bsl);
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("New ibss page " + spanPage);
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("New ibss page " + spanPage);
 		BSkipSpan.loadInit(this, bf, bsl, spanPage, key, val);
 		loadFirstKey();
 		this.next = null;
@@ -287,7 +287,7 @@ public class IBSkipSpan extends BSkipSpan {
 			    previousFirstKey.compareTo(nextFirstKey) >= 0) {
 				// TODO remove, but if we are at the bottom of a level
 				// we have to remove the level too, which is a mess
-				BlockFile.log.error("Corrupt database, span out of order " + ((BSkipSpan)bss.prev).page +
+				bf.log.error("Corrupt database, span out of order " + ((BSkipSpan)bss.prev).page +
 				                    " first key " + previousFirstKey +
 				                    " next page " + bss.page +
 				                    " first key " + nextFirstKey);
@@ -317,7 +317,7 @@ public class IBSkipSpan extends BSkipSpan {
 			    previousFirstKey.compareTo(nextFirstKey) >= 0) {
 				// TODO remove, but if we are at the bottom of a level
 				// we have to remove the level too, which is a mess
-				BlockFile.log.error("Corrupt database, span out of order " + bss.page +
+				bf.log.error("Corrupt database, span out of order " + bss.page +
 				                    " first key " + previousFirstKey +
 				                    " next page " + ((BSkipSpan)bss.next).page +
 				                    " first key " + nextFirstKey);
@@ -386,16 +386,16 @@ public class IBSkipSpan extends BSkipSpan {
 	 */
 	@Override
 	public Object[] remove(Comparable key, SkipList sl) {
-		if (BlockFile.log.shouldLog(Log.DEBUG))
-			BlockFile.log.debug("Remove " + key + " in " + this);
+		if (bf.log.shouldLog(Log.DEBUG))
+			bf.log.debug("Remove " + key + " in " + this);
 		if (nKeys <= 0)
 			return null;
 		try {
 			seekAndLoadData();
 			if (this.nKeys == 1 && this.prev == null && this.next != null && this.next.keys == null) {
 				// fix for NPE in SkipSpan if next is not loaded
-				if (BlockFile.log.shouldLog(Log.INFO))
-					BlockFile.log.info("Loading next data for remove");
+				if (bf.log.shouldLog(Log.INFO))
+					bf.log.info("Loading next data for remove");
 				((IBSkipSpan)this.next).seekAndLoadData();
 			}
 		} catch (IOException ioe) {
diff --git a/core/java/src/net/metanotion/util/skiplist/SkipLevels.java b/core/java/src/net/metanotion/util/skiplist/SkipLevels.java
index 32360172ed..e4665fc4b3 100644
--- a/core/java/src/net/metanotion/util/skiplist/SkipLevels.java
+++ b/core/java/src/net/metanotion/util/skiplist/SkipLevels.java
@@ -30,6 +30,7 @@ package net.metanotion.util.skiplist;
 
 import net.metanotion.io.block.BlockFile;
 
+import net.i2p.I2PAppContext;
 import net.i2p.util.Log;
 
 public class SkipLevels {
@@ -45,6 +46,7 @@ public class SkipLevels {
 	public SkipLevels[] levels;
 	// bottom is final
 	public SkipSpan bottom;
+	private final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
 
 	public SkipLevels newInstance(int levels, SkipSpan ss, SkipList sl) { return new SkipLevels(levels, ss); }
 	public void killInstance() { }
@@ -158,13 +160,13 @@ public class SkipLevels {
 					SkipSpan ssres = (SkipSpan)res[1];
 					if (bottom.firstKey().equals(ssres.firstKey())) {
 						// bottom copied the next span to itself
-						if (BlockFile.log.shouldLog(Log.INFO)) {
-							BlockFile.log.info("First Level, bottom.remove() copied and did not return itself!!!! in remove " + key);
-							BlockFile.log.info("Us:     " + print());
-							BlockFile.log.info("next:   " + levels[0].print());
-							BlockFile.log.info("ssres.firstKey():   " + ssres.firstKey());
-							BlockFile.log.info("ssres.keys[0]:   " + ssres.keys[0]);
-							BlockFile.log.info("FIXUP TIME");
+						if (_log.shouldLog(Log.INFO)) {
+							_log.info("First Level, bottom.remove() copied and did not return itself!!!! in remove " + key);
+							_log.info("Us:     " + print());
+							_log.info("next:   " + levels[0].print());
+							_log.info("ssres.firstKey():   " + ssres.firstKey());
+							_log.info("ssres.keys[0]:   " + ssres.keys[0]);
+							_log.info("FIXUP TIME");
 						}
 						
 						SkipLevels replace = levels[0];
@@ -174,16 +176,16 @@ public class SkipLevels {
 							if (i >= replace.levels.length)
 								break;
 							if (levels[i].key().equals(replace.key())) {
-								if (BlockFile.log.shouldLog(Log.INFO))
-							        	BlockFile.log.info("equal level " + i);
+								if (_log.shouldLog(Log.INFO))
+							        	_log.info("equal level " + i);
 								levels[i] = replace.levels[i];
-							} else if (BlockFile.log.shouldLog(Log.INFO)) {
-								BlockFile.log.info("not equal level " + i + ' ' + levels[i].key());
+							} else if (_log.shouldLog(Log.INFO)) {
+								_log.info("not equal level " + i + ' ' + levels[i].key());
 							}
 						}
 						this.flush();
-						if (BlockFile.log.shouldLog(Log.INFO))
-							BlockFile.log.info("new Us: " + print());
+						if (_log.shouldLog(Log.INFO))
+							_log.info("new Us: " + print());
 						replace.killInstance();
 					}
 				}
@@ -193,11 +195,11 @@ public class SkipLevels {
 		if((bottom.nKeys == 0) && (sl.first != bottom)) {
 			// from debugging other problems
 			if (res == null) {
-				BlockFile.log.warn("WTF killing with no return value " + print());
+				_log.warn("WTF killing with no return value " + print());
 			} else if (res[1] == null) {
-				BlockFile.log.warn("WTF killing with no return value 1 " + print());
+				_log.warn("WTF killing with no return value 1 " + print());
 			} else if (res[1] != this) {
-				BlockFile.log.warn("WTF killing with return value not us " + res[1] + ' ' + print());
+				_log.warn("WTF killing with return value not us " + res[1] + ' ' + print());
 			}
 			this.killInstance();
 		}
-- 
GitLab