IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9540 for trunk/psLib/src/sys


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

Location:
trunk/psLib/src/sys
Files:
2 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}
  • trunk/psLib/src/sys/psTrace.h

    r8627 r9540  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-08-26 04:34:28 $
     11 *  @version $Revision: 1.51 $ $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
    … …  
    8989);
    9090
     91/** Get the trace level
     92 *
     93 *  @return int:    Trace Level
     94 */
     95int psTraceGetLevel(
     96    const char *facil                  ///< facilty of interest
     97);
     98
    9199#else // DOXYGEN
    92100#ifdef __GNUC__
    … …  
    112120);
    113121#endif // __GNUC__
     122
     123/** Get the trace level
     124 *
     125 *  @return int:    Trace Level
     126 */
     127int p_psTraceGetLevel(
     128    const char* file,                  ///< file name
     129    int lineno,                        ///< line number in file
     130    const char *func,                  ///< function name
     131    const char *facil                  ///< facilty of interest
     132);
     133
    114134#ifndef SWIG
    115135#define psTrace(facil, level, ...) p_psTrace(__FILE__,__LINE__,__func__,facil, level, __VA_ARGS__)
     136#define psTraceGetLevel(facil) p_psTraceGetLevel(__FILE__,__LINE__,__func__,facil)
    116137/** Sends a trace message. */
    117138void psTraceV(
    … …  
    131152    const char *facil,                 ///< facilty of interest
    132153    int level                          ///< desired trace level
    133 );
    134 
    135 /** Get the trace level
    136  *
    137  *  @return int:    Trace Level
    138  */
    139 int psTraceGetLevel(
    140     const char *facil                  ///< facilty of interest
    141154);
    142155
Note: See TracChangeset for help on using the changeset viewer.