IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3781


Ignore:
Timestamp:
Apr 28, 2005, 1:46:29 PM (21 years ago)
Author:
desonia
Message:

bug #379 - folded in posted changes.

Location:
trunk/psLib
Files:
7 edited

Legend:

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

    r3682 r3781  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.45 $ $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 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    252252    if (cRoot == NULL) {
    253253        initTrace();
     254    }
     255
     256    if (traceFP == NULL) {
     257        traceFP = stdout;
    254258    }
    255259
     
    425429    psS32 i = 0;
    426430
     431    if (traceFP == NULL) {
     432        traceFP = stderr;
     433    }
     434
    427435    if (comp->name[0] == '\0') {
    428436        return;
    429437    } else {
    430438        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);
    438440        } 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);
    446442        }
    447443    }
     
    498494    psS32 i = 0;
    499495
     496    if (traceFP == NULL) {
     497        traceFP = stderr;
     498    }
     499
    500500    if (NULL == comp) {
    501501        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     
    514514        fmt = va_arg(ap, char *);
    515515
    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);
    529521        va_end(ap);
    530522    }
    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)
    534526void psTraceSetDestination(FILE * fp)
    535527{
     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    }
    536545    traceFP = fp;
    537546}
    538547
     548FILE *psTraceGetDestination()
     549{
     550    if (traceFP == NULL) {
     551        traceFP = stderr;
     552    }
     553    return traceFP;
     554}
     555
    539556#endif
  • trunk/psLib/src/sys/psTrace.h

    r3264 r3781  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-02-17 19:26:24 $
     11 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-04-28 23:46:29 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2929//#define PS_NO_TRACE 1   ///< to turn off all tracing
    3030
    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
    4543
    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        }
    5859p_psComponent;
    5960
     
    7273#ifndef SWIG
    7374#define psTrace(facil, level, ...) p_psTrace(facil, level, __VA_ARGS__)
    74 #endif
     75#endif /* SWIG */
    7576
    76 #endif
     77#endif /* DOXYGEN */
    7778
    7879/// Set trace level
     
    8283
    8384/// Get the trace level
    84 psS32 psTraceGetLevel(const char *facil)     ///< facilty of interest
     85psS32 psTraceGetLevel(const char *facil) ///< facilty of interest
    8586;
    8687
     
    9495void psTraceSetDestination(FILE * fp);
    9596
     97/// Get the current destination for trace messages.
     98FILE *psTraceGetDestination(void);
     99
    96100/* \} */// End of SystemGroup Functions
    97101
    98 #endif
     102#endif /* PS_NO_TRACE */
    99103
    100 #endif
     104#endif /* PS_TRACE_H */
     105
  • trunk/psLib/src/sysUtils/psTrace.c

    r3682 r3781  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.45 $ $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 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    252252    if (cRoot == NULL) {
    253253        initTrace();
     254    }
     255
     256    if (traceFP == NULL) {
     257        traceFP = stdout;
    254258    }
    255259
     
    425429    psS32 i = 0;
    426430
     431    if (traceFP == NULL) {
     432        traceFP = stderr;
     433    }
     434
    427435    if (comp->name[0] == '\0') {
    428436        return;
    429437    } else {
    430438        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);
    438440        } 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);
    446442        }
    447443    }
     
    498494    psS32 i = 0;
    499495
     496    if (traceFP == NULL) {
     497        traceFP = stderr;
     498    }
     499
    500500    if (NULL == comp) {
    501501        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     
    514514        fmt = va_arg(ap, char *);
    515515
    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);
    529521        va_end(ap);
    530522    }
    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)
    534526void psTraceSetDestination(FILE * fp)
    535527{
     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    }
    536545    traceFP = fp;
    537546}
    538547
     548FILE *psTraceGetDestination()
     549{
     550    if (traceFP == NULL) {
     551        traceFP = stderr;
     552    }
     553    return traceFP;
     554}
     555
    539556#endif
  • trunk/psLib/src/sysUtils/psTrace.h

    r3264 r3781  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-02-17 19:26:24 $
     11 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-04-28 23:46:29 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2929//#define PS_NO_TRACE 1   ///< to turn off all tracing
    3030
    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
    4543
    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        }
    5859p_psComponent;
    5960
     
    7273#ifndef SWIG
    7374#define psTrace(facil, level, ...) p_psTrace(facil, level, __VA_ARGS__)
    74 #endif
     75#endif /* SWIG */
    7576
    76 #endif
     77#endif /* DOXYGEN */
    7778
    7879/// Set trace level
     
    8283
    8384/// Get the trace level
    84 psS32 psTraceGetLevel(const char *facil)     ///< facilty of interest
     85psS32 psTraceGetLevel(const char *facil) ///< facilty of interest
    8586;
    8687
     
    9495void psTraceSetDestination(FILE * fp);
    9596
     97/// Get the current destination for trace messages.
     98FILE *psTraceGetDestination(void);
     99
    96100/* \} */// End of SystemGroup Functions
    97101
    98 #endif
     102#endif /* PS_NO_TRACE */
    99103
    100 #endif
     104#endif /* PS_TRACE_H */
     105
  • trunk/psLib/test/runTest

    r3769 r3781  
    2626#
    2727#  $Revison:  $  $Name: not supported by cvs2svn $
    28 #  $Date: 2005-04-26 19:53:30 $
     28#  $Date: 2005-04-28 23:46:29 $
    2929#
    3030#  Copyright 2004 Maui High Performance Computering Center, University of Hawaii
     
    354354
    355355        # Perform difference on the STD stream files
    356         $diffstdout = `diff $streamFile $tempFile`;
     356        $diffstdout = `diff -b -y --suppress-common-lines $streamFile $tempFile`;
    357357
    358358        # Check the return value of the difference
  • trunk/psLib/test/sysUtils/verified/tst_psTrace.stderr

    r3542 r3781  
    6464     (1) This message should be displayed (beefface)
    6565     (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)
    6669
    6770---> 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)
    41     (0) This message should be displayed (beefface)
    52     (1) This message should be displayed (beefface)
Note: See TracChangeset for help on using the changeset viewer.