Index: /trunk/psLib/src/sys/psLogMsg.c
===================================================================
--- /trunk/psLib/src/sys/psLogMsg.c	(revision 4978)
+++ /trunk/psLib/src/sys/psLogMsg.c	(revision 4979)
@@ -12,6 +12,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-07 00:36:12 $
+ *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-09 01:11:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -90,7 +90,4 @@
 bool psLogSetDestination(int fd)
 {
-    //    char protocol[5];
-    //    char location[257];
-    //    char dest[257];
     FILE *fp;
     // if logDest has not been initialized, do so before using it
@@ -98,4 +95,6 @@
         logDest = stderr;
     }
+    if (fd == -1)
+        return false;
 
     if ( fd == 1 ) {
@@ -117,5 +116,5 @@
         }
         logDest = NULL;
-        return true;
+        //        return true;
     } else if (fd > 2) {
         if (logDest != NULL && logDest != stderr && logDest != stdout) {
@@ -125,57 +124,7 @@
         logDest = fp;
         //        fclose(fp);
-        return true;
-    }
-
-    /*
-        if (dest == NULL || strcmp(dest, "none") == 0) {
-            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) {
-                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 = file;
-            return true;
-        }
-    */
+        //        return true;
+    }
+
     return true;
 
@@ -253,4 +202,61 @@
 }
 
+int psMessageDestination (const char *dest)
+{
+    char protocol[5];
+    char location[257];
+    if (logDest == (FILE *) 1) {
+        logDest = stderr;
+    }
+
+    if (dest == NULL || strcmp(dest, "none") == 0) {
+        if (logDest != NULL && logDest != stderr && logDest != stdout) {
+            fclose(logDest);
+        }
+        logDest = NULL;
+        return 0;
+    }
+    if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
+        psError(PS_ERR_LOCATION_INVALID, true,
+                PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
+                dest);
+        return -1;
+    }
+    if (strcmp(protocol, "dest") == 0) {
+        if (strcmp(location, "stderr") == 0) {
+            if (logDest != NULL && logDest != stderr && logDest != stdout) {
+                fclose(logDest);
+            }
+            logDest = stderr;
+            return 2;
+        }
+        if (strcmp(location, "stdout") == 0) {
+            if (logDest != NULL && logDest != stderr && logDest != stdout) {
+                fclose(logDest);
+            }
+            logDest = stdout;
+            return 1;
+        }
+        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");
+        int fileD = creat(location, 0666);
+
+        if (fileD == 0) {
+            psError(PS_ERR_IO, true, PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
+                    location);
+            return -1;
+        }
+        if (logDest != NULL && logDest != stderr && logDest != stdout) {
+            fclose(logDest);
+        }
+        logDest = fdopen(fileD, "w");
+        return fileD;
+    }
+    return -1;
+}
+
 #ifndef HOST_NAME_MAX                // should be in limits.h
 #define HOST_NAME_MAX 256
Index: /trunk/psLib/src/sys/psLogMsg.h
===================================================================
--- /trunk/psLib/src/sys/psLogMsg.h	(revision 4978)
+++ /trunk/psLib/src/sys/psLogMsg.h	(revision 4979)
@@ -11,6 +11,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-07 00:36:12 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-09 01:11:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -61,4 +61,14 @@
 );
 
+/** This procedures uses a string to set the destination for which to send
+ *  the corresponding log messages.
+ *
+ *
+ *  @return int:        The file descriptor location of the message.
+ */
+int psMessageDestination(
+    const char *dest                   ///< Specifies where to send the message
+);
+
 /** This procedure logs a message to the destination set by a prior
  *  call to psLogSetDestination(), if myLevel is less than the level
Index: /trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- /trunk/psLib/src/types/psMetadataConfig.c	(revision 4978)
+++ /trunk/psLib/src/types/psMetadataConfig.c	(revision 4979)
@@ -10,11 +10,10 @@
 *  @author Eric Van Alst, MHPCC
 *
-*  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-08-24 22:00:53 $
+*  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-09 01:11:23 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */
 
-#include <libxml/parser.h>
 #include <fitsio.h>
 #include <string.h>
Index: /trunk/psLib/test/sys/tst_psLogMsg.c
===================================================================
--- /trunk/psLib/test/sys/tst_psLogMsg.c	(revision 4978)
+++ /trunk/psLib/test/sys/tst_psLogMsg.c	(revision 4979)
@@ -16,4 +16,5 @@
 static psS32 testLogMsg04();
 static psS32 testLogMsg05();
+static psS32 testLogMsg06();
 
 testDescription tests[] = {
@@ -35,4 +36,7 @@
                               {
                                   testLogMsg05, 5, "psLogSetDestination()", 0, false
+                              },
+                              {
+                                  testLogMsg06, 6, "psMessageDestination()", 0, false
                               },
                               {
@@ -236,2 +240,64 @@
     return 0;
 }
+
+psS32 testLogMsg06()
+{
+    psS32 i = 0;
+    //    FILE* file;
+    int fd;
+    //    char line[256];
+
+    printf("--------------- psMessageDestination(PS_LOG_NONE) ----------------\n");
+    psMessageDestination("none");
+    //    psLogSetDestination(0);
+    for (i=0;i<10;i++) {
+        psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
+    }
+
+    printf("------------- psMessageDestination(PS_LOG_TO_STDERR) -------------\n");
+    psMessageDestination("dest:stderr");
+    //    psLogSetDestination(2);
+    for (i=0;i<10;i++) {
+        psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
+    }
+
+    printf("------------- psMessageDestination(PS_LOG_TO_STDOUT) -------------\n");
+    psMessageDestination("dest:stdout");
+    //    psLogSetDestination(1);
+    for (i=0;i<10;i++) {
+        psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
+    }
+
+    printf("--------------- psMessageDestination(""file:log2.txt"") ---------------\n");
+    fd = creat("log2.txt", 0666);
+    psMessageDestination("file:log2.txt");
+    //    psLogSetDestination(fd);
+    for (i=0;i<10;i++) {
+        psLogMsg(__func__, i, "Hello World!  My level is %d\n", i);
+    }
+
+
+    psMessageDestination("none");
+    FILE *file;
+    char line[257];
+    //    psMessageDestination(-1);
+    //    psLogSetDestination(0);
+    printf("--------------------- The Contents of log2.txt -------------------\n");
+    file = fopen("log2.txt","r");
+    while ( fgets(line,256,file) != NULL ) {
+        printf("%s",line);
+    }
+    fclose(file);
+    close(fd);
+
+    int fd2 = creat("/eva/log2.txt", 0666);
+    printf("--------------- psMessageDestination(""file:/eva/log.txt"") ----------\n");
+    psMessageDestination("file:/eva/log2.txt");
+    //    psLogSetDestination(fd2);
+    for ( i=0;i<10;i++) {
+        psLogMsg(__func__, i, "Hello World! My level is %d\n", i);
+    }
+    close(fd2);
+
+    return 0;
+}
Index: /trunk/psLib/test/sys/verified/tst_psLogMsg.stderr
===================================================================
--- /trunk/psLib/test/sys/verified/tst_psLogMsg.stderr	(revision 4978)
+++ /trunk/psLib/test/sys/verified/tst_psLogMsg.stderr	(revision 4979)
@@ -167,2 +167,19 @@
 ---> TESTPOINT PASSED (psLogMsg{psLogSetDestination()} | tst_psLogMsg.c)
 
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psLogMsg.c                                             *
+*            TestPoint: psLogMsg{psMessageDestination()}                           *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|A|testLogMsg06
+    Hello World!  My level is 0
+<DATE><TIME>|<HOST>|E|testLogMsg06
+    Hello World!  My level is 1
+<DATE><TIME>|<HOST>|W|testLogMsg06
+    Hello World!  My level is 2
+<DATE><TIME>|<HOST>|I|testLogMsg06
+    Hello World!  My level is 3
+
+---> TESTPOINT PASSED (psLogMsg{psMessageDestination()} | tst_psLogMsg.c)
+
Index: /trunk/psLib/test/sys/verified/tst_psLogMsg.stdout
===================================================================
--- /trunk/psLib/test/sys/verified/tst_psLogMsg.stdout	(revision 4978)
+++ /trunk/psLib/test/sys/verified/tst_psLogMsg.stdout	(revision 4979)
@@ -21,2 +21,24 @@
     Hello World!  My level is 3
 --------------- psLogSetDestination(file:/eva/log.txt) ----------
+--------------- psMessageDestination(PS_LOG_NONE) ----------------
+------------- psMessageDestination(PS_LOG_TO_STDERR) -------------
+------------- psMessageDestination(PS_LOG_TO_STDOUT) -------------
+<DATE><TIME>|<HOST>|A|testLogMsg06
+    Hello World!  My level is 0
+<DATE><TIME>|<HOST>|E|testLogMsg06
+    Hello World!  My level is 1
+<DATE><TIME>|<HOST>|W|testLogMsg06
+    Hello World!  My level is 2
+<DATE><TIME>|<HOST>|I|testLogMsg06
+    Hello World!  My level is 3
+--------------- psMessageDestination(file:log2.txt) ---------------
+--------------------- The Contents of log2.txt -------------------
+<DATE><TIME>|<HOST>|A|testLogMsg06
+    Hello World!  My level is 0
+<DATE><TIME>|<HOST>|E|testLogMsg06
+    Hello World!  My level is 1
+<DATE><TIME>|<HOST>|W|testLogMsg06
+    Hello World!  My level is 2
+<DATE><TIME>|<HOST>|I|testLogMsg06
+    Hello World!  My level is 3
+--------------- psMessageDestination(file:/eva/log.txt) ----------
