00001 /** @file psLogMsg.h 00002 * @brief Procedures for logging messages. 00003 * \ingroup LogTrace 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 * @ingroup LogTrace 00009 * 00010 * @author Robert Lupton, Princeton University 00011 * @author GLG, MHPCC 00012 * 00013 * @version $Revision: 1.1.1.1 $ $Name: $ 00014 * @date $Date: 2005/10/14 00:32:52 $ 00015 * 00016 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00017 */ 00018 #ifndef PS_LOG_MSG_H 00019 #define PS_LOG_MSG_H 00020 #include <stdarg.h> 00021 00022 #include "psType.h" 00023 00024 /** @addtogroup LogTrace 00025 * @{ 00026 */ 00027 00028 /** This procedure sets the destination for future log messages. 00029 * This procedure will take a character string as an 00030 * argument 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 * 00080 * @return int: The file descriptor location of the message. 00081 */ 00082 int psMessageDestination( 00083 const char *dest ///< Specifies where to send the message 00084 ); 00085 00086 /** This procedure logs a message to the destination set by a prior 00087 * call to psLogSetDestination(), if myLevel is less than the level 00088 * specified by a prior call to psLogSetLevel(). The message is specified 00089 * with a printf-type string and arguments. 00090 * 00091 */ 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 ); 00098 00099 #ifndef SWIG 00100 /** This procedure is functionally equivalent to psLogMsg(), except that 00101 * it takes a va_list as the message parameter, not a printf-style string. 00102 * 00103 */ 00104 void psLogMsgV( 00105 const char *name, ///< name of the log source 00106 int level, ///< severity level of this log message 00107 const char *format, ///< printf-style format command 00108 va_list ap ///< varargs argument list 00109 ); 00110 #endif // #ifndef SWIG 00111 00112 ///< Status codes for log messages 00113 enum { 00114 PS_LOG_ABORT = 0, ///< log message is a critical error, perform an abort after printing 00115 PS_LOG_ERROR, ///< log message is an error, but don't abort 00116 PS_LOG_WARN, ///< log message is a warning 00117 PS_LOG_INFO ///< log message is informational only 00118 }; 00119 00120 ///< Destinations for log messages 00121 enum { 00122 PS_LOG_TO_NONE = 0, ///< turn off logging 00123 PS_LOG_TO_STDERR = 1, ///< log to system's stderr 00124 PS_LOG_TO_STDOUT = 2 ///< log to system's stdout 00125 }; 00126 00127 /// @} 00128 00129 #endif // #ifndef PS_LOG_MSG_H
1.4.2