Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psTrace.h

Go to the documentation of this file.
00001 /** @file psTrace.h
00002  *  \brief basic run-time trace facilities
00003  *  \ingroup LogTrace
00004  *
00005  *  This file will hold the prototypes for defining procedures to insert
00006  *  trace messages into the code.
00007  *
00008  *  @author Robert Lupton, Princeton University
00009  *  @author GLG, MHPCC
00010  *
00011  *  @version $Revision: 1.1.1.1 $ $Name:  $
00012  *  @date $Date: 2005/10/14 00:32:52 $
00013  *
00014  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00015  */
00016 #if !defined(PS_TRACE_H)
00017 #define PS_TRACE_H 1
00018 #include <stdarg.h>
00019 
00020 #define PS_UNKNOWN_TRACE_LEVEL -9999   // we don't know this name's level
00021 #define PS_DEFAULT_TRACE_LEVEL -1
00022 #define PS_THE_OTHER_DEFAULT_TRACE_LEVEL 0
00023 
00024 /** \addtogroup LogTrace
00025  *  \{
00026  */
00027 
00028 enum {
00029     PS_TRACE_TO_NONE = 0,             ///< turn off all traces
00030     PS_TRACE_TO_STDOUT = 1,           ///< trace to system's stdout
00031     PS_TRACE_TO_STDERR = 2,           ///< trace to system's stderr
00032 };
00033 
00034 /** Functions **************************************************************/
00035 
00036 //#define PS_NO_TRACE 1   ///< to turn off all tracing
00037 
00038 // XXX EAM : the old 'empty' values of (void) 0 are dangerous
00039 # if defined(PS_NO_TRACE)
00040     #   define psTrace(facil, level, ...)   /* do nothing */
00041     #   define p_psTrace(facil, level, ...) /* do nothing */
00042     #   define psTraceSetLevel(facil,level) /* do nothing */
00043     #   define psTraceGetLevel(facil)       /* do nothing */
00044     #   define psTraceReset()               /* do nothing */
00045     #   define psTraceFree()                /* do nothing */
00046     #   define psTracePrintLevels()         /* do nothing */
00047     #   define psTraceSetDestination(fp)    /* do nothing */
00048     #   define psTraceGetDestination()      /* do nothing */
00049     #   define PS_TRACE_ON 0
00050 
00051     # else /* PS_NO_TRACE */
00052         #   define PS_TRACE_ON 1
00053 
00054         /** Basic structure for the component tree.  A component is a string of the
00055             form aaa.bbb.ccc, and may itself contain further subcomponents.  The
00056             Component structure doesn't in fact contain it's full name, but only the
00057             last part. */
00058         typedef struct p_psComponent
00059         {
00060             const char *name;                  ///< last part of name of component
00061             psS32 level;                       ///< trace level for this component
00062             bool p_psSpecified;                ///< whether the component is specified
00063             psS32 n;                           ///< number of subcomponents
00064             struct p_psComponent* *subcomp;    ///< next level of subcomponents
00065         }
00066 p_psComponent;
00067 
00068 #ifdef DOXYGEN
00069 /** This procedure sets the trace format for future trace messages.  The argument
00070  *  must be a character string consistsing of the letters H (host), L
00071  *  (level), M (message), N (name), and T (time).  The default is "THLNM".
00072  *  Deleting a letter from the string will cause the associated information
00073  *  to not be logged.  This procedure does not alter the order in which
00074  *  the messages are displayed.
00075  *
00076  *  @return bool:       True if successful, otherwise false.
00077  */
00078 bool psTraceSetFormat(
00079     const char *format                 ///< Specifies the system trace format
00080 );
00081 
00082 /** Sends a trace message. */
00083 void psTrace(
00084     const char *facil,                 ///< facilty of interest
00085     int level,                         ///< desired trace level
00086     const char *format,                ///< printf-style format command
00087     ...                                ///< trace message arguments
00088 );
00089 
00090 #else
00091 /// Send a trace message
00092 void p_psTrace(
00093     const char *facil,                 ///< facilty of interest
00094     psS32 myLevel,                     ///< desired trace level
00095     const char *format,                ///< printf-style format command
00096     ...                                ///< trace message arguments
00097 );
00098 
00099 #ifndef SWIG
00100 #define psTrace(facil, level, ...) p_psTrace(facil, level, __VA_ARGS__)
00101 /** Sends a trace message. */
00102 void psTraceV(
00103     const char *facil,                 ///< facilty of interest
00104     int level,                         ///< desired trace level
00105     const char *format,                ///< printf-style format command
00106     va_list ap                         ///< varargs argument list
00107 );
00108 
00109 #endif /* SWIG */
00110 
00111 #endif /* DOXYGEN */
00112 
00113 /** Set trace level
00114  *
00115  *  @return int:       The previous level.
00116  */
00117 int psTraceSetLevel(
00118     const char *facil,                 ///< facilty of interest
00119     int level                          ///< desired trace level
00120 );
00121 
00122 /** Get the trace level
00123  *
00124  *  @return int:    Trace Level
00125  */
00126 int psTraceGetLevel(
00127     const char *facil                  ///< facilty of interest
00128 );
00129 
00130 /// Set all trace levels to zero (do not free nodes in the component tree).
00131 void psTraceReset();
00132 
00133 /// print trace levels
00134 void psTracePrintLevels(void);
00135 
00136 /// Set the destination of future trace messages.
00137 void psTraceSetDestination(
00138     int fd                             ///< File descriptor
00139 );
00140 
00141 /** Get the current destination for trace messages.
00142  *
00143  *  @return FILE*:      File Destination
00144  */
00145 int psTraceGetDestination(void);
00146 
00147 /* \} */// End of SystemGroup Functions
00148 
00149 #endif /* PS_NO_TRACE */
00150 
00151 #endif /* PS_TRACE_H */
00152 

Generated on Thu Oct 13 14:32:52 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2