psLogMsg.h

Go to the documentation of this file.
00001 /** @file  psLogMsg.h
00002  *
00003  *  @brief Procedures for logging messages.
00004  *
00005  *  This file will hold the prototypes for defining procedure which set
00006  *  message log levels, messahe log formats, message log destinations, and
00007  *  for generating the messages themselves.
00008  *
00009  *  @author Robert Lupton, Princeton University
00010  *  @author GLG, MHPCC
00011  *
00012  *  @version $Revision: 1.38 $ $Name:  $
00013  *  @date $Date: 2007/01/23 22:47:23 $
00014  *
00015  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00016  */
00017 
00018 #ifndef PS_LOG_MSG_H
00019 #define PS_LOG_MSG_H
00020 
00021 /// @addtogroup SysUtils System Utilities
00022 /// @{
00023 
00024 #include <stdarg.h>
00025 #include "psType.h"
00026 
00027 /** This procedure sets the destination for future log messages.
00028  *
00029  *  This procedure will take an integer as an argument
00030  *  which can specify general log destinations.
00031  *
00032  *  @return bool     true if set successfully, otherwise false.
00033  */
00034 bool psLogSetDestination(
00035     int fd                             ///< Specifies where to send messages.
00036 );
00037 
00038 /** This procedure returns the current log destination file descriptor.  If the
00039  *  destination has not been defined by the use, the descriptor for stdout is returned.
00040  *
00041  *  @return int:        The current file descriptor.
00042  */
00043 int psLogGetDestination();
00044 
00045 /** This procedure sets the message level for future log messages.  Subsequent
00046  *  log messages, with a log level of "mylevel", will only be logged if
00047  *  "mylevel" is less than the current log level set by this procedure.
00048  *  Ie. higher values set by this procedure will cause more log messages to
00049  *  be displayed.  The old log level will be returned.
00050  *
00051  *  @return int:        old logging level.
00052  */
00053 int psLogSetLevel(
00054     int level                          ///< Specifies the system log level
00055 );
00056 
00057 /** This procedures returns the current log message level.
00058  *
00059  *  @return int:        The current logging level.
00060  */
00061 int psLogGetLevel();
00062 
00063 /** This procedure sets the log format for future log 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 psLogSetFormat(
00073     const char *format                 ///< Specifies the system log format
00074 );
00075 
00076 /** This procedures uses a string to set the destination for which to send
00077  *  the corresponding log messages.
00078  *
00079  *  @return int:        The file descriptor location of the message.
00080  */
00081 int psMessageDestination(
00082     const char *dest                   ///< Specifies where to send the message
00083 );
00084 
00085 /** This procedure logs a message to the destination set by a prior
00086  *  call to psLogSetDestination(), if myLevel is less than the level
00087  *  specified by a prior call to psLogSetLevel().  The message is specified
00088  *  with a printf-type string and arguments.
00089  *
00090  */
00091 #ifdef __GNUC__
00092 void psLogMsg(
00093     const char *name,                  ///< name of the log source
00094     int level,                         ///< severity level of this log message
00095     const char *format,                ///< printf-style format command
00096     ...
00097 ) __attribute__((format(printf, 3, 4)));
00098 #else // __GNUC__
00099 void psLogMsg(
00100     const char *name,                  ///< name of the log source
00101     int level,                         ///< severity level of this log message
00102     const char *format,                ///< printf-style format command
00103     ...
00104 );
00105 #endif // __GNUC__
00106 
00107 #ifndef SWIG
00108 /** This procedure is functionally equivalent to psLogMsg(), except that
00109  *  it takes a va_list as the message parameter, not a printf-style string.
00110  *
00111  */
00112 void psLogMsgV(
00113     const char *name,                  ///< name of the log source
00114     int level,                         ///< severity level of this log message
00115     const char *format,                ///< printf-style format command
00116     va_list ap                         ///< varargs argument list
00117 );
00118 #endif // #ifndef SWIG
00119 
00120 ///< Status codes for log messages
00121 enum {
00122     PS_LOG_ABORT = 0,                  ///< log message is a critical error, perform an abort after printing
00123     PS_LOG_ERROR,                      ///< log message is an error, but don't abort
00124     PS_LOG_WARN,                       ///< log message is a warning
00125     PS_LOG_INFO,                       ///< log message is informational only
00126     PS_LOG_DETAIL,                     ///< log message provides details of minor interest
00127     PS_LOG_MINUTIA,                    ///< log message provides very detailed information
00128 };
00129 
00130 ///< Destinations for log messages
00131 enum {
00132     PS_LOG_TO_NONE = 0,                ///< turn off logging
00133     PS_LOG_TO_STDERR = 1,              ///< log to system's stderr
00134     PS_LOG_TO_STDOUT = 2               ///< log to system's stdout
00135 };
00136 
00137 /// @}
00138 #endif // #ifndef PS_LOG_MSG_H

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1