IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 30, 2007, 2:38:46 PM (19 years ago)
Author:
Paul Price
Message:

Adding psTraceLevels to return a metadata with the trace levels.

File:
1 edited

Legend:

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

    r11265 r11449  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.80 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-01-24 22:14:48 $
     11 *  @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2007-01-31 00:38:46 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5656#include "psError.h"
    5757#include "psLogMsg.h"
     58#include "psMetadata.h"
    5859
    5960#define MAX_HOSTNAME_LENGTH 256
     
    761762
    762763
     764static void doGetTraceLevels(psMetadata *out, // Output metadata with the trace levels
     765                             const p_psComponent* comp, // Component to add
     766                             psString parent, // Name of parent level
     767                             int defLevel // Default level
     768                            )
     769{
     770    if (comp->name[0] == '\0') {
     771        return;
     772    }
     773
     774    psString name = psStringCopy(parent); // Name of this level
     775    if (comp->name[0] == '.') {
     776        psStringAppend(&name, "%s", comp->name + 1);
     777    } else if (!parent) {
     778        psStringAppend(&name, "%s", comp->name);
     779    } else {
     780        psStringAppend(&name, ".%s", comp->name);
     781    }
     782
     783    int level = (comp->level == PS_DEFAULT_TRACE_LEVEL) ? defLevel : comp->level; // Level for component
     784    if (name) {
     785        psMetadataAddS32(out, PS_LIST_TAIL, name, 0, NULL, level);
     786    }
     787    for (int i = 0; i < comp->n; i++) {
     788        doGetTraceLevels(out, comp->subcomp[i], name, level);
     789    }
     790
     791    psFree(name);
     792
     793    return;
     794}
     795
     796
     797psMetadata *psTraceLevels(void)
     798{
     799    if (cRoot == NULL) {
     800        return psMetadataAlloc();
     801    }
     802
     803    psMetadata *out = psMetadataAlloc();// Output metadata with the levels
     804    doGetTraceLevels(out, cRoot, NULL, PS_THE_OTHER_DEFAULT_TRACE_LEVEL);
     805
     806    return out;
     807}
     808
    763809
    764810#endif // #ifndef PS_NO_TRACE
Note: See TracChangeset for help on using the changeset viewer.