[Webfunds-commits] java/webfunds/utils Debug.java Diagnostics.java VersionNumbers.java

Ian Grigg iang@cypherpunks.ai
Thu, 12 Apr 2001 00:43:29 -0400 (AST)


iang        01/04/12 00:43:29

  Modified:    webfunds/utils Debug.java Diagnostics.java
                        VersionNumbers.java
  Log:
  now use util.Log where possible, but maintaining compatibility with old

Revision  Changes    Path
1.11      +10 -4     java/webfunds/utils/Debug.java

Index: Debug.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/utils/Debug.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Debug.java	2000/04/25 02:18:11	1.10
+++ Debug.java	2001/04/12 04:43:28	1.11
@@ -1,5 +1,5 @@
 /*
- * $Id: Debug.java,v 1.10 2000/04/25 02:18:11 iang Exp $
+ * $Id: Debug.java,v 1.11 2001/04/12 04:43:28 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -9,6 +9,9 @@
 
 import java.io.*;
 
+//migration class
+import webfunds.util.Log;
+
 /**
  *  Extend this to add the logmsg() method.
  */
@@ -27,7 +30,7 @@
      * @param pw The PrintWriter stream to send debugging information to.
      * A null value disables debugging.
      */     
-    public void debug()            { bug = new PrintWriter(System.err, true); }
+    public void debug()                         { bug = new Log(); }
     public void debug(PrintWriter pw)   { bug = pw; } // new PrintWriter(pw, true); }
     public void debug(PrintWriter pw, String s) { logfix = s; debug(pw); }
     public void debug(String s)                 { logfix = s; debug(); }
@@ -56,7 +59,8 @@
         if (bug != null)
         {
             bug.print(logfix + s);
-            bug.flush();
+            if ( ! (bug instanceof Log) )
+                bug.flush();
         }
         else if (debugAll)
         {
@@ -70,7 +74,8 @@
         if (bug != null)
         {
             bug.print(s);
-            bug.flush();
+            if ( ! (bug instanceof Log) )
+                bug.flush();
         }
         else if (debugAll)
         {
@@ -88,6 +93,7 @@
     }
 
     public PrintWriter getDebug()         { return bug ; }
+    public Log         getLog()           { return (Log)bug; }
                 
     /**
      * Do stack trace prints to err().



1.3       +8 -1      java/webfunds/utils/Diagnostics.java

Index: Diagnostics.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/utils/Diagnostics.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Diagnostics.java	2000/06/05 02:43:24	1.2
+++ Diagnostics.java	2001/04/12 04:43:28	1.3
@@ -1,5 +1,5 @@
 /*
- * $Id: Diagnostics.java,v 1.2 2000/06/05 02:43:24 gelderen Exp $
+ * $Id: Diagnostics.java,v 1.3 2001/04/12 04:43:28 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -9,6 +9,8 @@
 
 import java.io.PrintWriter;
 
+import webfunds.util.Log;
+
 public interface Diagnostics
 {
     void logmsg(String s);
@@ -22,4 +24,9 @@
      * Returns a debug writer, if any is set.
      */
     PrintWriter getDebug();
+
+    /**
+     * Returns a debug writer.
+    Log getLog();
+     */
 }



1.7       +15 -4     java/webfunds/utils/VersionNumbers.java

Index: VersionNumbers.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/utils/VersionNumbers.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- VersionNumbers.java	2000/11/19 10:21:22	1.6
+++ VersionNumbers.java	2001/04/12 04:43:28	1.7
@@ -1,5 +1,5 @@
 /*
- * $Id: VersionNumbers.java,v 1.6 2000/11/19 10:21:22 iang Exp $
+ * $Id: VersionNumbers.java,v 1.7 2001/04/12 04:43:28 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -12,6 +12,8 @@
 import java.util.Vector;
 import java.util.Enumeration;
 
+import webfunds.util.Log;
+
 /**
  * Work out version numbers embedded in file names.
  * A version number is a series of {dash number}
@@ -29,7 +31,7 @@
  */
 public class VersionNumbers
 {
-    static PrintWriter bug;
+    static Log bug;
     static void logmsg(String s) { if (bug != null) bug.println(s); }
 
     /**
@@ -48,12 +50,21 @@
      *
      * @return a list of latest-version plugin directories.
      */
-    static public String[] getListOfAddOns(File dir, PrintWriter callerBug)
+    static public String[] getListOfAddOns(File dir, Log callerBug)
     {
         bug = callerBug;
         return getList(dir);
     }
 
+    /**
+     * XXX: Deprecated
+     */
+    static public String[] getListOfAddOns(File dir, PrintWriter callerBug)
+    {
+        bug = new Log(callerBug);
+        return getList(dir);
+    }
+
     static protected void checkOutDirectory(File dir)
     {
         logmsg("directory: " + dir + " list is null");
@@ -280,7 +291,7 @@
     public static void main(String[] arg)
     {
 
-        bug = new PrintWriter(System.err, true);
+        bug = new Log();
 
         if (arg.length > 0)
         {