Author: robert
Date: 2008-02-07 16:24:47 +0000 (Thu, 07 Feb 2008)
New Revision: 17664

Modified:
   trunk/freenet/src/freenet/node/NetworkIDManager.java
   trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java
Log:
logging


Modified: trunk/freenet/src/freenet/node/NetworkIDManager.java
===================================================================
--- trunk/freenet/src/freenet/node/NetworkIDManager.java        2008-02-07 
16:04:24 UTC (rev 17663)
+++ trunk/freenet/src/freenet/node/NetworkIDManager.java        2008-02-07 
16:24:47 UTC (rev 17664)
@@ -45,7 +45,7 @@
                long uid = m.getLong(DMT.UID);
                long secret = m.getLong(DMT.SECRET);
                StoredSecret s=new StoredSecret(pn, uid, secret);
-               Logger.error(this, "Storing secret: "+s);
+               if (logMINOR) Logger.minor(this, "Storing secret: "+s);
                addOrReplaceSecret(s);
                try {
                        pn.sendAsync(DMT.createFNPAccepted(uid), null, 0, null);
@@ -78,7 +78,7 @@
        private boolean _handleSecretPing(Message m, PeerNode source, long uid, 
short htl, short dawnHtl, int counter) throws NotConnectedException {

                if (disableSecretPings || node.recentlyCompleted(uid)) {
-                       Logger.normal(this, "recently complete/loop: "+uid);
+                       if (logMINOR) Logger.minor(this, "recently 
complete/loop: "+uid);
                        source.sendAsync(DMT.createFNPRejectedLoop(uid), null, 
0, null);
                } else {
                        StoredSecret match;
@@ -92,7 +92,7 @@
                                if (htl > dawnHtl) {
                                        
source.sendAsync(DMT.createFNPRejectedLoop(uid), null, 0, null);
                                } else {
-                                       Logger.error(this, "Responding to 
"+source+" with "+match+" from "+match.peer);
+                                       if (logMINOR) Logger.minor(this, 
"Responding to "+source+" with "+match+" from "+match.peer);
                                        
source.sendAsync(match.getSecretPong(counter+1), null, 0, null);
                                }
                        } else {
@@ -162,7 +162,7 @@
                                                if (suppliedCounter>counter)
                                                        counter=suppliedCounter;
                                                long 
secret=msg.getLong(DMT.SECRET);
-                                               Logger.error(this, node+" 
forwarding apparently-successful secretpong response: "+counter+"/"+secret+" 
from "+next+" to "+source);
+                                               if (logMINOR) 
Logger.minor(this, node+" forwarding apparently-successful secretpong response: 
"+counter+"/"+secret+" from "+next+" to "+source);
                                                
source.sendAsync(DMT.createFNPSecretPong(uid, counter, secret), null, 0, null);
                                                break;
                                        }
@@ -187,7 +187,7 @@
                        StoredSecret s=(StoredSecret)secretsByPeer.get(pn);
                        if (s!=null) {
                                //???: Might it still be valid to respond to 
secret pings when the neighbor requesting it has disconnected? (super-secret 
ping?)
-                               Logger.error(this, "Removing on disconnect: 
"+s);
+                               Logger.normal(this, "Removing on disconnect: 
"+s);
                                removeSecret(s);
                        }
                }

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java        
2008-02-07 16:04:24 UTC (rev 17663)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java        
2008-02-07 16:24:47 UTC (rev 17664)
@@ -55,7 +55,7 @@
         new File(wd).mkdir();
         //NOTE: globalTestInit returns in ignored random source
         NodeStarter.globalTestInit(wd);
-               Logger.setupStdoutLogging(Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeSecretPingTest:normal,freenet.node.NetworkIDManager:debug");
+               Logger.setupStdoutLogging(Logger.ERROR, 
"freenet.node.Location:normal,freenet.node.simulator.RealNodeSecretPingTest:normal,freenet.node.NetworkIDManager:normal");
                Logger.globalSetThreshold(Logger.ERROR);

         DummyRandomSource random = new DummyRandomSource();
@@ -100,7 +100,7 @@
                        PeerNode verify = source.peers.getRandomPeer();
                        PeerNode pathway = source.peers.getRandomPeer(verify);

-                       Logger.error(source, "verify ("+verify+") through: 
"+pathway+"; so far "+avg2.currentValue());
+                       Logger.error(source, "verify 
("+getPortNumber(verify)+") through: "+getPortNumber(pathway)+"; so far 
"+avg2.currentValue());

                        long uid=random.nextLong();
                        long secret=random.nextLong();
@@ -170,7 +170,7 @@
                Message msg = source.getUSM().waitFor(mfPong.or(mfRejectLoop), 
null);

                if (msg==null) {
-                       Logger.error(source, "fatal timeout in waiting for 
secretpong from "+pathway);
+                       Logger.error(source, "fatal timeout in waiting for 
secretpong from "+getPortNumber(pathway));
                        return -2;
                }

@@ -182,7 +182,7 @@
                }

                if (msg.getSpec() == DMT.FNPRejectedLoop) {
-                       Logger.error(source, "top level secret ping should not 
reject!: "+source+" -> "+pathway);
+                       Logger.error(source, "top level secret ping should not 
reject!: "+getPortNumber(source)+" -> "+getPortNumber(pathway));
                        return -1;
                }

@@ -232,4 +232,17 @@
                double bL=b.getLocation();
                return Location.distance(aL, bL);
        }
+       
+       static String getPortNumber(PeerNode p) {
+               if (p == null || p.getPeer() == null)
+                       return "null";
+               return Integer.toString(p.getPeer().getPort());
+       }
+       
+       static String getPortNumber(Node n) {
+               if (n == null)
+                       return "null";
+               return Integer.toString(n.getDarknetPortNumber());
+       }
+       
 }


Reply via email to