Index: trunk/psLib/src/sys/psTrace.c
===================================================================
--- trunk/psLib/src/sys/psTrace.c	(revision 8601)
+++ trunk/psLib/src/sys/psTrace.c	(revision 9540)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-25 22:01:29 $
+ *  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-13 22:04:58 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -69,4 +69,5 @@
 static void componentFree(p_psComponent* comp);
 static p_psComponent* componentAlloc(const char *name, int level);
+static int getLevel(const char *facil);
 
 /*****************************************************************************
@@ -122,4 +123,15 @@
     }
 }
+
+// Append the function name to the facility
+// NB: declares TARGET!
+#define FACILITY(TARGET, FUNC, FACIL) \
+size_t _facilLength = strlen(FACIL); /* Length of facility name */ \
+size_t _funcLength = strlen(FUNC);   /* Length of function name */ \
+char TARGET[_facilLength + _funcLength + 2]; /* facility + the function name */ \
+strcpy(&TARGET[0], FACIL); \
+TARGET[_facilLength] = '.'; \
+strcpy(&TARGET[_facilLength + 1], FUNC);
+
 
 /*****************************************************************************
@@ -283,5 +295,5 @@
         compName = (char *) comp;
     }
-    prevLevel = psTraceGetLevel(compName);
+    prevLevel = getLevel(compName);
     // Add the new component to the component tree.
     if ( !componentAdd(compName, level) ) {
@@ -385,25 +397,18 @@
 }
 
-/*****************************************************************************
-    psTraceLevelGet()
+
+/*****************************************************************************
+    getLevel()
  Return a trace level of "name" in the root component tree.  If the
  exact string of components in "name" does not exist in the root
  tree, we return the deepest level of the match.
-    Input:
- name
-    Output:
- none
-    Return:
- The level of "name" in the root component tree.
- *****************************************************************************/
-int psTraceGetLevel(const char *name)
-{
-    PS_ASSERT_PTR_NON_NULL(name, 0);
-
-    psS32 traceLevel;
-
+ *****************************************************************************/
+static int getLevel(const char *name)
+{
     if (cRoot == NULL) {
         return (PS_UNKNOWN_TRACE_LEVEL);
     }
+
+    psS32 traceLevel;
 
     // If the component name has no leading dot, then supply it.
@@ -430,4 +435,16 @@
 
     return(traceLevel);
+}
+
+int p_psTraceGetLevel(const char *file,
+                      int lineno,
+                      const char *func,
+                      const char *name)
+{
+    PS_ASSERT_PTR_NON_NULL(name, 0);
+    PS_ASSERT_PTR_NON_NULL(func, 0);
+
+    FACILITY(facility, func, name);
+    return getLevel(facility);
 }
 
@@ -520,5 +537,5 @@
     // Only display this message if it's trace level is less than the level
     // of it's associatedcomponent.
-    if (level <= psTraceGetLevel(comp)) {
+    if (level <= getLevel(comp)) {
 
         char clevel = 0;                    // letter-name for level
@@ -641,17 +658,9 @@
     PS_ASSERT_PTR_NON_NULL(format, );
 
-    // XXX file & lineo are currently unused
-
-    // Append the function name to the facility
-    size_t facilLength = strlen(facil); // Length of facility name
-    size_t funcLength = strlen(func);   // Length of function name
-    char fullFacil[facilLength + funcLength + 2]; // Full facility name is the facility + the function name
-    strcpy(&fullFacil[0], facil);
-    fullFacil[facilLength] = '.';
-    strcpy(&fullFacil[facilLength + 1], func);
+    FACILITY(name, func, facil);
 
     va_list ap;
     va_start(ap, format);
-    psTraceV(fullFacil, level, format, ap);
+    psTraceV(name, level, format, ap);
     va_end(ap);
 }
