Author: j16sdiz
Date: 2009-01-05 12:03:39 +0000 (Mon, 05 Jan 2009)
New Revision: 24912

Modified:
   trunk/plugins/XMLSpider/IndexWriter.java
   trunk/plugins/XMLSpider/db/Config.java
   trunk/plugins/XMLSpider/web/ConfigPage.java
Log:
make debug info configable

Modified: trunk/plugins/XMLSpider/IndexWriter.java
===================================================================
--- trunk/plugins/XMLSpider/IndexWriter.java    2009-01-05 12:03:27 UTC (rev 
24911)
+++ trunk/plugins/XMLSpider/IndexWriter.java    2009-01-05 12:03:39 UTC (rev 
24912)
@@ -50,7 +50,6 @@
        private int match;
        private long time_taken;
        private boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
-       private boolean DEBUG = true;
 
        IndexWriter() {
        }
@@ -273,8 +272,10 @@
                        Document xmlDoc = impl.createDocument(null, 
"sub_index", null);
                        
                        Element rootElement = xmlDoc.getDocumentElement();
-                       if (DEBUG)
+                       if (config.isDebug()) {
+                               
xmlDoc.createAttributeNS("urn:freenet:xmlspider:debug", "debug");
                                
rootElement.appendChild(xmlDoc.createComment(new Date().toGMTString()));
+                       }
                        
                        /* Adding header to the index */
                        Element headerElement = xmlDoc.createElement("header");
@@ -294,8 +295,8 @@
                        for (Term term : termIterator) {
                                Element wordElement = 
xmlDoc.createElement("word");
                                wordElement.setAttribute("v", term.getWord());
-                               if (DEBUG)
-                                       wordElement.setAttribute("debugMd5", 
term.getMD5());
+                               if (config.isDebug())
+                                       wordElement.setAttribute("debug:md5", 
term.getMD5());
                                count++;
                                estimateSize += 12;
                                estimateSize += term.getWord().length();

Modified: trunk/plugins/XMLSpider/db/Config.java
===================================================================
--- trunk/plugins/XMLSpider/db/Config.java      2009-01-05 12:03:27 UTC (rev 
24911)
+++ trunk/plugins/XMLSpider/db/Config.java      2009-01-05 12:03:39 UTC (rev 
24912)
@@ -23,6 +23,8 @@
        private int maxParallelRequests;
        private String[] badlistedExtensions;
        private short requestPriority;
+       
+       private boolean debug;
 
        public Config() {
        }
@@ -174,4 +176,13 @@
        public synchronized short getRequestPriority() {
                return requestPriority;
        }
+       
+       public synchronized boolean isDebug() {
+               return debug;
+       }
+
+       public synchronized void debug(boolean debug) {
+               assert !isPersistent();
+               this.debug = debug;
+       }
 }
\ No newline at end of file

Modified: trunk/plugins/XMLSpider/web/ConfigPage.java
===================================================================
--- trunk/plugins/XMLSpider/web/ConfigPage.java 2009-01-05 12:03:27 UTC (rev 
24911)
+++ trunk/plugins/XMLSpider/web/ConfigPage.java 2009-01-05 12:03:39 UTC (rev 
24912)
@@ -81,6 +81,11 @@
                addConfig(indexConfig, //
                        "Index Owner Email", "Index Owner Email", // 
                        "indexOwnerEmail", config.getIndexOwnerEmail());
+               addConfig(indexConfig, //
+                       "Write debug info", "Write debug info", // 
+                       "debug", //
+                       new String[] { "false", "true" }, //
+                       Boolean.toString(config.isDebug()));
                
                configForm.addChild("input", //
                        new String[] { "type", "value" }, //

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to