r26769 - trunk/freenet/src/freenet/node/fcp

[email protected]
Newsgroups gmane.network.freenet.cvs
Message-ID <[email protected]>
Author: j16sdiz
Date: 2009-04-14 04:43:11 +0000 (Tue, 14 Apr 2009)
New Revision: 26769

Modified:
   trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
Log:
Logging (FCPConnectionInputHandler.java)

Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java	2009-04-14 04:42:50 UTC (rev 26768)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java	2009-04-14 04:43:11 UTC (rev 26769)
@@ -11,6 +11,7 @@
 
 import com.db4o.ObjectContainer;
 
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
 import freenet.support.OOMHandler;
 import freenet.support.SimpleFieldSet;
@@ -19,7 +20,19 @@
 import freenet.support.io.TooLongException;
 
 public class FCPConnectionInputHandler implements Runnable {
-
+	private static volatile boolean logMINOR;
+	private static volatile boolean logDEBUG;
+	
+	static {
+		Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+			@Override
+			public void shouldUpdate() {
+				logMINOR = Logger.shouldLog(Logger.MINOR, this);
+				logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
+			}
+		});
+	}
+	
 	final FCPConnectionHandler handler;
 	
 	FCPConnectionInputHandler(FCPConnectionHandler handler) {
@@ -37,7 +50,7 @@
 		} catch (TooLongException e) {
 			Logger.normal(this, "Caught"+e.getMessage(),e);
 		} catch (IOException e) {
-			if(Logger.shouldLog(Logger.MINOR, this))
+			if(logMINOR)
 				Logger.minor(this, "Caught "+e, e);
 		} catch (OutOfMemoryError e) {
 			OOMHandler.handleOOM(e);
@@ -82,7 +95,7 @@
 			
 			FCPMessage msg;
 			try {
-				if(Logger.shouldLog(Logger.DEBUG, this))
+				if(logDEBUG)
 					Logger.debug(this, "Incoming FCP message:\n"+messageType+'\n'+fs.toString());
 				msg = FCPMessage.create(messageType, fs, handler.bf, handler.server.core.persistentTempBucketFactory);
 				if(msg == null) continue;
@@ -122,7 +135,7 @@
 				continue;
 			}
 			try {
-				if(Logger.shouldLog(Logger.DEBUG, this))
+				if(logDEBUG)
 					Logger.debug(this, "Parsed message: "+msg+" for "+handler);
 				msg.run(handler, handler.server.node);
 			} catch (MessageInvalidException e) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.