eliminate logging in Connection class
authoradam <adam@megacz.com>
Thu, 5 Jul 2007 01:50:40 +0000 (01:50 +0000)
committeradam <adam@megacz.com>
Thu, 5 Jul 2007 01:50:40 +0000 (01:50 +0000)
darcs-hash:20070705015040-5007d-ac2c4d05eaf337ec58eefabdcbf1b572c1a99b02.gz

src/org/ibex/io/Stream.java

index 1d03c20..04aef23 100644 (file)
@@ -15,7 +15,6 @@ public class Stream {
 
     protected final In in;
     protected final Out out;
-    private         StringBuffer log = loggingEnabled ? new StringBuffer(16 * 1024) : null;
     private         String newLine = "\r\n";
     private         Stream in_next = null;
 
@@ -28,9 +27,6 @@ public class Stream {
         return this;
     }
 
-    //public static boolean loggingEnabled = "true".equals(System.getProperty("ibex.io.stream.logEnabled", "false"));
-    public static boolean loggingEnabled = true;
-
     public void transcribe(Stream out) { transcribe(out, false); }
     public void transcribe(Stream out, boolean close) {
         try {
@@ -96,25 +92,19 @@ public class Stream {
     public char   getc()                           {
         flush();
         char ret = in.getc(false);
-        log(ret);
         return ret;
     }   
     public String readln()                         {
         flush();
         String s = in.readln();
-        log(s);
-        log('\n');
         return s;
     }
     
     public void   print(String s) {
-        logWrite(s);
         out.write(s);
         flush();
     }
     public void   println(String s) {
-        logWrite(s);
-        logWrite(newLine);
         out.write(s);
         out.write(newLine);
         flush();
@@ -125,14 +115,12 @@ public class Stream {
     public int    read(byte[] b, int off, int len) {
         flush();
         int ret = in.readBytes(b, off, len);
-        if (log != null) log("\n[read " + ret + " bytes of binary data ]\n");
         nnl = false;
         return ret;
     }
     public int    read(char[] c, int off, int len) {
         flush();
         int ret = in.read(c, off, len);
-        if (log != null && ret != -1) log(new String(c, off, ret));
         return ret;
     }
 
@@ -144,10 +132,6 @@ public class Stream {
 
 
     /** dumps the connection log into a file */
-    public  String dumpLog()         { if (log==null) return ""; String ret = log.toString(); log = new StringBuffer(16 * 1024); return ret; }
-    private void  log(String s)      { if(log==null) return; if (!nnl) Log.note("\n[read ] "); Log.note(s + "\n"); nnl=false; if (log != null) log.append(s); }
-    private void  logWrite(String s) { if(log==null) return; if (nnl) Log.note("\n"); Log.note("[write] "+s+"\n"); nnl=false; if (log != null) log.append(s); }
-    private void  log(char c)        { if(log==null) return; if (c == '\r') return; if (!nnl) Log.note("[read ] "); Log.note(c+""); nnl = c != '\n'; if (log != null) log.append(c); }
     private boolean nnl = false;
 
     private static class Out extends BufferedOutputStream {
@@ -295,8 +279,4 @@ public class Stream {
        }
     }
 
-    public static interface Transformer {
-        public Stream transform(Stream in);
-    }
-
 }