Index: trunk/psLib/src/sysUtils/psLogMsg.c
===================================================================
--- trunk/psLib/src/sysUtils/psLogMsg.c	(revision 1406)
+++ trunk/psLib/src/sysUtils/psLogMsg.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psLogMsg.c
  *  @brief Procedures for logging messages.
@@ -11,6 +12,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -44,11 +45,11 @@
 
 #define MAX_LOG_LINE_LENGTH 128
-static FILE* logDest = (FILE*)1;       // flag to initialize to stderr before using.
-static int globalLogLevel = PS_LOG_INFO; // log all messages at this or above
-static bool logTime = true;            // Flag to include time info
-static bool logHost = true;            // Flag to include host info
-static bool logLevel = true;           // Flag to include level info
-static bool logName = true;            // Flag to include name info
-static bool logMsg = true;             // Flag to include message info
+static FILE *logDest = (FILE *) 1;      // flag to initialize to stderr before using.
+static int globalLogLevel = PS_LOG_INFO;        // log all messages at this or above
+static bool logTime = true;     // Flag to include time info
+static bool logHost = true;     // Flag to include host info
+static bool logLevel = true;    // Flag to include level info
+static bool logName = true;     // Flag to include name info
+static bool logMsg = true;      // Flag to include message info
 
 /*****************************************************************************
@@ -67,9 +68,7 @@
 
     if ((level < MIN_LOG_LEVEL) || (level > MAX_LOG_LEVEL)) {
-        psLogMsg("logmsg", PS_LOG_WARN,
-                 "Attempt to set invalid logMsg level: %d", level);
+        psLogMsg("logmsg", PS_LOG_WARN, "Attempt to set invalid logMsg level: %d", level);
         level = (level < MIN_LOG_LEVEL) ? MIN_LOG_LEVEL : MAX_LOG_LEVEL;
     }
-
     // Set new global log level
     globalLogLevel = level;
@@ -78,5 +77,4 @@
     return oldLevel;
 }
-
 
 /*****************************************************************************
@@ -91,5 +89,5 @@
  An integer specifying the old log destination.
  *****************************************************************************/
-int psLogSetDestination(const char* dest)
+int psLogSetDestination(const char *dest)
 {
     char protocol[5];
@@ -97,9 +95,9 @@
 
     // if logDest has not been initialized, do so before using it
-    if (logDest==(FILE*)1) {
+    if (logDest == (FILE *) 1) {
         logDest = stderr;
     }
 
-    if (dest == NULL || strcmp(dest,"none")==0) {
+    if (dest == NULL || strcmp(dest, "none") == 0) {
         if (logDest != NULL && logDest != stderr && logDest != stdout) {
             fclose(logDest);
@@ -109,11 +107,11 @@
     }
 
-    if (sscanf(dest,"%4s:%256s",protocol,location) < 2) {
-        psError(__func__,"The specified destination, %s, is malformed.", dest);
+    if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
+        psError(__func__, "The specified destination, %s, is malformed.", dest);
         return 1;
     }
 
-    if (strcmp(protocol,"dest") == 0) {
-        if (strcmp(location,"stderr") == 0) {
+    if (strcmp(protocol, "dest") == 0) {
+        if (strcmp(location, "stderr") == 0) {
             if (logDest != NULL && logDest != stderr && logDest != stdout) {
                 fclose(logDest);
@@ -122,5 +120,5 @@
             return 0;
         }
-        if (strcmp(location,"stdout") == 0) {
+        if (strcmp(location, "stdout") == 0) {
             if (logDest != NULL && logDest != stderr && logDest != stdout) {
                 fclose(logDest);
@@ -129,21 +127,21 @@
             return 0;
         }
-        psError(__func__,"The location, %s, for protocol 'dest' is invalid.",location);
+        psError(__func__, "The location, %s, for protocol 'dest' is invalid.", location);
         return 1;
-    } else
-        if (strcmp(protocol,"file") == 0) {
-            FILE* file = fopen(location,"w");
-            if (file == NULL) {
-                psError(__func__,"Could not open file '%s' for output.",location);
-                return 1;
-            }
-            if (logDest != NULL && logDest != stderr && logDest != stdout) {
-                fclose(logDest);
-            }
-            logDest = file;
-            return 0;
-        }
-
-    psError(__func__,"Do not know how to handle the protocol '%s'.",protocol);
+    } else if (strcmp(protocol, "file") == 0) {
+        FILE *file = fopen(location, "w");
+
+        if (file == NULL) {
+            psError(__func__, "Could not open file '%s' for output.", location);
+            return 1;
+        }
+        if (logDest != NULL && logDest != stderr && logDest != stdout) {
+            fclose(logDest);
+        }
+        logDest = file;
+        return 0;
+    }
+
+    psError(__func__, "Do not know how to handle the protocol '%s'.", protocol);
     return 1;
 }
@@ -181,5 +179,4 @@
         fmt = "THLNM";
     }
-
     // Step through each character in the format string.  For each letter
     // in that string, set/unset the appropriate logging.
@@ -214,15 +211,12 @@
 
     if (!logMsg) {
-        psTrace("utils.logMsg", 1,
-                "You must at least log error messages (You chose \"%s\")",
-                fmt);
-    }
-}
-
-
-
-#if !defined(HOST_NAME_MAX)  // should be in limits.h
-#  define HOST_NAME_MAX 256
+        psTrace("utils.logMsg", 1, "You must at least log error messages (You chose \"%s\")", fmt);
+    }
+}
+
+#if !defined(HOST_NAME_MAX)                // should be in limits.h
+#    define HOST_NAME_MAX 256
 #endif
+
 /*****************************************************************************
     psVLogMsg(): This routine sends the message, which is a printf style
@@ -239,29 +233,25 @@
  NULL.
  *****************************************************************************/
-void psLogMsgV(const char *name,
-               int level,
-               const char *fmt,
-               va_list ap)
-{
-    static int first = 1;               // Flag for calling gethostname()
+void psLogMsgV(const char *name, int level, const char *fmt, va_list ap)
+{
+    static int first = 1;       // Flag for calling gethostname()
     static char hostname[HOST_NAME_MAX + 1];
+
     // Buffer for hostname.
-    char clevel=0;                      // letter-name for level
-    char head[MAX_LOG_LINE_LENGTH+2];   // the added two are for the ending | and \0
-    char *head_ptr = head;              // where we've got to in head
+    char clevel = 0;            // letter-name for level
+    char head[MAX_LOG_LINE_LENGTH + 2]; // the added two are for the ending | and \0
+    char *head_ptr = head;      // where we've got to in head
     int maxLength = MAX_LOG_LINE_LENGTH;
-    time_t clock = time(NULL);          // The current time.
+    time_t clock = time(NULL);  // The current time.
     struct tm *utc = gmtime(&clock);    // The current gm time.
 
     // if logDest has not been initialized, do so before using it
-    if (logDest==(FILE*)1) {
+    if (logDest == (FILE *) 1) {
         logDest = stderr;
     }
-
     // If logging is off, or if the level is too high, return immediately.
     if ((level > globalLogLevel) || (logDest == NULL)) {
         return;
     }
-
     // If I have not been here yet, determine my hostname and save it.
     if (first) {
@@ -297,6 +287,5 @@
 
     default:
-        psTrace("utils.logMsg", 2, "Invalid logMsg level: %d (%s)\n",
-                level, fmt);
+        psTrace("utils.logMsg", 2, "Invalid logMsg level: %d (%s)\n", level, fmt);
         level = (level < 0) ? 0 : 9;
         break;
@@ -307,5 +296,5 @@
         maxLength -= snprintf(head_ptr, maxLength, "%4d:%02d:%02d %02d:%02d:%02dZ",
                               utc->tm_year + 1900, utc->tm_mon + 1, utc->tm_mday,
-                              utc->tm_hour, utc->tm_min, utc->tm_sec)-1;
+                              utc->tm_hour, utc->tm_min, utc->tm_sec) - 1;
         head_ptr += strlen(head_ptr);
     }
@@ -336,8 +325,7 @@
     if (head_ptr > head) {
         *head_ptr++ = '|';
-    } else
-        if (!logMsg) { // no output desired
-            return;
-        }
+    } else if (!logMsg) {                  // no output desired
+        return;
+    }
     *head_ptr = '\0';
 
@@ -352,5 +340,4 @@
     }
 }
-
 
 /*****************************************************************************
@@ -369,8 +356,5 @@
  NULL
  *****************************************************************************/
-void psLogMsg(const char *name,
-              int level,
-              const char *fmt,
-              ...)
+void psLogMsg(const char *name, int level, const char *fmt, ...)
 {
     va_list ap;
