Index: /trunk/psLib/src/sys/psLogMsg.c
===================================================================
--- /trunk/psLib/src/sys/psLogMsg.c	(revision 4950)
+++ /trunk/psLib/src/sys/psLogMsg.c	(revision 4951)
@@ -12,6 +12,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-07-12 19:12:01 $
+ *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-07 00:15:48 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -37,4 +37,5 @@
 #include <time.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #include "psLogMsg.h"
@@ -87,9 +88,10 @@
  An psBool: TRUE if successful.
  *****************************************************************************/
-bool psLogSetDestination(const char *dest)
+bool psLogSetDestination(int fd)
 {
-    char protocol[5];
-    char location[257];
-
+    //    char protocol[5];
+    //    char location[257];
+    //    char dest[257];
+    FILE *fp;
     // if logDest has not been initialized, do so before using it
     if (logDest == (FILE *) 1) {
@@ -97,55 +99,85 @@
     }
 
-    if (dest == NULL || strcmp(dest, "none") == 0) {
+    if ( fd == 1 ) {
+        //        fp = stdout;
         if (logDest != NULL && logDest != stderr && logDest != stdout) {
             fclose(logDest);
         }
+        logDest = stdout;
+    } else if (fd == 2) {
+        //        fp = stderr;
+        if (logDest != NULL && logDest != stderr && logDest != stdout) {
+            fclose(logDest);
+        }
+        logDest = stderr;
+    } else if (fd == 0) {
+        //        fp = NULL;
+        if (logDest != NULL && logDest != stderr && logDest != stdout) {
+            fclose(logDest);
+        }
         logDest = NULL;
         return true;
-    }
-
-    if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
-        psError(PS_ERR_LOCATION_INVALID, true,
-                PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
-                dest);
-        return false;
-    }
-
-    if (strcmp(protocol, "dest") == 0) {
-        if (strcmp(location, "stderr") == 0) {
+    } else if (fd > 2) {
+        if (logDest != NULL && logDest != stderr && logDest != stdout) {
+            fclose(logDest);
+        }
+        fp = fdopen(fd, "w");
+        logDest = fp;
+        //        fclose(fp);
+        return true;
+    }
+
+    /*
+        if (dest == NULL || strcmp(dest, "none") == 0) {
             if (logDest != NULL && logDest != stderr && logDest != stdout) {
                 fclose(logDest);
             }
-            logDest = stderr;
+            logDest = NULL;
             return true;
         }
-        if (strcmp(location, "stdout") == 0) {
+        if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
+                    dest);
+            return false;
+        }
+    */
+    /*
+     
+        if (strcmp(protocol, "dest") == 0) {
+            if (strcmp(location, "stderr") == 0) {
+                if (logDest != NULL && logDest != stderr && logDest != stdout) {
+                    fclose(logDest);
+                }
+                logDest = stderr;
+                return true;
+            }
+            if (strcmp(location, "stdout") == 0) {
+                if (logDest != NULL && logDest != stderr && logDest != stdout) {
+                    fclose(logDest);
+                }
+                logDest = stdout;
+                return true;
+            }
+            psError(PS_ERR_LOCATION_INVALID, true, PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,
+                    location);
+            return 1;
+        } else if (strcmp(protocol, "file") == 0) {
+            FILE *file = fopen(location, "w");
+     
+            if (file == NULL) {
+                psError(PS_ERR_IO, true, PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
+                        location);
+                return false;
+            }
             if (logDest != NULL && logDest != stderr && logDest != stdout) {
                 fclose(logDest);
             }
-            logDest = stdout;
+            logDest = file;
             return true;
         }
-        psError(PS_ERR_LOCATION_INVALID, true, PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,
-                location);
-        return 1;
-    } else if (strcmp(protocol, "file") == 0) {
-        FILE *file = fopen(location, "w");
-
-        if (file == NULL) {
-            psError(PS_ERR_IO, true, PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
-                    location);
-            return false;
-        }
-        if (logDest != NULL && logDest != stderr && logDest != stdout) {
-            fclose(logDest);
-        }
-        logDest = file;
-        return true;
-    }
-
-    psError(PS_ERR_LOCATION_INVALID, true, PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,
-            protocol);
-    return false;
+    */
+    return true;
+
 }
 
Index: /trunk/psLib/src/sys/psLogMsg.h
===================================================================
--- /trunk/psLib/src/sys/psLogMsg.h	(revision 4950)
+++ /trunk/psLib/src/sys/psLogMsg.h	(revision 4951)
@@ -11,6 +11,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-07-15 02:33:54 $
+ *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-07 00:15:48 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -33,5 +33,5 @@
  */
 bool psLogSetDestination(
-    const char *dest                   ///< Specifies where to send messages.
+    int fd                             ///< Specifies where to send messages.
 );
 
Index: /trunk/psLib/src/sys/psTrace.c
===================================================================
--- /trunk/psLib/src/sys/psTrace.c	(revision 4950)
+++ /trunk/psLib/src/sys/psTrace.c	(revision 4951)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-02 21:32:06 $
+ *  @version $Revision: 1.57 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-07 00:15:48 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -245,8 +245,9 @@
  zero
 *****************************************************************************/
-psBool psTraceSetLevel(const char *comp,   // component of interest
-                       int level)  // desired trace level
+int psTraceSetLevel(const char *comp,   // component of interest
+                    int level)  // desired trace level
 {
     char *compName = NULL;
+    int prevLevel = -1;
 
     // If the root component tree does not exist, then initialize it.
@@ -267,5 +268,5 @@
         compName = (char *) comp;
     }
-
+    prevLevel = psTraceGetLevel(compName);
     // Add the new component to the component tree.
     if ( !componentAdd(compName, level) ) {
@@ -278,5 +279,6 @@
             psFree(compName);
         }
-        return false;
+        //        return false;
+        return -1;
     }
 
@@ -285,5 +287,6 @@
     }
 
-    return true;
+    //    return true;
+    return prevLevel;
 }
 
@@ -489,4 +492,5 @@
 void p_psTrace(const char *comp,        // component being traced
                int level,               // desired trace level
+               const char *format,
                ...)                     // arguments
 {
@@ -508,5 +512,5 @@
     // of it's associatedcomponent.
     if (level <= psTraceGetLevel(comp)) {
-        va_start(ap, level);
+        va_start(ap, format);
 
         // The following functions get the variable list of parameters with
@@ -517,7 +521,9 @@
         // We indent each message one space for each level of the message.
         for (i = 0; i < level; i++) {
-            fprintf(traceFP, " ");
+            //            fprintf(traceFP, " ");
+            fprintf(traceFP, "%s", format);
         }
         vfprintf(traceFP, fmt, ap);
+        //        vfprintf(traceFP, format, ap);
         va_end(ap);
     }
@@ -532,10 +538,10 @@
     /*
         bool special;
-     
+
         // XXX EAM perhaps return an error?
         if (fp == NULL) {
             return;
         }
-     
+
         // cannot close traceFP if one of the special FILE ptrs
         special  = (traceFP == NULL);
@@ -543,5 +549,5 @@
         special |= (traceFP == stdout);
         special |= (traceFP == stderr);
-     
+
         if (!special) {
             fclose (traceFP);
Index: /trunk/psLib/src/sys/psTrace.h
===================================================================
--- /trunk/psLib/src/sys/psTrace.h	(revision 4950)
+++ /trunk/psLib/src/sys/psTrace.h	(revision 4951)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-02 21:32:06 $
+ *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-07 00:15:48 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -64,4 +64,5 @@
     const char *facil,                 ///< facilty of interest
     int level,                         ///< desired trace level
+    const char *format,                ///< printf-style format command
     ...                                ///< trace message arguments
 );
@@ -72,4 +73,5 @@
     const char *facil,                 ///< facilty of interest
     psS32 myLevel,                     ///< desired trace level
+    const char *format,                ///< printf-style format command
     ...                                ///< trace message arguments
 );
@@ -83,7 +85,7 @@
 /** Set trace level
  *
- *  @return psBool:       True if successful, otherwise false
+ *  @return int:       The previous level.
  */
-psBool psTraceSetLevel(
+int psTraceSetLevel(
     const char *facil,                 ///< facilty of interest
     int level                          ///< desired trace level
Index: /trunk/psLib/test/math/tst_psRandom.c
===================================================================
--- /trunk/psLib/test/math/tst_psRandom.c	(revision 4950)
+++ /trunk/psLib/test/math/tst_psRandom.c	(revision 4951)
@@ -19,4 +19,6 @@
 #include <stdio.h>
 #include <math.h>
+#include <fcntl.h>
+#include <unistd.h>
 #include "pslib_strict.h"
 #include "psTest.h"
@@ -80,7 +82,10 @@
 
     // Valid type allocation with seed equal to zero
-    psLogSetDestination("file:seed_msglog1.txt");
+    int fd1 = creat("seed_msglog1.txt", 0666);
+    //    psLogSetDestination("file:seed_msglog1.txt");
+    psLogSetDestination(fd1);
     myRNG = psRandomAlloc(PS_RANDOM_TAUS, 0);
-    psLogSetDestination("dest:stderr");
+    //    psLogSetDestination("dest:stderr");
+    psLogSetDestination(2);
     if (myRNG == NULL) {
         psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure");
@@ -107,4 +112,5 @@
         return 6;
     }
+    close(fd1);
     psFree(myRNG);
 
@@ -291,7 +297,9 @@
     psRandom *myRNG1 = NULL;
     myRNG1 = psRandomAlloc(PS_RANDOM_TAUS, SEED);
-    psLogSetDestination("file:seed_msglog2.txt");
+    //    psLogSetDestination("dest:stderr");
+    psLogSetDestination(0);
     psRandomReset(myRNG1,0);
-    psLogSetDestination("dest:stderr");
+    //    psLogSetDestination("dest:stderr");
+    psLogSetDestination(2);
     psFree(myRNG1);
 
Index: /trunk/psLib/test/sys/tst_psLogMsg.c
===================================================================
--- /trunk/psLib/test/sys/tst_psLogMsg.c	(revision 4950)
+++ /trunk/psLib/test/sys/tst_psLogMsg.c	(revision 4951)
@@ -7,4 +7,6 @@
 #include "pslib_strict.h"
 #include "psTest.h"
+#include <unistd.h>
+#include <fcntl.h>
 
 static psS32 testLogMsg00();
@@ -176,9 +178,11 @@
 {
     psS32 i = 0;
-    FILE* file;
-    char line[256];
+    //    FILE* file;
+    int fd;
+    //    char line[256];
 
     printf("--------------- psLogSetDestination(PS_LOG_NONE) ----------------\n");
-    psLogSetDestination("none");
+    //    psLogSetDestination("none");
+    psLogSetDestination(0);
     for (i=0;i<10;i++) {
         psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
@@ -186,5 +190,6 @@
 
     printf("------------- psLogSetDestination(PS_LOG_TO_STDERR) -------------\n");
-    psLogSetDestination("dest:stderr");
+    //    psLogSetDestination("dest:stderr");
+    psLogSetDestination(2);
     for (i=0;i<10;i++) {
         psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
@@ -192,15 +197,24 @@
 
     printf("------------- psLogSetDestination(PS_LOG_TO_STDOUT) -------------\n");
-    psLogSetDestination("dest:stdout");
-    for (i=0;i<10;i++) {
-        psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
-    }
+    //    psLogSetDestination("dest:stdout");
+    psLogSetDestination(1);
+    for (i=0;i<10;i++) {
+        psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
+    }
+
     printf("--------------- psLogSetDestination(""file:log.txt"") ---------------\n");
-    psLogSetDestination("file:log.txt");
-    for (i=0;i<10;i++) {
-        psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
-    }
-
-    psLogSetDestination("none");
+    fd = creat("log.txt", 0666);
+    //    psLogSetDestination("file:log.txt");
+    psLogSetDestination(fd);
+    for (i=0;i<10;i++) {
+        psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
+    }
+
+
+    //    psLogSetDestination("none");
+    FILE *file;
+    char line[257];
+    //    psLogSetDestination(-1);
+    psLogSetDestination(0);
     printf("--------------------- The Contents of log.txt -------------------\n");
     file = fopen("log.txt","r");
@@ -209,11 +223,15 @@
     }
     fclose(file);
-
+    close(fd);
+
+    int fd2 = creat("/eva/log.txt", 0666);
     printf("--------------- psLogSetDestination(""file:/eva/log.txt"") ----------\n");
-    psLogSetDestination("file:/eva/log.txt");
+    //    psLogSetDestination("file:/eva/log.txt");
+    psLogSetDestination(fd2);
     for ( i=0;i<10;i++) {
         psLogMsg(__func__, i, "Hello World! My level is %d\n", i);
     }
-
-    return 0;
-}
+    close(fd2);
+
+    return 0;
+}
Index: /trunk/psLib/test/sys/tst_psTrace.c
===================================================================
--- /trunk/psLib/test/sys/tst_psTrace.c	(revision 4950)
+++ /trunk/psLib/test/sys/tst_psTrace.c	(revision 4951)
@@ -103,7 +103,7 @@
     (void)psTraceSetLevel(".A.B.C.D.E", 5);
 
-    psTrace(".A.C.D.C",1,"You should not see this.\n");
-    psTrace(".A.B.C.D.E",2,"You should see this.\n");
-    psTrace(".A.B.C.D.E.F",3,"You should see this too.\n");
+    psTrace(".A.C.D.C",1," ","You should not see this.\n");
+    psTrace(".A.B.C.D.E",2," ","You should see this.\n");
+    psTrace(".A.B.C.D.E.F",3," ","You should see this too.\n");
 
     psTracePrintLevels();
@@ -208,23 +208,23 @@
 
         (void)psTraceSetLevel(".", 4);
-        psTrace(".", 5, "(0) This message should not be displayed (%x)\n",
+        psTrace(".", 5, " ", "(0) This message should not be displayed (%x)\n",
                 0xbeefface);
         (void)psTraceSetLevel(".", 7);
-        psTrace(".", 5, "(0) This message should be displayed (%x)\n",
+        psTrace(".", 5, " ", "(0) This message should be displayed (%x)\n",
                 0xbeefface);
 
         (void)psTraceSetLevel(".a", 4);
-        psTrace(".a", 5, "(1) This message should not be displayed (%x)\n",
+        psTrace(".a", 5, " ", "(1) This message should not be displayed (%x)\n",
                 0xbeefface);
         (void)psTraceSetLevel(".a", 7);
-        psTrace(".a", 5, "(1) This message should be displayed (%x)\n",
+        psTrace(".a", 5, " ", "(1) This message should be displayed (%x)\n",
                 0xbeefface);
 
 
         (void)psTraceSetLevel(".a.b", 4);
-        psTrace(".a.b", 5, "(2) This message should not be displayed (%x)\n",
+        psTrace(".a.b", 5, " ", "(2) This message should not be displayed (%x)\n",
                 0xbeefface);
         (void)psTraceSetLevel(".a.b", 7);
-        psTrace(".a.b", 5, "(2) This message should be displayed (%x)\n",
+        psTrace(".a.b", 5, " ", "(2) This message should be displayed (%x)\n",
                 0xbeefface);
 
