chiark / gitweb /
debug output option
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Sep 2010 11:47:11 +0000 (12:47 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Sep 2010 11:47:11 +0000 (12:47 +0100)
src/com/tedpearson/ypp/market/ControlPanel.java
src/com/tedpearson/ypp/market/MarketUploader.java

index 0f15704..bbd75f6 100644 (file)
@@ -35,13 +35,16 @@ public class ControlPanel extends JFrame {
                    com.tedpearson.ypp.market.Version.version;
                JLabel version = new JLabel(version_label);
 
-               setLayout(new GridLayout(7,1));
+               final JCheckBox enableDebug = new JCheckBox("Write debug files?", prefs.getBoolean("writeDebugFiles", false));
+
+               setLayout(new GridLayout(8,1));
                add(toPCTB);
                add(toYarrg);
                add(showArbitrage);
                add(live);
                add(testing);
                add(version);
+               add(enableDebug);
 
                final int exitstatus = Integer.parseInt(System.getProperty("com.tedpearson.ypp.market.controlpanel.exitstatus", "0"));
 
@@ -53,6 +56,7 @@ public class ControlPanel extends JFrame {
                                prefs.putBoolean("uploadToYarrg", toYarrg.isSelected());
                                prefs.putBoolean("showArbitrage", showArbitrage.isSelected());
                                prefs.putBoolean("useLiveServers", live.isSelected());
+                               prefs.putBoolean("writeDebugFiles", enableDebug.isSelected());
                                System.exit(exitstatus);
                        }
                });
index 2466b44..a7a90c8 100644 (file)
@@ -65,6 +65,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
 
        private AccessibleContext sidePanel;
        private HashMap<String,Integer> commodMap;
+        public PrintStream dtxt = null;
 
        private PropertyChangeListener changeListener = new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent e) {
@@ -236,6 +237,14 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                // check if we've been turned off in the control panel
                Preferences prefs = Preferences.userNodeForPackage(getClass());
 
+               if (prefs.getBoolean("writeDebugFiles", false)) {
+                   try {
+                       dtxt = new PrintStream(new File("jarrg-debug-log.txt"));
+                   } catch (java.io.FileNotFoundException e) {
+                       System.err.println("JARRG: Error opening debug log: "+e);
+                   }
+               }
+
                if (prefs.getBoolean("useLiveServers", false)) {
                        YARRG_URL = YARRG_LIVE_URL;
                        PCTB_HOST_URL = PCTB_LIVE_HOST_URL;
@@ -705,6 +714,13 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                        int first = sb.indexOf("<pre>") + 5;
                        int last = sb.indexOf("</body>");
                        xml = sb.substring(first,last);
+                       //if (dtxt!=null) {
+                       //        dtxt.println(">>");
+                       //        dtxt.println(sb);;
+                       //        dtxt.println("||");
+                       //        dtxt.println(xml);
+                       //        dtxt.println("<<");
+                       //}
                        //System.out.println(xml);
                        Reader reader = new CharArrayReader(xml.toCharArray());
                        Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(reader));