Changeset 1731 for trunk/psLib/src/sysUtils/psTrace.c
- Timestamp:
- Sep 8, 2004, 11:22:47 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sysUtils/psTrace.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sysUtils/psTrace.c
r1718 r1731 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-08 05:59:41$11 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-08 21:22:47 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 48 48 #include "psString.h" 49 49 #include "psError.h" 50 #include "psAbort.h" 50 #include "psLogMsg.h" 51 52 #include "psSysUtilsErrors.h" 51 53 52 54 static p_psComponent* cRoot = NULL; // The root of the trace component … … 117 119 for (i = 0; i < currentNode->n; i++) { 118 120 if (NULL == currentNode->subcomp[i]) { 119 psError(__func__, 120 "Sub-component %d of node %s in the trace tree is NULL.\n", i, currentNode->name); 121 psLogMsg(PS_ERRORNAME_DOMAIN "p_psTraceReset", PS_LOG_WARN, 122 PS_ERRORTEXT_psTrace_NULL_SUBCOMPONENT, 123 i, currentNode->name); 121 124 } else { 122 125 p_psTraceReset(currentNode->subcomp[i]); … … 141 144 to ANSI-C. 142 145 *****************************************************************************/ 143 static voidcomponentAdd(const char *addNodeName, int level)146 static bool componentAdd(const char *addNodeName, int level) 144 147 { 145 148 int i = 0; // Loop index variable. … … 152 155 // XXX: Verify that this is the correct behavior. 153 156 if (strcmp("", addNodeName) == 0) { 154 psAbort(__func__, "Failed to add null component to trace tree.\n"); 157 psErrorMsg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_NULL,true, 158 PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT); 159 return false; 155 160 } 156 161 … … 158 163 if (strcmp(".", addNodeName) == 0) { 159 164 cRoot->level = level; 160 return ;165 return true; 161 166 } 162 167 163 168 if (addNodeName[0] != '.') { 164 printf("ERROR: failed to add %s to the root component tree.\n", addNodeName); 165 exit(1); 169 psErrorMsg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_VALUE,true, 170 PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME, 171 addNodeName); 172 return false; 166 173 } 167 174 … … 205 212 } 206 213 } 214 215 return true; 207 216 } 208 217 … … 218 227 zero 219 228 *****************************************************************************/ 220 intpsTraceSetLevel(const char *comp, // component of interest221 int level) // desired trace level229 bool psTraceSetLevel(const char *comp, // component of interest 230 int level) // desired trace level 222 231 { 223 232 // If the root component tree does not exist, then initialize it. … … 226 235 } 227 236 // Add the new component to the component tree. 228 componentAdd(comp, level); 229 230 // return 0 on success. 231 return 0; 237 if ( !componentAdd(comp, level) ) { 238 psErrorMsg(PS_ERRORNAME_DOMAIN "psTraceSetLevel", PS_ERR_UNKNOWN, false, 239 PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT,level,comp); 240 return false; 241 } 242 return true; 232 243 } 233 244 … … 274 285 for (i = 0; i < currentNode->n; i++) { 275 286 if (NULL == currentNode->subcomp[i]) { 276 psError(__func__, 277 "Sub-component %d of node %s in trace tree is NULL.\n", i, currentNode->name); 287 psLogMsg(PS_ERRORNAME_DOMAIN "p_psTraceReset", PS_LOG_WARN, 288 PS_ERRORTEXT_psTrace_NULL_SUBCOMPONENT, 289 i, currentNode->name); 278 290 } 279 291 … … 321 333 322 334 /***************************************************************************** 323 doPrintTraceLevelsOld()324 This function recursively searches the component tree supplied by the325 parameter "comp" and prints the name and level of each component.326 Inputs:327 comp: a node in the component tree.328 level: the level of that node329 Outputs:330 none331 Returns:332 null333 *****************************************************************************/334 static void doPrintTraceLevelsOld(const p_psComponent* comp, int depth)335 {336 int i = 0;337 338 if (comp->name[0] == '\0') {339 printf("%*s%-*s %d\n", depth, "", 20 - depth,340 "(root)", (comp->level == PS_DEFAULT_TRACE_LEVEL) ? 0 : comp->level);341 } else {342 if (comp->level == PS_DEFAULT_TRACE_LEVEL) {343 printf("%*s%-*s %s\n", depth, "", 20 - depth, comp->name, ".");344 } else {345 printf("%*s%-*s %d\n", depth, "", 20 - depth, comp->name,346 comp->level);347 }348 }349 350 for (i = 0; i < comp->n; i++) {351 doPrintTraceLevelsOld(comp->subcomp[i], depth + 1);352 }353 }354 355 /*****************************************************************************356 335 doPrintTraceLevels() 357 336 This function recursively searches the component tree supplied by the … … 372 351 373 352 if (comp->name[0] == '\0') { 374 psAbort(__func__, "component name is NULL\n");353 return; 375 354 } else { 376 355 if (comp->level == PS_DEFAULT_TRACE_LEVEL) { … … 435 414 436 415 if (NULL == comp) { 437 psError(__func__, "p_psTrace() called on a NULL trace level tree\n"); 416 psErrorMsg(PS_ERRORNAME_DOMAIN "psTrace", PS_ERR_BAD_PARAMETER_NULL, true, 417 PS_ERRORTEXT_psTrace_NULL_TRACETREE, 418 __func__); 419 return; 438 420 } 439 421 // Only display this message if it's trace level is less than the level
Note:
See TracChangeset
for help on using the changeset viewer.
