IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 13, 2006, 12:04:58 PM (20 years ago)
Author:
Paul Price
Message:

Fixing psTraceGetLevel to use same convention as for psTrace

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psTrace.c

    r8601 r9540  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-08-25 22:01:29 $
     11 *  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-10-13 22:04:58 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6969static void componentFree(p_psComponent* comp);
    7070static p_psComponent* componentAlloc(const char *name, int level);
     71static int getLevel(const char *facil);
    7172
    7273/*****************************************************************************
     
    122123    }
    123124}
     125
     126// Append the function name to the facility
     127// NB: declares TARGET!
     128#define FACILITY(TARGET, FUNC, FACIL) \
     129size_t _facilLength = strlen(FACIL); /* Length of facility name */ \
     130size_t _funcLength = strlen(FUNC);   /* Length of function name */ \
     131char TARGET[_facilLength + _funcLength + 2]; /* facility + the function name */ \
     132strcpy(&TARGET[0], FACIL); \
     133TARGET[_facilLength] = '.'; \
     134strcpy(&TARGET[_facilLength + 1], FUNC);
     135
    124136
    125137/*****************************************************************************
     
    283295        compName = (char *) comp;
    284296    }
    285     prevLevel = psTraceGetLevel(compName);
     297    prevLevel = getLevel(compName);
    286298    // Add the new component to the component tree.
    287299    if ( !componentAdd(compName, level) ) {
     
    385397}
    386398
    387 /*****************************************************************************
    388     psTraceLevelGet()
     399
     400/*****************************************************************************
     401    getLevel()
    389402 Return a trace level of "name" in the root component tree.  If the
    390403 exact string of components in "name" does not exist in the root
    391404 tree, we return the deepest level of the match.
    392     Input:
    393  name
    394     Output:
    395  none
    396     Return:
    397  The level of "name" in the root component tree.
    398  *****************************************************************************/
    399 int psTraceGetLevel(const char *name)
    400 {
    401     PS_ASSERT_PTR_NON_NULL(name, 0);
    402 
    403     psS32 traceLevel;
    404 
     405 *****************************************************************************/
     406static int getLevel(const char *name)
     407{
    405408    if (cRoot == NULL) {
    406409        return (PS_UNKNOWN_TRACE_LEVEL);
    407410    }
     411
     412    psS32 traceLevel;
    408413
    409414    // If the component name has no leading dot, then supply it.
     
    430435
    431436    return(traceLevel);
     437}
     438
     439int p_psTraceGetLevel(const char *file,
     440                      int lineno,
     441                      const char *func,
     442                      const char *name)
     443{
     444    PS_ASSERT_PTR_NON_NULL(name, 0);
     445    PS_ASSERT_PTR_NON_NULL(func, 0);
     446
     447    FACILITY(facility, func, name);
     448    return getLevel(facility);
    432449}
    433450
     
    520537    // Only display this message if it's trace level is less than the level
    521538    // of it's associatedcomponent.
    522     if (level <= psTraceGetLevel(comp)) {
     539    if (level <= getLevel(comp)) {
    523540
    524541        char clevel = 0;                    // letter-name for level
     
    641658    PS_ASSERT_PTR_NON_NULL(format, );
    642659
    643     // XXX file & lineo are currently unused
    644 
    645     // Append the function name to the facility
    646     size_t facilLength = strlen(facil); // Length of facility name
    647     size_t funcLength = strlen(func);   // Length of function name
    648     char fullFacil[facilLength + funcLength + 2]; // Full facility name is the facility + the function name
    649     strcpy(&fullFacil[0], facil);
    650     fullFacil[facilLength] = '.';
    651     strcpy(&fullFacil[facilLength + 1], func);
     660    FACILITY(name, func, facil);
    652661
    653662    va_list ap;
    654663    va_start(ap, format);
    655     psTraceV(fullFacil, level, format, ap);
     664    psTraceV(name, level, format, ap);
    656665    va_end(ap);
    657666}
Note: See TracChangeset for help on using the changeset viewer.