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/09/14 20:42:48 $
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 /** Functions **************************************************************/
00029 
00030 //#define PS_NO_TRACE 1   ///< to turn off all tracing
00031 
00032 // XXX EAM : the old 'empty' values of (void) 0 are dangerous
00033 # if defined(PS_NO_TRACE)
00034     #   define psTrace(facil, level, ...)   /* do nothing */
00035     #   define p_psTrace(facil, level, ...) /* do nothing */
00036     #   define psTraceSetLevel(facil,level) /* do nothing */
00037     #   define psTraceGetLevel(facil)       /* do nothing */
00038     #   define psTraceReset()               /* do nothing */
00039     #   define psTraceFree()                /* do nothing */
00040     #   define psTracePrintLevels()         /* do nothing */
00041     #   define psTraceSetDestination(fp)    /* do nothing */
00042     #   define psTraceSetDestination()      /* do nothing */
00043     #   define PS_TRACE_ON 0
00044 
00045     # else /* PS_NO_TRACE */
00046         #   define PS_TRACE_ON 1
00047 
00048         /** Basic structure for the component tree.  A component is a string of the
00049             form aaa.bbb.ccc, and may itself contain further subcomponents.  The
00050             Component structure doesn't in fact contain it's full name, but only the
00051             last part. */
00052         typedef struct p_psComponent
00053         {
00054             const char *name;                  ///< last part of name of component
00055             psS32 level;                       ///< trace level for this component
00056             bool p_psSpecified;                ///< whether the component is specified
00057             psS32 n;                           ///< number of subcomponents
00058             struct p_psComponent* *subcomp;    ///< next level of subcomponents
00059         }
00060 p_psComponent;
00061 
00062 #ifdef DOXYGEN
00063 /** This procedure sets the trace format for future trace messages.  The argument
00064  *  must be a character string consistsing of the letters H (host), L
00065  *  (level), M (message), N (name), and T (time).  The default is "THLNM".
00066  *  Deleting a letter from the string will cause the associated information
00067  *  to not be logged.  This procedure does not alter the order in which
00068  *  the messages are displayed.
00069  *
00070  *  @return bool:       True if successful, otherwise false.
00071  */
00072 bool psTraceSetFormat(
00073     const char *format                 ///< Specifies the system trace format
00074 );
00075 
00076 /** Sends a trace message. */
00077 void psTrace(
00078     const char *facil,                 ///< facilty of interest
00079     int level,                         ///< desired trace level
00080     const char *format,                ///< printf-style format command
00081     ...                                ///< trace message arguments
00082 );
00083 
00084 #else
00085 /// Send a trace message
00086 void p_psTrace(
00087     const char *facil,                 ///< facilty of interest
00088     psS32 myLevel,                     ///< desired trace level
00089     const char *format,                ///< printf-style format command
00090     ...                                ///< trace message arguments
00091 );
00092 
00093 #ifndef SWIG
00094 #define psTrace(facil, level, ...) p_psTrace(facil, level, __VA_ARGS__)
00095 /** Sends a trace message. */
00096 void psTraceV(
00097     const char *facil,                 ///< facilty of interest
00098     int level,                         ///< desired trace level
00099     const char *format,                ///< printf-style format command
00100     va_list ap                         ///< varargs argument list
00101 );
00102 
00103 #endif /* SWIG */
00104 
00105 #endif /* DOXYGEN */
00106 
00107 /** Set trace level
00108  *
00109  *  @return int:       The previous level.
00110  */
00111 int psTraceSetLevel(
00112     const char *facil,                 ///< facilty of interest
00113     int level                          ///< desired trace level
00114 );
00115 
00116 /** Get the trace level
00117  *
00118  *  @return int:    Trace Level
00119  */
00120 int psTraceGetLevel(
00121     const char *facil                  ///< facilty of interest
00122 );
00123 
00124 /// Set all trace levels to zero (do not free nodes in the component tree).
00125 void psTraceReset();
00126 
00127 /// print trace levels
00128 void psTracePrintLevels(void);
00129 
00130 /// Set the destination of future trace messages.
00131 void psTraceSetDestination(
00132     int fd                             ///< File descriptor
00133 );
00134 
00135 /** Get the current destination for trace messages.
00136  *
00137  *  @return FILE*:      File Destination
00138  */
00139 int psTraceGetDestination(void);
00140 
00141 /* \} */// End of SystemGroup Functions
00142 
00143 #endif /* PS_NO_TRACE */
00144 
00145 #endif /* PS_TRACE_H */
00146 

Generated on Wed Sep 14 10:42:48 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2