Changeset 3781
- Timestamp:
- Apr 28, 2005, 1:46:29 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 7 edited
-
src/sys/psTrace.c (modified) (5 diffs)
-
src/sys/psTrace.h (modified) (5 diffs)
-
src/sysUtils/psTrace.c (modified) (5 diffs)
-
src/sysUtils/psTrace.h (modified) (5 diffs)
-
test/runTest (modified) (2 diffs)
-
test/sysUtils/verified/tst_psTrace.stderr (modified) (1 diff)
-
test/sysUtils/verified/tst_psTrace.stdout (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psTrace.c
r3682 r3781 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-04- 07 20:27:41$11 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-04-28 23:46:29 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 252 252 if (cRoot == NULL) { 253 253 initTrace(); 254 } 255 256 if (traceFP == NULL) { 257 traceFP = stdout; 254 258 } 255 259 … … 425 429 psS32 i = 0; 426 430 431 if (traceFP == NULL) { 432 traceFP = stderr; 433 } 434 427 435 if (comp->name[0] == '\0') { 428 436 return; 429 437 } else { 430 438 if (comp->level == PS_DEFAULT_TRACE_LEVEL) { 431 if (traceFP == NULL) { 432 printf("%*s%-*s %d\n", depth, "", 20 - depth, comp->name, 433 defLevel); 434 } else { 435 fprintf(traceFP,"%*s%-*s %d\n", depth, "", 20 - depth, comp->name, 436 defLevel); 437 } 439 fprintf(traceFP,"%*s%-*s %d\n", depth, "", 20 - depth, comp->name, defLevel); 438 440 } else { 439 if (traceFP == NULL) { 440 printf("%*s%-*s %d\n", depth, "", 20 - depth, comp->name, 441 comp->level); 442 } else { 443 fprintf(traceFP, "%*s%-*s %d\n", depth, "", 20 - depth, comp->name, 444 comp->level); 445 } 441 fprintf(traceFP, "%*s%-*s %d\n", depth, "", 20 - depth, comp->name, comp->level); 446 442 } 447 443 } … … 498 494 psS32 i = 0; 499 495 496 if (traceFP == NULL) { 497 traceFP = stderr; 498 } 499 500 500 if (NULL == comp) { 501 501 psError(PS_ERR_BAD_PARAMETER_NULL, true, … … 514 514 fmt = va_arg(ap, char *); 515 515 516 if (traceFP != NULL) { 517 // We indent each message one space for each level of the message. 518 for (i = 0; i < level; i++) { 519 fprintf(traceFP, " "); 520 } 521 vfprintf(traceFP, fmt, ap); 522 } else { 523 // We indent each message one space for each level of the message. 524 for (i = 0; i < level; i++) { 525 putchar(' '); 526 } 527 vprintf(fmt, ap); 528 } 516 // We indent each message one space for each level of the message. 517 for (i = 0; i < level; i++) { 518 fprintf(traceFP, " "); 519 } 520 vfprintf(traceFP, fmt, ap); 529 521 va_end(ap); 530 522 } 531 // NOTE: should we free *fmt as well? Read the man page. 532 } 533 523 } 524 525 // XXX EAM : I've added code to close the old traceFP (safely) 534 526 void psTraceSetDestination(FILE * fp) 535 527 { 528 529 bool special; 530 531 // XXX EAM perhaps return an error? 532 if (fp == NULL) { 533 return; 534 } 535 536 // cannot close traceFP if one of the special FILE ptrs 537 special = (traceFP == NULL); 538 special |= (traceFP == stdin); 539 special |= (traceFP == stdout); 540 special |= (traceFP == stderr); 541 542 if (!special) { 543 fclose (traceFP); 544 } 536 545 traceFP = fp; 537 546 } 538 547 548 FILE *psTraceGetDestination() 549 { 550 if (traceFP == NULL) { 551 traceFP = stderr; 552 } 553 return traceFP; 554 } 555 539 556 #endif -
trunk/psLib/src/sys/psTrace.h
r3264 r3781 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 2-17 19:26:24$11 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-04-28 23:46:29 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 29 29 //#define PS_NO_TRACE 1 ///< to turn off all tracing 30 30 31 #if defined(PS_NO_TRACE) 32 # define psTrace(facil, level, ...) (void)0 33 /* do nothing */ 34 # define p_psTrace(facil, level, ...) (void)0 35 /* do nothing */ 36 # define psTraceSetLevel(facil,level) 0 37 # define psTraceGetLevel(facil) 0 38 # define psTraceReset() (void)0 /* do nothing */ 39 # define psTraceFree() (void)0 /* do nothing */ 40 # define psTracePrintLevels() (void)0 41 /* do nothing */ 42 # define psTraceSetDestination(fp) (void)0 43 /* do nothing */ 44 # else 31 // XXX EAM : the old 'empty' values of (void) 0 are dangerous 32 # if defined(PS_NO_TRACE) 33 # define psTrace(facil, level, ...) /* do nothing */ 34 # define p_psTrace(facil, level, ...) /* do nothing */ 35 # define psTraceSetLevel(facil,level) /* do nothing */ 36 # define psTraceGetLevel(facil) /* do nothing */ 37 # define psTraceReset() /* do nothing */ 38 # define psTraceFree() /* do nothing */ 39 # define psTracePrintLevels() /* do nothing */ 40 # define psTraceSetDestination(fp) /* do nothing */ 41 # define psTraceSetDestination() /* do nothing */ 42 # define PS_TRACE_ON 0 45 43 46 /** Basic structure for the component tree. A component is a string of the 47 form aaa.bbb.ccc, and may itself contain further subcomponents. The 48 Component structure doesn't in fact contain it's full name, but only the 49 last part. */ 50 typedef struct p_psComponent 51 { 52 const char *name; // last part of name of component 53 psS32 level; // trace level for this component 54 bool p_psSpecified; 55 psS32 n; // number of subcomponents 56 struct p_psComponent* *subcomp; // next level of subcomponents 57 } 44 # else /* PS_NO_TRACE */ 45 # define PS_TRACE_ON 1 46 47 /** Basic structure for the component tree. A component is a string of the 48 form aaa.bbb.ccc, and may itself contain further subcomponents. The 49 Component structure doesn't in fact contain it's full name, but only the 50 last part. */ 51 typedef struct p_psComponent 52 { 53 const char *name; // last part of name of component 54 psS32 level; // trace level for this component 55 bool p_psSpecified; 56 psS32 n; // number of subcomponents 57 struct p_psComponent* *subcomp; // next level of subcomponents 58 } 58 59 p_psComponent; 59 60 … … 72 73 #ifndef SWIG 73 74 #define psTrace(facil, level, ...) p_psTrace(facil, level, __VA_ARGS__) 74 #endif 75 #endif /* SWIG */ 75 76 76 #endif 77 #endif /* DOXYGEN */ 77 78 78 79 /// Set trace level … … 82 83 83 84 /// Get the trace level 84 psS32 psTraceGetLevel(const char *facil) ///< facilty of interest85 psS32 psTraceGetLevel(const char *facil) ///< facilty of interest 85 86 ; 86 87 … … 94 95 void psTraceSetDestination(FILE * fp); 95 96 97 /// Get the current destination for trace messages. 98 FILE *psTraceGetDestination(void); 99 96 100 /* \} */// End of SystemGroup Functions 97 101 98 #endif 102 #endif /* PS_NO_TRACE */ 99 103 100 #endif 104 #endif /* PS_TRACE_H */ 105 -
trunk/psLib/src/sysUtils/psTrace.c
r3682 r3781 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-04- 07 20:27:41$11 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-04-28 23:46:29 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 252 252 if (cRoot == NULL) { 253 253 initTrace(); 254 } 255 256 if (traceFP == NULL) { 257 traceFP = stdout; 254 258 } 255 259 … … 425 429 psS32 i = 0; 426 430 431 if (traceFP == NULL) { 432 traceFP = stderr; 433 } 434 427 435 if (comp->name[0] == '\0') { 428 436 return; 429 437 } else { 430 438 if (comp->level == PS_DEFAULT_TRACE_LEVEL) { 431 if (traceFP == NULL) { 432 printf("%*s%-*s %d\n", depth, "", 20 - depth, comp->name, 433 defLevel); 434 } else { 435 fprintf(traceFP,"%*s%-*s %d\n", depth, "", 20 - depth, comp->name, 436 defLevel); 437 } 439 fprintf(traceFP,"%*s%-*s %d\n", depth, "", 20 - depth, comp->name, defLevel); 438 440 } else { 439 if (traceFP == NULL) { 440 printf("%*s%-*s %d\n", depth, "", 20 - depth, comp->name, 441 comp->level); 442 } else { 443 fprintf(traceFP, "%*s%-*s %d\n", depth, "", 20 - depth, comp->name, 444 comp->level); 445 } 441 fprintf(traceFP, "%*s%-*s %d\n", depth, "", 20 - depth, comp->name, comp->level); 446 442 } 447 443 } … … 498 494 psS32 i = 0; 499 495 496 if (traceFP == NULL) { 497 traceFP = stderr; 498 } 499 500 500 if (NULL == comp) { 501 501 psError(PS_ERR_BAD_PARAMETER_NULL, true, … … 514 514 fmt = va_arg(ap, char *); 515 515 516 if (traceFP != NULL) { 517 // We indent each message one space for each level of the message. 518 for (i = 0; i < level; i++) { 519 fprintf(traceFP, " "); 520 } 521 vfprintf(traceFP, fmt, ap); 522 } else { 523 // We indent each message one space for each level of the message. 524 for (i = 0; i < level; i++) { 525 putchar(' '); 526 } 527 vprintf(fmt, ap); 528 } 516 // We indent each message one space for each level of the message. 517 for (i = 0; i < level; i++) { 518 fprintf(traceFP, " "); 519 } 520 vfprintf(traceFP, fmt, ap); 529 521 va_end(ap); 530 522 } 531 // NOTE: should we free *fmt as well? Read the man page. 532 } 533 523 } 524 525 // XXX EAM : I've added code to close the old traceFP (safely) 534 526 void psTraceSetDestination(FILE * fp) 535 527 { 528 529 bool special; 530 531 // XXX EAM perhaps return an error? 532 if (fp == NULL) { 533 return; 534 } 535 536 // cannot close traceFP if one of the special FILE ptrs 537 special = (traceFP == NULL); 538 special |= (traceFP == stdin); 539 special |= (traceFP == stdout); 540 special |= (traceFP == stderr); 541 542 if (!special) { 543 fclose (traceFP); 544 } 536 545 traceFP = fp; 537 546 } 538 547 548 FILE *psTraceGetDestination() 549 { 550 if (traceFP == NULL) { 551 traceFP = stderr; 552 } 553 return traceFP; 554 } 555 539 556 #endif -
trunk/psLib/src/sysUtils/psTrace.h
r3264 r3781 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 2-17 19:26:24$11 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-04-28 23:46:29 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 29 29 //#define PS_NO_TRACE 1 ///< to turn off all tracing 30 30 31 #if defined(PS_NO_TRACE) 32 # define psTrace(facil, level, ...) (void)0 33 /* do nothing */ 34 # define p_psTrace(facil, level, ...) (void)0 35 /* do nothing */ 36 # define psTraceSetLevel(facil,level) 0 37 # define psTraceGetLevel(facil) 0 38 # define psTraceReset() (void)0 /* do nothing */ 39 # define psTraceFree() (void)0 /* do nothing */ 40 # define psTracePrintLevels() (void)0 41 /* do nothing */ 42 # define psTraceSetDestination(fp) (void)0 43 /* do nothing */ 44 # else 31 // XXX EAM : the old 'empty' values of (void) 0 are dangerous 32 # if defined(PS_NO_TRACE) 33 # define psTrace(facil, level, ...) /* do nothing */ 34 # define p_psTrace(facil, level, ...) /* do nothing */ 35 # define psTraceSetLevel(facil,level) /* do nothing */ 36 # define psTraceGetLevel(facil) /* do nothing */ 37 # define psTraceReset() /* do nothing */ 38 # define psTraceFree() /* do nothing */ 39 # define psTracePrintLevels() /* do nothing */ 40 # define psTraceSetDestination(fp) /* do nothing */ 41 # define psTraceSetDestination() /* do nothing */ 42 # define PS_TRACE_ON 0 45 43 46 /** Basic structure for the component tree. A component is a string of the 47 form aaa.bbb.ccc, and may itself contain further subcomponents. The 48 Component structure doesn't in fact contain it's full name, but only the 49 last part. */ 50 typedef struct p_psComponent 51 { 52 const char *name; // last part of name of component 53 psS32 level; // trace level for this component 54 bool p_psSpecified; 55 psS32 n; // number of subcomponents 56 struct p_psComponent* *subcomp; // next level of subcomponents 57 } 44 # else /* PS_NO_TRACE */ 45 # define PS_TRACE_ON 1 46 47 /** Basic structure for the component tree. A component is a string of the 48 form aaa.bbb.ccc, and may itself contain further subcomponents. The 49 Component structure doesn't in fact contain it's full name, but only the 50 last part. */ 51 typedef struct p_psComponent 52 { 53 const char *name; // last part of name of component 54 psS32 level; // trace level for this component 55 bool p_psSpecified; 56 psS32 n; // number of subcomponents 57 struct p_psComponent* *subcomp; // next level of subcomponents 58 } 58 59 p_psComponent; 59 60 … … 72 73 #ifndef SWIG 73 74 #define psTrace(facil, level, ...) p_psTrace(facil, level, __VA_ARGS__) 74 #endif 75 #endif /* SWIG */ 75 76 76 #endif 77 #endif /* DOXYGEN */ 77 78 78 79 /// Set trace level … … 82 83 83 84 /// Get the trace level 84 psS32 psTraceGetLevel(const char *facil) ///< facilty of interest85 psS32 psTraceGetLevel(const char *facil) ///< facilty of interest 85 86 ; 86 87 … … 94 95 void psTraceSetDestination(FILE * fp); 95 96 97 /// Get the current destination for trace messages. 98 FILE *psTraceGetDestination(void); 99 96 100 /* \} */// End of SystemGroup Functions 97 101 98 #endif 102 #endif /* PS_NO_TRACE */ 99 103 100 #endif 104 #endif /* PS_TRACE_H */ 105 -
trunk/psLib/test/runTest
r3769 r3781 26 26 # 27 27 # $Revison: $ $Name: not supported by cvs2svn $ 28 # $Date: 2005-04-2 6 19:53:30$28 # $Date: 2005-04-28 23:46:29 $ 29 29 # 30 30 # Copyright 2004 Maui High Performance Computering Center, University of Hawaii … … 354 354 355 355 # Perform difference on the STD stream files 356 $diffstdout = `diff $streamFile $tempFile`;356 $diffstdout = `diff -b -y --suppress-common-lines $streamFile $tempFile`; 357 357 358 358 # Check the return value of the difference -
trunk/psLib/test/sysUtils/verified/tst_psTrace.stderr
r3542 r3781 64 64 (1) This message should be displayed (beefface) 65 65 (2) This message should be displayed (beefface) 66 (0) This message should be displayed (beefface) 67 (1) This message should be displayed (beefface) 68 (2) This message should be displayed (beefface) 66 69 67 70 ---> TESTPOINT PASSED (psTrace{psTrace()} | tst_psTrace.c) -
trunk/psLib/test/sysUtils/verified/tst_psTrace.stdout
r2110 r3781 1 (0) This message should be displayed (beefface)2 (1) This message should be displayed (beefface)3 (2) This message should be displayed (beefface)4 1 (0) This message should be displayed (beefface) 5 2 (1) This message should be displayed (beefface)
Note:
See TracChangeset
for help on using the changeset viewer.
