Changeset 707 for trunk/archive/pslib/src/Utils/trace.c
- Timestamp:
- May 17, 2004, 7:53:16 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/archive/pslib/src/Utils/trace.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/pslib/src/Utils/trace.c
r569 r707 34 34 #define NO_CACHE "\a" // no name is cached 35 35 36 #define UNKNOWN_LEVEL -9999 // we don 't know this name's level36 #define UNKNOWN_LEVEL -9999 // we don\'t know this name\'s level 37 37 38 38 static char cachedName[CACHE_NAME_LEN + 1] = NO_CACHE; // last name looked up … … 176 176 /*****************************************************************************/ 177 177 178 int ps SetTraceLevel(const char *comp, // component of interest178 int psTraceSetLevel(const char *comp, // component of interest 179 179 int level) // desired trace level 180 180 { … … 201 201 * Return a trace level given a name 202 202 */ 203 static int do GetTraceLevel(const Component *comp, // end of component to search203 static int doTraceGetLevel(const Component *comp, // end of component to search 204 204 const char *aname) // name to find 205 205 { … … 215 215 for (int i = 0; i < comp->n; i++) { 216 216 if (strcmp(comp->subcomp[i]->name, cpt0) == 0) { // a match 217 if (rest == NULL) { // we 're there217 if (rest == NULL) { // we\'re there 218 218 int level = comp->subcomp[i]->level; 219 219 220 220 return (level == UNKNOWN_LEVEL) ? comp->level : level; 221 221 } else { 222 return do GetTraceLevel(comp->subcomp[i], rest);222 return doTraceGetLevel(comp->subcomp[i], rest); 223 223 } 224 224 } … … 230 230 } 231 231 232 int ps GetTraceLevel(const char *name) // component of interest232 int psTraceGetLevel(const char *name) // component of interest 233 233 { 234 234 if (croot == NULL) { … … 240 240 } 241 241 242 int level = do GetTraceLevel(croot, name);242 int level = doTraceGetLevel(croot, name); 243 243 244 244 strncpy(cachedName, name, CACHE_NAME_LEN); … … 252 252 * Print a tree of trace levels 253 253 */ 254 static void do PrintTraceLevels(const Component *comp, int depth)254 static void doTracePrintLevels(const Component *comp, int depth) 255 255 { 256 256 if (comp->name[0] == '\0') { … … 268 268 269 269 for (int i = 0; i < comp->n; i++) { 270 doPrintTraceLevels(comp->subcomp[i], depth + 1);271 } 272 } 273 274 void ps PrintTraceLevels(void)270 doTracePrintLevels(comp->subcomp[i], depth + 1); 271 } 272 } 273 274 void psTracePrintLevels(void) 275 275 { 276 276 if (croot == NULL) { … … 278 278 } 279 279 280 doPrintTraceLevels(croot, 0); 281 } 280 doTracePrintLevels(croot, 0); 281 } 282 283 /*****************************************************************************/ 284 /* 285 * Change where we're writing to; close previous file descriptor 286 * if it isn't stdout/stderr 287 */ 288 static FILE *traceFD = NULL; 289 290 void psTraceSetDestination(FILE *fp) 291 { 292 if (traceFD != stdout && traceFD != stderr) { 293 fclose(traceFD); 294 } 295 296 traceFD = fp; 297 } 298 282 299 283 300 /*****************************************************************************/ … … 290 307 ...) // arguments 291 308 { 292 if (level <= highest_level && psGetTraceLevel(comp) >= level) { 309 if (level <= highest_level && psTraceGetLevel(comp) >= level) { 310 if (traceFD == NULL) { // not initialised, or fopen failed 311 traceFD = stdout; 312 } 313 293 314 va_list ap; 294 315 va_start(ap, level); 295 316 for (int i = 0; i < level; i++) { 296 putchar(' ');317 fputc(' ', traceFD); 297 318 } 298 319 char *fmt = va_arg(ap, char *); 299 v printf(fmt, ap);320 vfprintf(traceFD, fmt, ap); 300 321 if (strchr(fmt, '\n') == NULL) { 301 printf("\n");322 fputc('\n', traceFD); 302 323 } 303 324 va_end(ap);
Note:
See TracChangeset
for help on using the changeset viewer.
